Creating new pipe in Revit Python Shell

Creating new pipe in Revit Python Shell

Anonymous
Not applicable
1,688 Views
2 Replies
Message 1 of 3

Creating new pipe in Revit Python Shell

Anonymous
Not applicable

Hi,

I want to create a pipe system using Revit Python Shell. My code is:

from Autodesk.Revit.DB.Mechanical import *

a = XYZ(0,0,0)
b = XYZ(100,0,0)
levels = FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_Levels).WhereElementIsNotElementType().ToElements()
print(levels)
level = levels[1]
print(level)
system = Plumbing.PipeSystemType.DomesticColdWater.GetType
print(system)
pipetype = id(Plumbing.PipeType)
print(pipetype)
t = Transaction(doc, "pipe")
t.Start()
Plumbing.Pipe.Create(doc, id(system), Plumbing.PipeType.Id, level.Id, a, b)
t.Commit()

 

But when I run I am getting:

Exception : Microsoft.Scripting.ArgumentTypeException: expected ElementId, got int

Anyone help please to create a new element type (pipe type) and get its' id? How can I set a specific dimensions to the pipe I want to creating using script only? thank you!

0 Likes
Accepted solutions (1)
1,689 Views
2 Replies
Replies (2)
Message 2 of 3

MarryTookMyCoffe
Collaborator
Collaborator

usually it is nice to ready exception message.

Not doing it in phyton, but it look like you didn't get valid type.
you already use once FilteredElementCollector, use it to find rest thing you need to a method.

You don't create new pipingsystemtype or pipetype, you duplicate existing one and change it.

-------------------------------------------------------------
--------------------------------|\/\/|------------------------
do not worry it only gonna take Autodesk 5 years to fix bug
Message 3 of 3

jeremytammik
Autodesk
Autodesk
Accepted solution

Welcome to the Revit API!

 

Please note that this discussion forum is dedicated to programming Revit using the Revit API.

 

For RevitPythonShell specific question, you might be better off asking on StackOverflow, which supports a dedicated tag for that topic:

   

https://stackoverflow.com/questions/tagged/revitpythonshell

    

However, I would suggest that you first of all work through the basics of the Revit API using the standard getting started material:

    

https://thebuildingcoder.typepad.com/blog/about-the-author.html#2

    

That will make everything else much easier for you.

 

That said, here are a bunch of samples shared by The Building Coder on how to successfully use Pipe.Create:

 

https://www.google.com/search?q=pipe.create&as_sitesearch=thebuildingcoder.typepad.com

 

In your code, I wonder what the function call id(system) does.

 

Maybe you should be using system.Id instead?

 

That might explain your error message.

 



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder