How to create the GetPipeByPartsize node in dynamo similar like node of GetPipeByName, i have also attached script from python but i am getting syntax error if anyone could help me to solve this issue

Load the Python Standard and DesignScript Libraries

import sys
import clr

Add Assemblies for AutoCAD and Civil3D

clr.AddReference(‘AcMgd’)
clr.AddReference(‘AcCoreMgd’)
clr.AddReference(‘AcDbMgd’)
clr.AddReference(‘AecBaseMgd’)
clr.AddReference(‘AecPropDataMgd’)
clr.AddReference(‘AeccDbMgd’)

Import references from AutoCAD

from Autodesk.AutoCAD.Runtime import *
from Autodesk.AutoCAD.ApplicationServices import *
from Autodesk.AutoCAD.EditorInput import *
from Autodesk.AutoCAD.DatabaseServices import *
from Autodesk.AutoCAD.Geometry import *

Import references from Civil3D

from Autodesk.Civil.ApplicationServices import *
from Autodesk.Civil.DatabaseServices import *

Inputs from Dynamo

doc = IN[0] # Document input
part_sizes = IN[1] # List of part sizes input

adoc = Application.DocumentManager.MdiActiveDocument
editor = adoc.Editor

def get_pipes_by_partsizes(doc, part_sizes):
db = doc.Database
pipes_by_size =

with db.TransactionManager.StartTransaction() as trans:
    pipes = CivilApplication.ActiveDocument.GetPipeNetworks()
    for network in pipes:
        for part in network.Parts:
            if isinstance(part, Pipe) and part.PartSize in part_sizes:
                pipes_by_size.append(part)
    trans.Commit()
return pipes_by_size

Get pipes by part sizes

pipes = get_pipes_by_partsizes(doc, part_sizes)

Output the results

OUT = pipes

A syntax error means there is a basic issue with the code.
If you could use the code format </> in the top menu or to do a large block of code - or - use three backticks on a line above and below.
If you append the code language name to the first backticks you get syntax highlighting

```python
block of code goes here
```

Looks like this :backhand_index_pointing_down:

# Load the Python Standard and DesignScript Libraries
import sys
import clr

# Add Assemblies for AutoCAD and Civil3D
clr.AddReference("AcMgd")
clr.AddReference("AcCoreMgd")
clr.AddReference("AcDbMgd")
clr.AddReference("AecBaseMgd")
clr.AddReference("AecPropDataMgd")
clr.AddReference("AeccDbMgd")

# Import references from AutoCAD
from Autodesk.AutoCAD.Runtime import *
from Autodesk.AutoCAD.ApplicationServices import *
from Autodesk.AutoCAD.EditorInput import *
from Autodesk.AutoCAD.DatabaseServices import *
from Autodesk.AutoCAD.Geometry import *

# Import references from Civil3D
from Autodesk.Civil.ApplicationServices import *
from Autodesk.Civil.DatabaseServices import *

# Inputs from Dynamo
doc = IN[0]  # Document input
part_sizes = IN[1]  # List of part sizes input

adoc = Application.DocumentManager.MdiActiveDocument
editor = adoc.Editor


def get_pipes_by_partsizes(doc, part_sizes):
    db = doc.Database
    pipes_by_size = []

    with db.TransactionManager.StartTransaction() as trans:
        pipes = CivilApplication.ActiveDocument.GetPipeNetworks()
        for network in pipes:
            for part in network.Parts:
                if isinstance(part, Pipe) and part.PartSize in part_sizes:
                    pipes_by_size.append(part)
        trans.Commit()
    return pipes_by_size


# Get pipes by part sizes
pipes = get_pipes_by_partsizes(doc, part_sizes)

# Output the results
OUT = pipes

I would also investigate using an IDE like Visual Studio Code or PyCharm to assist with writing and formatting as these have format checking

i am using this code in dynamo there still having issue as i want to create the node of getpipebypartsize

What error are you getting? It is difficult to help if we don’t know what is happening
Please review the following FAQ How to get help on the Dynamo forums

You can also consult the Civil3D API documentation [here] as there is no method CivilDocument.GetPipeNetworks()

Alternately use the OOTB nodes

As there is no node of GetPipefromPartSize in Autodesk & Camber Libraries, which filter the pipes as per part sizes list which we given as input similar like node GetPipefromName where we get the pipes as per list we given of names of pipe in the drawing, that’s why i am creating a new python code which gives output as pipes by providing input as part sizes in the drawing, the code when i am run in dynamo is not working as properly. I hope now my message is clear.

Not exactly sure if this is what you want, however this is how you can get the pipes that have a part size with standard C3D toolkit nodes.

Unless you are prepared to use the Civil 3D API documentation to assist with writing code and you put in some of your own effort, you will not be able to work effectively with python

Thanks @Mike.Buttery, i exactly want this dynamo pattern only.