Creating new Piping/Duct system

Hi everyone.

Tying to create a new piping system with Dynamo from excel.
I have list of piping system and i want to create new piping system from each item in the list and set “system abbreviation” and set a materiel".

any idea? any help? any API ?
no google solution was found :frowning:

Amir

I think you can create system once you have elements in your model.
I couldn’t fully understand what you are trying to achieve?
Piping/Mechanical system will be assigned to Elements. Without elements you can’t create a system (As far as I know)

@jalshu thnak you for replay

i will try to make it clear .
i have a very big list of systems and i want to create for all of thoes items new “Piping system” and then when i will model a new pipe I will chose one of thoes systems.
i dont want to do it one by one by clicking duplicate-> rename the piping system etc.

hope now its more clear.
Amir

1 Like

I think this will help.
But first you need to create pipe for each “System Classification”

Element.SystemType is from MEPover package
FamilyType.Duplicate is from Clockwork package


Ah… you meant systemtype. sorry I misunderstood that.

I assume that you can bring excel data to dynamo by your own and I wrote a short script to create pipe system and assign abbreviation.

clr.AddReference("RevitAPI")
import Autodesk
from Autodesk.Revit.DB import *
clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
doc = DocumentManager.Instance.CurrentDBDocument
TransactionManager.Instance.EnsureInTransaction(doc)

pipe=Plumbing.PipingSystemType.Create(doc,MEPSystemClassification.OtherPipe,"My Test Pipe")
Abr=pipe.LookupParameter("Abbreviation")
Abr.Set("Jalshu")
Mtr=pipe.LookupParameter("Material")
Mtr.Set("steel")

        

TransactionManager.Instance.TransactionTaskDone()
OUT= pipe

image

1 Like

@jalshu @yamanyildirim thank you so much for both of you!

ill start with @jalshu becasue its seems to be much easy.
do you have any idea why the material doesnt change to “steel” ? maybe steel is not on your material list?

Mtr=pipe.Parameters
for i in Mtr:
   if i.Definition.Name== "Material":
       
        i.Definition == "Steel"

replace material code with this and try.

@jalshu

unfortunatly the material issue doesnt work.
do you have any other idea?

It worked perfectly for me. Can you share a snip of your system type property? and is the material you are trying to set is already in your material library?

@jalshu

yea

change:
i.Definition == “Poche”
to:
i.Definition = “Poche”

the first one is testing if it equals poche, so if you printed that it would return False.

.set(“Poche”) should work

you may have to get the elementId of the material, then use that to set it

I would also stay away from lookupparameter and use the BuiltInParameter instead

@Tom_James Thanks for the tip Tom,I haven’t done set material via API before. I thought it would similar to setting other parameters. but it seems like it takes only MaterialId as a input not a material name as a string. To set material by its name we need to search for materialId first and then assign it here. Right?

Hi @Tom_James and @jalshu i try your segestion but unfortunatly its doesnt work

Mtr=pipe.Parameters
for i in Mtr:
if i.Definition.Name== “Material”:
i.Definition = 26

and the other one

Mtr=pipe.LookupParameter(“Material”)
Mtr.Set(26)

i cheack it and 26 is one of the material id in my project

Hi @jalshu and @Tom_James , do you have any idea?

Hi Amir & Jal, sorry to leave you hanging, i’ll get back to you later today i’m swamped.

1 Like

As per my understanding, It has to be Element not Integer, when you get “Element.Id” you get Integer value not element. That’s why my next suggestion would be, Search material name by string and get matching material by Boolean mask and then assign it to your pipe system.

@amir.aroesti
@jalshu

Hi both, sorry for the late reply.

The easiest way to find the parameter storage type / what parameter to set would be to use the Revit Lookup addin:

We can see that the material of a system type has a built in parameter name of MATERIAL_ID_PARAM, and the storage type is ElementId.

We can get this by, modifying what Jal has done above:

BIP = BuiltInParameter.MATERIAL_ID_PARAM
Mtr=pipe.get_Parameter(BIP)

All we need to do then is get the material, filtered element collector would be the easiest way programmatically, get the Id of the material, then set the parameter using:

pipeMat = the id of the material you want to set
Mtr.Set(pipeMat)

@Tom_James
Thank you very much for your help and sorry about to the delay its due to different time zone and to much out of the ofice meeting :pensive:

first : i got the Lookup app and its amazing, it going to help us a lot!

As you can see, me screen shows diiferent value and Im confuse .
when I chose one of my "pipe system " i got a different paramter of material and im not relly shure what code line i have to change.

Lets say that until the material lines everything works fine

Enable Python support and load DesignScript library

import clr
clr.AddReference(‘ProtoGeometry’)
from Autodesk.DesignScript.Geometry import *

The inputs to this node will be stored as a list in the IN variables.

dataEnteringNode = IN

Place your code below this line

Assign your output to the OUT variable.

clr.AddReference("RevitAPI")
import Autodesk
from Autodesk.Revit.DB import *
clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
doc = DocumentManager.Instance.CurrentDBDocument
TransactionManager.Instance.EnsureInTransaction(doc)

pipe=Plumbing.PipingSystemType.Create(doc,MEPSystemClassification.OtherPipe,"My Test Pipe")
Abr=pipe.LookupParameter("Abbreviation")
Abr.Set("Jalshu")
Mtr=pipe.LookupParameter("Material")
Mtr.Set(Material Tid - Test 914840)
OUT= 0

Read my post above, you need to replace LookupParameter with get_Parameter(BIP).
Also, the elementid is 914840 in your case, the left image is showing a description and the Id, don’t use this. I think you need to do some background reading, have a look at the dynamo primer.

import clr
clr.AddReference("RevitAPI")
import Autodesk
from Autodesk.Revit.DB import *
clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

doc = DocumentManager.Instance.CurrentDBDocument
TransactionManager.Instance.EnsureInTransaction(doc)

pipe = Plumbing.PipingSystemType.Create(doc,MEPSystemClassification.OtherPipe,"My Test Pipe")

BIP = BuiltInParameter.MATERIAL_ID_PARAM
Mtr = pipe.get_Parameter(BIP)

matFilter = FilteredElementCollector(doc).OfClass(Material).ToElements()
pipeMat = [m.Id for m in matFilter if m.Name == "Copper"][0]

Mtr.Set(pipeMat)

TransactionManager.Instance.TransactionTaskDone()

OUT= pipe
1 Like