Civil 3D Draw Multiple Pipes In Profile View From Selection

@hosneyalaa

Thank you for posting the update. I think this is getting closer to the graph that I was hoping to be able to use. I have included a graph where I added notes to help explain what I would like to accomplish and hopefully this is something that can be done.

  1. User selects pipes and/or pressure pipes to add to profile view
  2. User selects profile view to add selected pipes and/or pressure pipes to
  3. The dynamo graph filters the entire lists of pipes and pressure pipes in the current document based on the user selection of pipes and/or pressure pipes
  4. A combined filtered list of pipes and/or pressure pipes is created
  5. Python script adds pipes and/or pressure pipes to profile view.

Since we have a language barrier, I am going to include @mzjensen on this discussion and see if he has some availability to take a look.

JJH_PipeNetwork_InvertToPolylines +PYTHON+f.dyn (63.5 KB)

This is looking pretty cool!

1 Like

JJH_PipeNetwork_InvertToPolylines +PYTHON+f.dyn (53.7 KB)

I have learned how to work with a couple of new nodes since your last reply. Please take a look at the attached graph and see if it can work with your python script. The idea is:

  1. Select Profile View with “Select Objects” node
  2. Select Pipes and Pressure Pipes with second “Select Objects” node
  3. Python script uses these selections as inputs and adds to profile view

JJH_FilterPipes&PressurePipes_rev0.dyn (12.7 KB)

JJH_FilterPipes&PressurePipes.dyn (19.4 KB)

Here is an updated version of your original python script that I think is very close to working how we would like it to. There seem to be just a couple of issues with the script, but it is close.

a

import sys
import clr

# Add Assemblies for AutoCAD and Civil 3D APIs
clr.AddReference('acmgd')
clr.AddReference('acdbmgd')
clr.AddReference('accoremgd')
clr.AddReference('AecBaseMgd')
clr.AddReference('AecPropDataMgd')
clr.AddReference('AeccDbMgd')
clr.AddReference('AeccPressurePipesMgd')
clr.AddReference('acdbmgdbrep')
clr.AddReference('System.Windows.Forms')
clr.AddReference('Civil3DNodes')

# Create an alias to the Autodesk.AutoCAD.ApplicationServices.Application class
import Autodesk.AutoCAD.ApplicationServices.Application as acapp

# 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 for Civil 3D
from Autodesk.Civil.ApplicationServices import *
from Autodesk.Civil.DatabaseServices import *

adoc = acapp.DocumentManager.MdiActiveDocument
ed = adoc.Editor
civdoc = CivilApplication.ActiveDocument



Pipe = IN[0]

sPipe = IN[1]

PROFILE_VIEW = IN[2]





def move_labels(ids,PROFILE_VIEW):
	if not hasattr(PROFILE_VIEW, "__iter__"):
		PROFILE_VIEW = [PROFILE_VIEW]

	if not hasattr(ids, "__iter__"):
		ids = [ids]
	error_report = None
	res = []
	try:
		with adoc.LockDocument():		
		    with adoc.Database as db:		
		        with db.TransactionManager.StartTransaction() as t:		    
		            sampleLineId = PROFILE_VIEW[0].InternalObjectId
		            objVIEW = t.GetObject(sampleLineId, OpenMode.ForWrite)
		            for i in  ids:
						sampleLineIdp = i.InternalObjectId
						objp = t.GetObject(sampleLineIdp, OpenMode.ForWrite)
						objp.AddToProfileView(objVIEW.Id)										
						res.append('Success')
		            t.Commit()
	except:
		import traceback
		error_report = traceback.format_exc()
	if error_report is None:
		return res
	else:
		return error_report



OUTq =[]

if PROFILE_VIEW != None:
  for iPROFILE in PROFILE_VIEW:
     OUTq.append(move_labels(Pipe,iPROFILE))
     OUTq.append(move_labels(sPipe,iPROFILE))
     OUT = OUTq
else:
    OUTq.append("NO DATA")



This is great thanks for all of your assistance!

could you please upload the final dynamo script with the final python script