How can I create a Pressure Network?

Hello,

I’m trying to create a new Pressure network in my file. But when I do this in a python script, it creates a Pressure Network Id but it doesn’t appear in ToolSpace. In my code I checked the database of the file if there really was any network and the Id of the network I created appeared.

I tried to create a Pressure Pipe in this Network, but I have the same problem, it creates a Pressure Pipe Id, but my pipe doesn’t appear in the model.

Someone knows how can I correct this?

# 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 - Create a new Pressure Pipe Network:
            NewNet = ACD.PressurePipeNetwork.Create(db,IN[0])

            #2 - Read from database all Pressure Networks ids:
            PressureNetwork_Ids = ACAC.GetPressurePipeNetworkIds(AD)            

# Assign your output to the OUT variable.
OUT = NewNet,PressureNetwork_Ids

hi
I think first you should get this PressurePartListCollection Members
PressurePartListCollection Members
and
PressurePartList Members

I was trying it and couldn’t get a result

Have you tried to get it

1 Like

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)
1 Like

good job
Thanks for sharing the code Tomorrow

I will try it can i get a result?

1 Like

You must already have a catalog and partlist on file. I filtered by name (ex. “R22”) and was able to access the tubes and fittings.


1 Like

Did you try to add another line?
Code
t.Commit()

1 Like

OMG! Worked!!! Thanks!!

2 Likes

good job

We wish you good luck
Thanks

@hosneyalaa @andre.demski FYI there are some nodes in Camber to create and work with Pressure Networks.

CreatePressureNetwork

2 Likes

Dear demski,

it is a great example for create the pressure network, but the problem is how we can add the pressure fitting to the network, do you have any example for that and i will be gratefully.