How can I create a Pressure Network?

I’ve already managed to create a pressure pipe, I already know how to read and see the part lists. But even creating, it doesn’t appear in my file.

# Load the Python Standard and DesignScript Libraries
import sys #sys is a fundamental Python library - here, we're using it to load in the standard IronPython libraries
import clr #This is .NET's Common Language Runtime. It's an execution environment that is able to execute code from several different languages.
import os
import math

# Add Assemblies for AutoCAD and Civil 3D APIs
clr.AddReference('AcMgd')
clr.AddReference('AcCoreMgd')
clr.AddReference('AcDbMgd')
clr.AddReference('AecBaseMgd')
clr.AddReference('AecPropDataMgd')
clr.AddReference('AeccDbMgd')
clr.AddReference('ProtoGeometry') #A Dynamo library for its proxy geometry
#classes. You'll only need this if you're interacting with geometry
clr.AddReference('AeccPressurePipesMgd')
clr.AddReference('System.Windows.Forms')
clr.AddReference('acdbmgdbrep')
clr.AddReference('Civil3DNodes')
clr.AddReference('AutoCADNodes')

# Add references to manage arrays, collections and interact with the user
from System import *
from System.IO import *
from System.Collections.Specialized import *
from System.Windows.Forms import MessageBox

import Autodesk #Loads the Autodesk namespace
# Import references from AutoCAD
AAR = Autodesk.AutoCAD.Runtime
AAA = Autodesk.AutoCAD.ApplicationServices #Setting a handle to the currently-open instance of the AutoCAD application
AAD = Autodesk.AutoCAD.DatabaseServices
AAE = Autodesk.AutoCAD.EditorInput
AAG = Autodesk.AutoCAD.Geometry
AADy = Autodesk.AutoCAD.DynamoNodes

AUX = Autodesk.Aec.DatabaseServices

OP = AAD.OpenMode
TS = AAD.Transaction

# Import references from Civil3D
ACA = Autodesk.Civil.ApplicationServices #Setting a handle to the currently-open instance of the Civil3D application
ACD = Autodesk.Civil.DatabaseServices
ACDy = Autodesk.Civil.DynamoNodes

AD = ACA.CivilApplication.ActiveDocument #Finally, setting up handles to the active Civil3D document
ACAC = Autodesk.Civil.ApplicationServices.CivilDocumentPressurePipesExtension
adoc = AAA.Application.DocumentManager.MdiActiveDocument
editor = adoc.Editor

with adoc.LockDocument():
    with adoc.Database as db:

        with db.TransactionManager.StartTransaction() as t:
            # E vem ai
            
            #1 - Coletar e pega a PartList escolhida para a pressure pipes (Collect and get the partlist choose to pressure pipe):
                        
            PartList_Collection = ACD.Styles.PressurePartList.GetAvailablePartLists(db) 
            PartList_Selected = []
            for id in PartList_Collection:
                PartList = TS.GetObject(t,id,OP.ForRead)
                PartList_Description = PartList.Description
                if PartList_Description.Contains(IN[0]) is True:
                    PartList_Selected = PartList
            
            #2 - Ler o catálogo (Read the catalog):
            
            PipeType = ACD.PressurePartDomainType.Pipe
            FittingsType = ACD.PressurePartDomainType.Fitting
            PipeSize = PartList_Selected.GetParts(PipeType) 
            PipeSize_Name = []
            FittingsSize = PartList_Selected.GetParts(FittingsType)
            FittingsSize_Name = []
            for i in PipeSize:
                PipeSize_Name.append(i.Description)
                
            for i in FittingsSize: 
                FittingsSize_Name.append(i.Description)
                
            #3 - Criar Pressure Network pelo nome (Create Pressure Network by name):
            NewNet = ACD.PressurePipeNetwork.Create(db,IN[1])
            Net = TS.GetObject(t,NewNet,OP.ForWrite)
            Net.UpgradeOpen()
            
            Ponto1 = AAG.Point3d(279867.7154,9114672.9238,0)
            Ponto2 = AAG.Point3d(279785.0385,9114495.0680,0)
            Linha = AAG.LineSegment3d(Ponto1,Ponto2)
            
            #Create Pressure Pipe by Line and PipePartSize
            TuboTeste = Net.AddLinePipe(Linha,PipeSize[0])
            Pipe = TS.GetObject(t,TuboTeste,OP.ForWrite)
            
# Assign your output to the OUT variable.
OUT = dir(Net)
2 Likes