Hi, nice to see you on my page. If you are looking for tools that will help you in the daily work of an architect, engineer or designer, you have come to the right place. Below are the latest entries. If you are looking for something specific, you can do so using the search engine or post categories. If you want to know more about me, please visit the "about me" tab. Have you used my solutions? You can return the favour by buy me a virtual coffee using the "Buy me a coffe" button
Hi, nice to see you on my page. If you are looking for tools that will help you in the daily work of an architect, engineer or designer, you have come to the right place. Below are the latest entries. If you are looking for something specific, you can do so using the search engine or post categories. If you want to know more about me, please visit the "about me" tab. Have you used my solutions? You can return the favour by buy me a virtual coffee using the "Buy me a coffe" button
The program for changing the type of pipes allows you to replace selected pipes and fittings with another type. When can you use it?
You transfer calculation results from other programs, but their pipes and fittings are incompatible with those used by you
You have to change many types of pipes at one time
How program works
First, the program will ask you to select all the pipe elements that you want to change, and after selecting, confirm with the “finish” button.
In the second step, we have to choose the type of pipes we want to change our installations to.
After selecting the type, the elements in the model will be replaced. When the program is finished, you can close the results window.
Film with program in action
Source code – revit pipes type change
Below is the program code from the first version of the overlay. For more please visit mine GitHub, where new versions of the overlay will appear on a regular basis.
Python
Copyright(C)2022 Paweł Kińczyk## Importsfrom Autodesk.Revit.UI.Selection import*from Autodesk.Revit.DB import*from pyrevit import formsfrom rpw import revit# Get revit modeldoc = revit.docuidoc = revit.uidoc# Class and defclassCustomISelectionFilter(ISelectionFilter):def__init__(self,nom_categorie):self.nom_categorie = nom_categoriedefAllowElement(self,e):if e.Category.Name inself.nom_categorie:# if self.nom_categorie.Contains(e.Category.Name):# if e.Category.Name == self.nom_categorie:returnTrueelse:returnFalsedefAllowReference(self,ref,point):returnTruedefget_dict_of_elements(build_in_category): elements =FilteredElementCollector(doc).OfCategory( build_in_category).WhereElementIsElementType().ToElements()return{Element.Name.GetValue(e): e for e in elements}# Picking elementswith forms.WarningBar(title="Pick elements in model[pipes/pipe fittings]"): collector = uidoc.Selection.PickObjects( ObjectType.Element,CustomISelectionFilter("Pipes Pipe Fittings"))# Get pipe typespipe_types_dict =get_dict_of_elements(BuiltInCategory.OST_PipeCurves)# Chose pipe type you want to changepipe_type_name = forms.CommandSwitchWindow.show(pipe_types_dict.keys(),message='Select pipe type',recognize_access_key=False)# Get routing preferenceif pipe_type_name ==None: forms.alert("You didn't pick any pipe type",exitscript=True)raiseException("You didn't pick any pipe type")pipe_type = pipe_types_dict[pipe_type_name]rpm = pipe_type.RoutingPreferenceManagerrc =RoutingConditions(RoutingPreferenceErrorLevel.None)# Clear unuse elementsdel pipe_types_dict# Sort elements pipe fittings/pipescollector_fittings =[]collector_pipes =[]for element in collector: element_category = doc.GetElement( element).LookupParameter("Category").AsValueString()if element_category =="Pipes": collector_pipes.append(element)else: collector_fittings.append(element)# Clear unuse elementsdel collectortransaction =Transaction(doc,'Batch change pipe - PYLAB')transaction.Start()# for loop through picked elementsfor element in collector_pipes:try:print('it is a Pipe') element = doc.GetElement(element) element.ChangeTypeId(pipe_type.Id)exceptExceptionas e:print("Pipe error")print(e)for element in collector_fittings: refs =[]try: element = doc.GetElement(element) fitting = element element = element.MEPModel# Get info about connected elements connectors = element.ConnectorManager.Connectors size_fit =float(0)for c in connectors:for r in c.AllRefs: c_size =float(r.Owner.LookupParameter("Size").AsString()[0:3])print(c_size)if size_fit <= c_size: size_fit = c_size rc.AppendCondition(RoutingCondition(size_fit)) pipe_fitting = element.PartType# Get routing preference MEPPartIdif pipe_fitting == PartType.Elbow:print('it is an Elbow') new_fitting_id = rpm.GetMEPPartId( RoutingPreferenceRuleGroupType.Elbows, rc) part_fitting_id = rpm.GetRule( RoutingPreferenceRuleGroupType.Elbows,0) part_fitting_id = part_fitting_id.MEPPartIdelif pipe_fitting == PartType.Tee:print('it is a Tee') new_fitting_id = rpm.GetMEPPartId( RoutingPreferenceRuleGroupType.Junctions, rc)elif pipe_fitting == PartType.Cross:print('it is a Cross') new_fitting_id = rpm.GetMEPPartId( RoutingPreferenceRuleGroupType.Crosses, rc)elif pipe_fitting == PartType.Transition:print('it is a Transition') new_fitting_id = rpm.GetMEPPartId( RoutingPreferenceRuleGroupType.Transitions, rc)else: new_fitting_id =Noneprint('current fitting id: {}'.format(fitting.GetTypeId()))if(new_fitting_idand fitting.Id != new_fitting_idand new_fitting_id.IntegerValue !=-1): fitting.ChangeTypeId(new_fitting_id)exceptExceptionas e:print("Fitting error")print(e)transaction.Commit()
Please report any irregularities in the operation of the program that occur during use on my social accounts or account GitHub.b.