Hi,
I want to access pressure network related data in civil 3D using dynamo.
I’m looking for a solution where I can get data of pressure pipes, fittings and appurtenances used in a document.
Thanks in advance!
In the Civil 3D Toolkit there are hidden nodes to handle pressure pipes, the only thing is that you cannot do is creating a pressure pipe network.
You can access them through Python at the moment.
Hi Paolo, is there any example how to work with Python to access pressure pipe networks data?
@Drbohlav this is a good starting point although it is not in Python https://adndevblog.typepad.com/infrastructure/2013/06/autocad-civil-3d-and-pressure-pipe-net-api-part-i.html
Hi all, Is here someone who can share any example for Python? At the moment for example for properties as 2D length, 3D length, Grade(Slope). Or is it not possible even with Python with the current API? Sorry I am not programmer so I can tweak only some prepared script at the moment.
It is possible with Python, It’s on my todo list to open these on Civil 3D Toolkit as well, just I don’t have a lot of bandwidth at the moment.
I have done it. Thanks @Paolo_Emilio_Serra1 for the hints here.
Another question is if it is possible by Python to access pressure pipes property sets and update them.
I can’t manage it by standard selection node (Object Types), because I can’t select pressure pipes.
Well done! so you can combine the Python examples that are shipped with Dynamo on Property Sets and you can still use Python to do the selection.
@Paolo_Emilio_Serra1 I exported CSV and used your AutoCAD_Python_PSet_UpdatePropertySetValuesByCSV.dyn to add properties to pset.
Next step is for me to do it without CSV file, but on the other hand I am not sure if it is save without tabular CSV visual inspection.
@Drbohlav @Paolo_Emilio_Serra1 I believe I got a quick solution. I quickly edited the python scripts that came with Civil 3D. Will try tidying it up even more later. At least it will give you an idea of how to avoid exporting to excel. Note that it requires you to list the parameters you would like to update in a code block.
# Load the Python Standard and DesignScript Libraries
import sys
import clr
import os
import csv
import json
sys.path.append(r'C:\Program Files\IronPython 2.7\Lib')
# 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 *
# Add Assemblies for AutoCAD and Civil 3D APIs
clr.AddReference('acmgd')
clr.AddReference('acdbmgd')
clr.AddReference('accoremgd')
clr.AddReference('AeccPressurePipesMgd')
clr.AddReference('acdbmgdbrep')
clr.AddReference('System.Windows.Forms')
# 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
# Create an alias to the Autodesk.AutoCAD.ApplicationServices.Application class
import Autodesk.AutoCAD.ApplicationServices.Application as acapp
# Import references for PropertySets
from Autodesk.Aec.PropertyData import *
from Autodesk.Aec.PropertyData.DatabaseServices import *
adoc = Application.DocumentManager.MdiActiveDocument
editor = adoc.Editor
obj_handles = IN[1]
pset_name = IN[0]
para_values = IN[2]
para_names = IN[3]
def loin_pset_test(name):
"""Selects an object by handle and assigns the specified property set values.
XXXXXX
name: the name of the property set.
"""
global adoc
global ed
db = adoc.Database
with adoc.LockDocument():
with adoc.Database as db:
####################################################
dpsd = DictionaryPropertySetDefinitions(db)
psdef = None
# Check if the property set exists
try:
psdef = dpsd.GetAt(name)
except Exception as ex:
MessageBox.Show('Property Set\r\n{}'.format(ex.message))
if psdef is None:
return # Fails gracefully with no property set with that name
# Safely manage the Database
####################################################
with db.TransactionManager.StartTransaction() as t:
# Place your code below
for idx, val in enumerate(obj_handles[0]):
# Get an object by handle
hndl = None
try:
hndl = Handle(Convert.ToInt64(val, 16))
except Exception as ex:
MessageBox.Show('Handle\n{}\n{}'.format(val, ex.message))
return
id = None
try:
id = db.GetObjectId(False, hndl, 0)
except Exception as ex:
MessageBox.Show('{}'.format(ex.message))
if id is None:
continue
obj = t.GetObject(id, OpenMode.ForWrite)
# Check if the object has the psdef associated
obj_ps = None
try:
PropertyDataServices.AddPropertySet(obj, psdef.ObjectId)
except Exception as ex:
MessageBox.Show('Assign Property Set\r\n{0}\r\n{1}'.format(hndl, ex.message))
return
for psid in PropertyDataServices.GetPropertySets(obj):
obj_ps = t.GetObject(psid, OpenMode.ForWrite)
if obj_ps.PropertySetDefinition == psdef.ObjectId:
break
# Assign the values to the properties
for i, parameter in enumerate(para_names):
try:
pid = obj_ps.PropertyNameToId(parameter)
prop = [p for p in obj_ps.PropertySetData if p.Id == pid]
if len(prop) > 0:
prop = prop[0]
else:
continue
value = para_values[i][0][idx]
if prop.DataType == DataType.Real:
value = float(value)
elif prop.DataType == DataType.Integer:
value = int(value)
elif prop.DataType == DataType.TrueFalse:
value = bool(value)
elif prop.DataType == DataType.Text:
value = str(value)
elif prop.DataType == DataType.AlphaIncrement:
pass
elif prop.DataType == DataType.AutoIncrement:
pass
elif prop.DataType == DataType.Graphic:
pass
elif prop.DataType == DataType.List:
pass
else:
pass
obj_ps.SetAt(pid, value)
except Exception as ex:
MessageBox.Show('Assign Property Value\r\n{0}\n{1}'.format(hndl, value))
continue
# Commit before end transaction
t.Commit()
pass
loin_pset_test(pset_name)
OUT = True
Hi,
Can someone help me with this error? I have the whole pressure network modelled but the node can’t seem to read it
Hi @richarddean.barcelo, can you send small example of your pressure pipe network in dwg?
Hi @Drbohlav,
Thanks for accomodating. Attached is the sample .dwg. Civil3DToolkit v1.1.14 installed.Test_PressureNetwork.dwg (978.3 KB)
guys, please, please, please, don’t ask for the dataset without asking for the Civil 3D Toolkit log file, don’t reach out for help without the log file. If you don’t know what it is or where it is read the Civil 3D Toolkit Feedback Thread Civil 3D Toolkit Feedback thread
And for the record I cannot reproduce, update your Civil 3D to the latest verison
Apologies, will do. I quickly asked for help as a matter of urgency, and never read any rules here in the forum, sorry.
Hi Paolo, thank you for your respose. Of course I would like to help in effective way. Next time with log file
Hi @richarddean.barcelo, here is my Dynamo script. It works on your dataset. I have the latest version of Civil 3D.
D4C3D_20201202_TK_PressurePipes_v1.0.1.dyn (94.4 KB)Hi @Drbohlav/@Paolo_Emilio_Serra1,
Many thanks for the help. I’ve just got the latest update a few minutes ago and tested, I confirm the issue is not using the latest version 2020.5.1.
Now it’s working.
Thanks,
Dear paolo…
I searched for the Civil3d toolkit logfile in your link and can’t figure it out…I have the same problem with"GetPipesFttings" node
Update Civil 3D