Hi,
Do we have any nodes to get pipe networks and its pipes from profileview?
Do we have any nodes for this in Civil3d toolkit?
Try the below Python code and let me know if you have any issues. It will allow you to select parts from a profile view and return there model equivalent. You can then pass these into the nodes in the toolkit for much more info (such as network)
# 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')
clr.AddReference('Civil3DNodes')
clr.AddReference('AutoCADNodes')
# 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 *
#Import References from dynamo
from Autodesk.AutoCAD.DynamoNodes import SelectionByQuery
#####################################################
#####################################################
# The inputs to this node will be stored as a list in the IN variables (global variables).
adoc = Application.DocumentManager.MdiActiveDocument
editor = adoc.Editor
output = []
hndl = []
def select_objects():
SelectedObjects = []
with adoc.LockDocument():
with adoc.Database as db:
with db.TransactionManager.StartTransaction() as t:
acSSPrompt = editor.GetSelection()
if acSSPrompt.Status == PromptStatus.OK:
acSSet = acSSPrompt.Value
for s in acSSet:
if s:
obj = t.GetObject(s.ObjectId, OpenMode.ForRead)
SelectedObjects.append(str(obj.Handle))
t.Commit()
return SelectedObjects
UserSelection = select_objects()
def GetPartsFromProfiles(SelectedProfilePart):
with adoc.LockDocument():
with adoc.Database as db:
with db.TransactionManager.StartTransaction() as t:
bt = t.GetObject(db.BlockTableId, OpenMode.ForWrite)
btr = t.GetObject(bt[BlockTableRecord.ModelSpace], OpenMode.ForWrite)
#Convert the profile part object handle string to base 16 integer
ProfPartHandle = int(SelectedProfilePart, 16)
#Get the handle of each profile part
handle = Handle(ProfPartHandle)
#get the object id of each profile part
ProfilePartID = db.GetObjectId(False, handle, 0)
#Opens the profile part object for read
ProfilePartObject = t.GetObject(ProfilePartID, OpenMode.ForRead)
#Get the model part ID from the profile part
ModelPartID = ProfilePartObject.ModelPartId
#Get the Network Name of the model part
NameOfNetwork = ModelPartID.NetworkName
Part = t.GetObject(ModelPartID, OpenMode.ForWrite)
hndl.append(str(Part.Handle))
t.Commit()
for h in hndl:
output.append(SelectionByQuery.GetObjectByObjectHandle(h))
return output
pass
return
i = 0
DynamoProfileView = IN[0]
sizeofList = len(UserSelection)
while i < sizeofList :
OUT = GetPartsFromProfiles(UserSelection[i])
i += 1
pass
#####################################################
#####################################################
Thanks for sharing the code. I’m getting exception "AttributeError: ‘ProfileView’ has no attribute ‘ModelPartId’.
Could you please drop here your dyn file?
You need to select the part(s) displaying in the profile - not the profile view itself
It works but this is not what I am after. I was aware of this select multiple objects and get SelectionByQuery. I’m looking to get directly from profile view without selecting objects.
Apologies - the below Python script will alow you to select a profile and return a list of it’s parts. Hopefully this is what your looking for
# 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')
clr.AddReference('Civil3DNodes')
clr.AddReference('AutoCADNodes')
# 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 *
#Import References from dynamo
from Autodesk.AutoCAD.DynamoNodes import SelectionByQuery
#####################################################
#####################################################
# The inputs to this node will be stored as a list in the IN variables (global variables).
adoc = Application.DocumentManager.MdiActiveDocument
editor = adoc.Editor
output = []
hndl = []
SelectedObjects = []
def select_objects():
with adoc.LockDocument():
with adoc.Database as db:
with db.TransactionManager.StartTransaction() as t:
acSSPrompt = editor.GetSelection()
if acSSPrompt.Status == PromptStatus.OK:
acSSet = acSSPrompt.Value
for s in acSSet:
if s:
obj = t.GetObject(s.ObjectId, OpenMode.ForRead)
SelectedObjects.append(str(obj.Handle))
t.Commit()
return SelectedObjects
UserSelection = select_objects()
def GetPartsFromProfiles(SelectedProfileView):
with adoc.LockDocument():
with adoc.Database as db:
with db.TransactionManager.StartTransaction() as t:
bt = t.GetObject(db.BlockTableId, OpenMode.ForWrite)
btr = t.GetObject(bt[BlockTableRecord.ModelSpace], OpenMode.ForWrite)
#Convert the profile view handle string to base 16 integer
ProfViewHandle = int(SelectedProfileView, 16)
#Get the handle of each profile view
handle = Handle(ProfViewHandle)
#get the object id of each profile view
ProfileViewID = db.GetObjectId(False, handle, 0)
#Opens the profile object for read
ProfileViewObject = t.GetObject(ProfileViewID, OpenMode.ForRead)
#Get Pipe Overrides collection for the profile object
PipeOvers = ProfileViewObject.PipeOverrides
#For each pipe overide in the pipe overrides collection - get the pipe name
for p in PipeOvers:
output.append(p.PipeName)
t.Commit()
return output
pass
return
i = 0
DynamoProfileView = IN[0]
sizeofList = len(UserSelection)
while i < sizeofList :
OUT = GetPartsFromProfiles(UserSelection[i])
i += 1
pass
#####################################################
#####################################################
Many thanks for this but unfortunately it doesn’t work for pressure pipes. I get EmpyList
. Do you have any workaround to work with pressure pipes? I really appreciate your help.
Hello @elliotgr2010 ,how can I get the bands from that profile view?