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.
User selects pipes and/or pressure pipes to add to profile view
User selects profile view to add selected pipes and/or pressure pipes to
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
A combined filtered list of pipes and/or pressure pipes is created
Python script adds pipes and/or pressure pipes to profile view.
Since we have a language barrier, I am going to include @zachri.jensen on this discussion and see if he has some availability to take a look.
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:
Select Profile View with “Select Objects” node
Select Pipes and Pressure Pipes with second “Select Objects” node
Python script uses these selections as inputs and adds to profile view
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.
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")
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)
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.
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