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

JJH_DrawPipesInProfileView.dyn (21.8 KB)

1 Like

Hi, this code is exactly what Im looking for, however I wish to supply the inputs through named objects rather than select objects. Im not at the level of editing python code but wondering is something simple like obtaining objectid from my element list. Only using gravity main pipes, so just IN[0] in use with IN[2]

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]


PROFILE_VIEW = 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



OUT = move_labels(Pipe,PROFILE_VIEW)

It just works ! Thank you hosneyalaa for taking the time, again… Your help on this civil forum is so appreciated. Thank u

1 Like

I haven’t read through everything in this post, but FYI there are some nodes in Camber that might help with this if anyone is looking for a non-Python route.

AddToViews

2 Likes

hello @mzjensen
camber, it would be great if adding profile view e block or cogopoint…

Hola buenas noches, el código funciona bien, sin embargo agrega todas las estructuras y buzones que hay en el modelo, hay manera de agregarlos con la lista que se tiene sin antes de hacer el flatten? No sé python, espero su ayuda, me serviría de mucho. Gracias

Hello mzjensen, could you post an example of how the node works? I get an error when placing the parts

Hi
Can you attach an example drawing and dynamo file
so i can for help you

You can’t use together PACKAGES

If you want to use Python, try as described in the post

And if you use a CAMBER package as in the picture

1 Like