Create pipe in Revit from two points problem

Hi guys.

I learned the basic stuff about: Grasshopper, Revit, Rhino.Inside.Revit, Rhino, General Python, GHPython and IronPython and completed some courses from McNeel education. I am working in Revit 2023 and Rhino 8 (WIP).

I jumped straight into GHpython scripting trying to create a pipe in revit from two points created in rhino and couldn’t find any good examples to learn from (plumbing/ MEP examples) so I am stuck. The examples are only written in C#, Visal Basic or Visual C++. I have just started with python coding and there is so much information to handle and read and that makes it hard when I am not knowing where to start. There are so many libraries to import and all of these confuses me what they really do and I really struggling to get all the pieces together where they belong.

What I have done by now:
I’ve downloaded and installed Revit 2023.
I’ve downloaded and installed Rhino.Inside.Revit
I’ve downloaded and installed Revit LookUp.
I’ve downloaded and installed Rhino 8 (WIP)
I’ve understand I need a transaction, think I know how to do this.

I’ve been searching around in revitapidocs.com and found this class I want to use (Creates a new pipe from two points):
https://www.revitapidocs.com/2023/9550265f-5760-3c28-d023-d0373285855b.htm

I’ve tried to translate the information found in revitapidocs.com to GHPython in several ways, but can’t get it to work with GHPython.

Anyone out there who can give me and example written in GHpython that works and explain with easy comments what to do for the create pipe class and get the pipe drawed inside revit?

I really want to learn this but I need some guidance in the start where to look and where to start, please keep it as simple as you can get it. I need a basic easy explained recipe for the whole process.

When I’ve learned the basics the plan is to expand the code from there.

I really appreciate all the help I can get here.

Hi Joachim,

Please use Rhino 7 for Rhino.Inside.Revit at this time.

I’ll put together a simple example of creating a pipe in python for you.

Hey @Joachim_S ,

Since Japhy will create a python sample for creating a pipe… here is my version for creating a Flex Pipe through points, tried to make the code a bit descriptive as far as my knowledge goes :sweat_smile:

If you need any more elaboration on it let me know, also the link Japhy sent is mainly your starting point for python components using RiR, and I would suggest going through their website/forum and check for the user created components written in Python, go through them and understand how they are created.

Good luck and feel free to ask :smiley:

FlexpPipe

FlexPipe_FromPoints.gh (25.3 KB)

1 Like

Joachim S,

Here’s a simple example. If you are looking to get deeper into Revit API i would recommend Ehsan’s pyrevit courses.

RE_Pipe_2Pts.gh (11.7 KB)

2 Likes

Wow, thank you so much Japhy and Mohamed. :grinning: I will have a look at the .gh files and links I got from you.

Did you maybe figure out how to active the fitting for the pipes?
Here is the example for what I want to do:

I have done some research and found out that I need to active the fitting action with this line of code:
I added -
from Autodesk.Revit import UI

UI.RevitCommandId.LookupPostableCommandId(UI.PostableCommand.PipeFitting)

Link to source: ApiDocs.co

Python doesn’t show up any error nor solution. I wonder what do I need to do to make this work. As shown is the video, I just click and release the pipe and it triggers the fitting.

I have also seen this from another thread:

He tried to figure it out but with no success. Is there a way for help with this?