Revit API Forum
Welcome to Autodesk’s Revit API Forums. Share your knowledge, ask questions, and explore popular Revit API topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Return ConduitRun Elements

2 REPLIES 2
Reply
Message 1 of 3
aaronR7JP6
182 Views, 2 Replies

Return ConduitRun Elements

Long story short, I want to access all conduit elbows in each conduit run on a sheet so I can determine the amount of bend in each run. I can get access to the conduit runs, but I am unable to access each element (conduit) that makes up the run. I'm new to the API so maybe there' an easy solution to this. I have tried GetDependentElements and GetGeneraingElementIds but I'm unsure of he syntax to properly use those methods, or even if those are the correct methods to use. I am using pyRevit to code:

 

    # Collect conduit runs in the selected view
	conduit_runs_collector = DB.FilteredElementCollector(revit.doc).OfClass(DB.Electrical.ConduitRun)
	conduit_runs = conduit_runs_collector.ToElements()

    # Analyze each conduit run
	for conduit_run in conduit_runs:
		print(conduit_run)
		total_bend_angle = 0
		for element in conduit_run:
			print(element)

 

Labels (2)
2 REPLIES 2
Message 2 of 3
sstewartPHEFA
in reply to: aaronR7JP6

I haven't tried this myself, but I imagine the GetSubelements method would return all the items in the ConduitRun. From there you can filter through, find the bends, their angle parameter, and then add it all together.

Message 3 of 3
nobre_fs
in reply to: aaronR7JP6

I don't know if this is what you want, but here is an idea.

 

I've made two filters: the first one is to get every ConduitRun and the other is to get every ConduitFitting.

 

With the ConduitRun, a dict was created with each ConduitRun's Id as key and initializing with 0.

 

Then, for each ConduitFitting, get the associated ConduitRun. I did not find a direct way to get this. There are comments in the code to explain the process. Then, get the angle from the fitting and add it to the dict.

 

conduit_runs_list = FilteredElementCollector(doc).OfClass(Electrical.ConduitRun).WhereElementIsNotElementType().ToElements()  

conduit_runs_dict = {conduit_run.Id:0 for conduit_run in conduit_runs_list}  
  
conduit_fittings = FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_ConduitFitting).WhereElementIsNotElementType().ToElements()  
  
for conduit_fitting in conduit_fittings:  
    mep_model = conduit_fitting.MEPModel # MEPModel associated to the fitting  
    connector_manager = mep_model.ConnectorManager # ConnectorManager from the MEPModel  
    if connector_manager:  
        # From here, a conduit fitting has two connectors, one in each end  
        # first we get the connectors and then the connectors that it is connected to  
        # then we get the conduit that has the connector that the fitting is connected to  
        # finally, the ConduitRun for that conduit  
        connectors = list(connector_manager.Connectors) # All Connectors (ConnectorSet class) from this ConnectorManager  
        connector_refs = list(connectors[0].AllRefs) # All references of the connector, i.e. elements that is connected to  
        cond = connector_refs[0].Owner # Conduit which the fitting is connected to  
        cond_run_id = cond.RunId  # Id of the ConduitRun (it was used as key for the dict)

		angle = conduit_fitting.LookupParameter("Angle").AsDouble() # Supposing your fitting has a parameter named Angle  
        conduit_runs_dict[cond_run_id] += angle  

for v in conduit_runs_dict.values():  
    print(v)

 

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report