Civil 3D Draw Multiple Pipes In Profile View From Selection

Hi,

I am looking into setting up a script that would allow me to select multiple types of pipes (gravity and pressure) and then draw those into profile view. Currently with Civil 3D you can only select pipes from the same network and draw them in. As soon as a pipe from a different network is selected, the option to draw into profile view disappears. Does anyone have thoughts on how simple of a program this would be to set up. Currently, our technicians spend a fair amount of tie drawing them in. It would be nice to just select the crossers and draw them all in at once. Thanks.

welcome
Who would prefer to attach an example file?
So that members can help prefer
Check Autodesk_Civil3DToolkit if there is a display of items on the profile view

if there is NOT a display on the profile view
You need both
https://help.autodesk.com/view/CIV3D/2021/ENU/?guid=2b015c6e-522c-ab2d-1d47-4b2e3f4a2f03
P

https://help.autodesk.com/view/CIV3D/2021/ENU/?guid=ac99ebc3-1f1b-a3d3-1d9c-5faa34f66934

PP

I did not notice any nodes for drawing parts in profile for civil 3D that had already been created. My question was more about how tough this would be to set up. Looks like I would need to go the python node route based on your response.

JJH_DrawPipesInProfileView.dyn (7.4 KB)

I have attached some code that I started working on. Pretty barebones still as far as the python portion goes. I am still learning the python node. Can anyone help with the python transaction? My plan was to have this program set up with three inputs. First the user will select the gravity crossing pipes. Next the pressure crossing pipes are selected. Finally, the profile view is selected. The code is started, but I am not sure about the python transaction to take the selected objects and draw them in profile. I understand I will need to use the commands you have linked above from the developer’s guide. I am just unsure how to go about building that in. Thanks.

Unfortunately this didn’t work for me
As if the dynamo is not working
But it works fine with c#

ppp

can you share the python code ? The API call is the same so if it works with C# then it should with python from dynamo

@david_licona
yes

# Load the Python Standard and DesignScript Libraries
import sys
import clr

# Add Assemblies for AutoCAD and Civil3D
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')


# 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 *

#from Autodesk.AutoCAD.DynamoNodes import SelectionByQuery
# The inputs to this node will be stored as a list in the IN variables.
PipesIn = IN[0]
PressurePipesIn = IN[1]
ProfileViewIn = IN[2]


adoc = Application.DocumentManager.MdiActiveDocument
editor = adoc.Editor

with adoc.LockDocument():
    with adoc.Database as db:

        with db.TransactionManager.StartTransaction() as t:
            # Place your code below
            #surfId = PipesIn.InternalObjectId
            #ProfViewHandle = int(PipesIn[0], 16)
            #SelectionByQuery.GetObjectByObjectHandle(PipesIn)
            bt = t.GetObject(db.BlockTableId, OpenMode.ForWrite)
            btr = t.GetObject(bt[BlockTableRecord.ModelSpace], OpenMode.ForWrite)
            objp = t.GetObject(PipesIn[0], OpenMode.ForWrite)           
            objpp = t.GetObject(PressurePipesIn[0], OpenMode.ForWrite)
            objv = t.GetObject(ProfileViewIn[0], OpenMode.ForWrite)
            #
            #
            #objpid = objp.PartFamilyId
            objp.AddToProfileView(objv.Id)
            objp.GetProfileViewsDisplayingMe

            # Commit before end transaction
            #t.Commit()
            pass

# Assign your output to the OUT variable.
#OUT = PipesIn

OUT = objp.ProfileViewPartId,dir(objp.GetProfileViewsDisplayingMe)


JJH_DrawPipesInProfileView from .dyn (16.0 KB)

Yes it works I forgot
t.Commit()

# Load the Python Standard and DesignScript Libraries
import sys
import clr

# Add Assemblies for AutoCAD and Civil3D
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')


# 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 *

#from Autodesk.AutoCAD.DynamoNodes import SelectionByQuery
# The inputs to this node will be stored as a list in the IN variables.
PipesIn = IN[0]
PressurePipesIn = IN[1]
ProfileViewIn = IN[2]


adoc = Application.DocumentManager.MdiActiveDocument
editor = adoc.Editor

with adoc.LockDocument():
    with adoc.Database as db:

        with db.TransactionManager.StartTransaction() as t:
            # Place your code below
            #surfId = PipesIn.InternalObjectId
            #ProfViewHandle = int(PipesIn[0], 16)
            #SelectionByQuery.GetObjectByObjectHandle(PipesIn)
            bt = t.GetObject(db.BlockTableId, OpenMode.ForWrite)
            btr = t.GetObject(bt[BlockTableRecord.ModelSpace], OpenMode.ForWrite)
            objp = t.GetObject(PipesIn[0], OpenMode.ForWrite)           
            objpp = t.GetObject(PressurePipesIn[0], OpenMode.ForWrite)
            objv = t.GetObject(ProfileViewIn[0], OpenMode.ForWrite)
            #
            #
            #objpid = objp.PartFamilyId
            objp.AddToProfileView(objv.Id)
            objp.GetProfileViewsDisplayingMe

            # Commit before end transaction
            t.Commit()
            pass

# Assign your output to the OUT variable.
#OUT = PipesIn

OUT = objp.ProfileViewPartId,dir(objp.GetProfileViewsDisplayingMe)


1 Like

DrawPipesInProfileView_rev0.dyn (16.0 KB)

I made a few minor tweaks to the program you uploaded and have a couple of additional questions.

  1. How difficult would it be to have the command prompt state which object(s) to select (Select Profile View, Select Pipes, Select Structures)

  2. The program currently will not function if you do not select at least one pipe and one pressure pipe. How difficult would it be to adjust the code so that in the event there is no pressure pipe crossing or no pipe crossing that the code can still execute and add the crossing pipes of one type. Hopefully that makes sense.

@hosneyalaa @david_licona

hi
try this

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


PROFILE_VIEW = IN[0]


objects = IN[1]


def move_labels(ids,PROFILE_VIEW):
	if not hasattr(PROFILE_VIEW, "__iter__"):
		PROFILE_VIEW = [PROFILE_VIEW]
	#if not hasattr(yy, "__iter__"):
		#yy = [yy]
	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:		    
		            bt = t.GetObject(db.BlockTableId, OpenMode.ForWrite)
		            btr = t.GetObject(bt[BlockTableRecord.ModelSpace], OpenMode.ForWrite)
		            for i in  ids:
						obj = t.GetObject(i, OpenMode.ForWrite)
						objVIEW = t.GetObject(PROFILE_VIEW[0], OpenMode.ForWrite)
						obj.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 =[]

for iPROFILE in  PROFILE_VIEW:
    OUTq.append(move_labels(objects,iPROFILE))




OUT = OUTq










ppp33

@hosneyalaa Thank you for the reply. When I use this updated code in the way that you have it outlined in your screencast I am unable to get the pipes/pressure pipes to draw in the profile view. See error message included below.

DrawPipesInProfileView_rev1.dyn (17.3 KB)

a

DrawPipesInProfileView_rev11.dyn (19.1 KB)

@hosneyalaa Thanks for the updated code. The code runs good for me but still will not allow the user to add just pipes or just pressure pipes. It appears to me that you still have to select at least one pressure pipe and one pipe to run. Is this how it works for you as well.

That goes back to my earlier question about being able to add any combination (pressure pipes & pipes, just pressure pipes, just pipes) would be the ideal way for a program like this to operate. Not sure how easy that is to include.

Thanks

welcome
Because my English is not good

I couldn’t understand well
Can you explain to me with pictures?
or video
So that I can help you if i can

@hosneyalaa

See included pictures to hopefully show you the issue.

Image A: Run program and first select Profile View. Hit Enter(Return) on Keyboard.

Image B: Next select Pipe. Hit Enter(Return) on Keyboard.

Image C: Next select Pressure Pipe. Hit Enter(Return) on Keyboard.

Image D: Program completes run successfully. Both pipe and pressure pipe display in Profile View.

Image Z: Now for the trouble. Once again run program and begin by selecting the profile view.

Image Y: Next select pipe. Hit enter(return) on keyboard.

Image X: This time I don’t want to add a pressure pipe like before. Do not select pressure pipe and hit enter(return) on keyboard. The program does not run correctly and shows an error. The pipe does not display in the profile view.

The last picture in yellow indicates the user You didn’t choose any item of the desired type

tomorrow morning I will choose another way Through the nodes in civil 3d toolkit nodes

Okay thank you I will look for your reply.

TRY

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


PROFILE_VIEW = IN[0]


objects = IN[1]


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 objects != None:
  for iPROFILE in PROFILE_VIEW:
     OUTq.append(move_labels(objects,iPROFILE))
else:
    OUTq.append("NO DATA")




OUT = OUTq





ppp33

PipeNetwork_InvertToPolylines +PYTHON+f.dyn (32.6 KB)

1 Like