Get several parameters of one element to male a BOM

63 views
Skip to first unread message

Yoann OBRY

unread,
Apr 1, 2021, 12:30:52 PM4/1/21
to RevitPythonShell
Hi,

I'm working to extract some parameters value of Pipe Accessories in the aim of creating a Bill of materials (BOM). In dynamo I find how to do it but in RPS i have some problems with the  instance and type parameters wich are diffenrent classes.

For example I wand to have a dictionnary or list of list with :

Item 1 : Name,  Description; Size
Item 2 : Name, Description, Size
....

Do you have an idea of this process ?

Here is my script :
(code_cir is a shared parameter)

import clr
import System
clr.AddReference('RevitAPI') 
clr.AddReference('RevitAPIUI') 
from Autodesk.Revit.DB import * 

from System import Guid

code_cir = Guid(r'55934d0c-0246-4ce2-9bdf-57ed4244e11b')

app = __revit__.Application
doc = __revit__.ActiveUIDocument.Document

PA_Type = FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_PipeAccessory).WhereElementIsElementType().ToElements()
PA_Instance = FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_PipeAccessory).WhereElementIsNotElementType().ToElements()

print('Type Parameters:')
for PA in PA_Type:
  
# Get Type Parameter value
nom = PA.get_Parameter(
BuiltInParameter.SYMBOL_FAMILY_NAME_PARAM)
print nom.AsString()

desc = PA.get_Parameter(
BuiltInParameter.ALL_MODEL_DESCRIPTION)
print desc.AsString()

print('Instance Parameters:')
for PA in PA_Instance:

# Get Instance Parameter value
code_circuit = PA.get_Parameter(code_cir)
print code_circuit.AsString()

size = PA.get_Parameter(
BuiltInParameter.RBS_CALCULATED_SIZE)
print size.AsString()

Kind regards,
Yoann

Yoann OBRY

unread,
Apr 3, 2021, 6:33:06 AM4/3/21
to RevitPythonShell
Ok I finally find by myself by inspiring of my python script :-)

It was not easy for a RPS beginner like me, hope it will helps other people.


import clr
import System
clr.AddReference('RevitAPI') 
clr.AddReference('RevitAPIUI') 
from Autodesk.Revit.DB import * 

from System import Guid

code_cir = Guid(r'55934d0c-0246-4ce2-9bdf-57ed4244e11b')

app = __revit__.Application
doc = __revit__.ActiveUIDocument.Document

PAs = FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_PipeAccessory).WhereElementIsNotElementType().ToElements()


for PA in PAs:

print PA.Id
# Get Type Parameter value
PA_type = doc.GetElement(PA.GetTypeId())

nom = PA_type.get_Parameter(
BuiltInParameter.SYMBOL_FAMILY_NAME_PARAM)
print nom.AsString()

desc = PA_type.get_Parameter(
BuiltInParameter.ALL_MODEL_DESCRIPTION)
print desc.AsString()


# Get Instance Parameter value
 
code_circuit = PA.get_Parameter(code_cir)
print code_circuit.AsString()

size = PA.get_Parameter(
BuiltInParameter.RBS_CALCULATED_SIZE)
print size.AsString()

print '-'*20

Yoann OBRY

unread,
Sep 10, 2021, 3:51:40 PM9/10/21
to RevitPythonShell
I just read again my post and I would say I was inspiring by using Dynamo (and not python) to find my solution in RPS.
Reply all
Reply to author
Forward
0 new messages