Thankyou @Paolo_Emilio_Serra1
Of course, easy once you see it
Here for others is working python code, I also had to modify code as prev version didnât pass correct syntax to method i.e. Profile.CreateFromSurface Method (String, ObjectId, ObjectId, ObjectId, ObjectId, ObjectId)
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')
# Add standard Python references
import sys
sys.path.append('C:\Program Files (x86)\IronPython 2.7\Lib')
import os
import math
# Add references to manage arrays, collections and interact with the user
from System import *
from System.IO import *
from System.Collections.Specialized import *
from System.Windows.Forms import MessageBox
# 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
def create_profiles(align, surface, name, style, label):
"""
This method creates and empty profile object
:param names: List of profile names
:return: A list of profiles
"""
global adoc
global ed
global civdoc
result = []
# Get the active document in the AutoCAD session:
with adoc.LockDocument():
with adoc.Database as db:
with db.TransactionManager.StartTransaction() as t:
# get alignment
alignId = align.InternalObjectId
# get surface
surfId = surface.InternalObjectId
# set layer same as alignment
layerId = alignId.LayerId
# set profile style
styleId = civdoc.Styles.ProfileStyles[style]
# set label set
labelSetId = civdoc.Styles.LabelSetStyles.ProfileLabelSetStyles[label]
for n in name:
try:
# Creates a new profile
profId = Profile.CreateFromSurface(n, alignId, surfId, layerId, styleId, labelSetId)
except Exception() as ex:
MessageBox.Show(ex.message)
t.Commit()
for n in name:
result.append(align.ProfileByName(n))
return result
alignment = IN[0]
names = IN[1]
surface = IN[2]
StyleName = IN[3]
LabelSetName = IN[4]
if not isinstance(names, list):
names = [names]
OUT = create_profiles(alignment, surface, names, StyleName, LabelSetName)
Hi everyone, thanks for the arguments. I am trying to create multiple profiles for different alignments, but I have some problems with the pynode. It works for a single alignment and name, but when I try to input
Hi @n.rapetti, can you share your script? In my opinion you need to create your script which works for one alignment as a function and then you need to place this function into a for-loop. Something like this [function(alignment, profiles) for alignment in listOfAlignments].
the community rules do not allow sharing my .dyn script, because I am a new user. The Python script is the same one posted on this page. meanwhile I can share an image of how I built the scriptProfile creation.dyn (99.1 KB)
I am creating a script that would create a surface profile in the alignment and create profile views for multiple alignments, my issue was the surface profiles are not created in the alignment.
i have attached an image of what i have done. Can you please check.
The first one (left) said âunexpected indentâ, and the other two (right) said:
Traceback (most recent call last):
File ââ, line 75, in
TypeError: object of type âNoneTypeâ has no len()
Now, I might not even be using the nodes correctly in the first place. For instance, Iâm giving it multiple alignments to create profiles on, which might be a problem for it.
Also, when you say you âhavenât published our package yetâ, do you mean the Civil 3D Toolkit? Or a different package that I should look out for?
To identify where the âunexpected indentâ is, try pasting it into a more robust IDE, such as PyCharm. You could even use an online one like this. For the other Python nodes, check your input list structure.
I recommend that you use the Civil 3D Toolkit. You should be able to accomplish what you need without the Python.
Our node package is not available from the Dynamo Package Manger. It is published with the Wisconsin DOT State Kit. We will likely be retiring the package with Civil 3D 2022.
No, these nodes call up already existing profiles (if Iâm understanding them correctly), but I would like to create new profiles altogether. Just a simple profile, two PVI points and a single elevation.
For a large subdivision with many streets, this just makes the initial setup quicker. After creating the alignments from a 2d master plan, I can quickly create all the profile views at once (with a dynamo script), then it would be helpful to just as quickly create all the initial profiles with another script (after which begins the detailed profile design, which by its nature requires a hands-on approach).