Get Pipe Networks from ProfileView

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 :slight_smile:

# 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


#####################################################
#####################################################

3 Likes