Civil 3D 2026.2
PartSize is not being updated
Pressure Pipes are at same XY locations as Pipes. In the specific example task the gravity Pipe outside diameter must be applied to the Pressure Pipe that has the same XY location.
import clr
clr.AddReference('AcMgd')
clr.AddReference('AcDbMgd')
clr.AddReference('AeccDbMgd')
clr.AddReference('AeccPressurePipesMgd')
from Autodesk.AutoCAD.ApplicationServices import Application
from Autodesk.AutoCAD.DatabaseServices import *
from Autodesk.AutoCAD.EditorInput import *
from Autodesk.Civil.ApplicationServices import CivilApplication
from Autodesk.Civil.DatabaseServices import *
from Autodesk.Civil.ApplicationServices import CivilDocumentPressurePipesExtension
from Autodesk.Civil.DatabaseServices import PressurePartDomainType, PressurePartContextType
data = IN[0]
networkName = IN[1]
doc = Application.DocumentManager.MdiActiveDocument
db = doc.Database
civDoc = CivilApplication.ActiveDocument
result = []
elog = []
doc.LockDocument()
for i in data:
NewDiameter = i[2] * 1000.0
with db.TransactionManager.StartTransaction() as trans:
try:
networkId = None
for nid in CivilDocumentPressurePipesExtension.GetPressurePipeNetworkIds(civDoc):
net = trans.GetObject(nid, OpenMode.ForRead)
if net.Name == networkName:
networkId = nid
break
if networkId is None:
result.append("network not accessed")
continue
ppn = trans.GetObject(networkId, OpenMode.ForWrite)
partListId = ppn.PartsListId
partList = trans.GetObject(partListId, OpenMode.ForRead)
selectedSize = None
selectedPart = None
parts = partList.GetParts(PressurePartDomainType.Pipe)
for part in parts:
partOuterDia = part.GetProperty(PressurePartContextType.PipeDiameterOutside)
if abs(partOuterDia - NewDiameter) < 20.0:
selectedPart = part
break
if selectedPart is None:
result.append("part size not matched ... " + str(NewDiameter))
continue
result.append("matched")
p = trans.GetObject(i[4].InternalObjectId, OpenMode.ForWrite)
p.PartSize = selectedPart
ppn.Rebuild()
trans.Commit()
except Exception as ex:
elog.append(ex)
OUT = [result,elog]
Thanks for helping,
K.
has-runs.dwg (3.2 MB)
update-water-size.dyn (18.8 KB)
