Create Profile

They will create new profiles, and then PVIs can be added to them.

1 Like

Wow, Iā€™m still adjusting to understanding the way the nodes are named. But I like how it splits up the actions of creating an object, and then actually adding definition to the object. Once you get a little more used to it, this way of seeing Civil 3D seems more logical than the way it is presented through the programā€™s default user interface.

That online Python tool is excellent! I do need to re-install Pycharm again; I had it to start learning Python. (One Windows re-install later, I keep forgetting to install it again)


Hi Zach, Iā€™m new to dynamo. Iā€™m trying to create multiple profiles from one of your scripts but not winning. Please take a look at the attached image and kindly advise.

Hi @sihle.dlamini,

It looks like there are just a few inputs missing. You need to provide values for ā€˜styleā€™, ā€˜labelSetā€™, and ā€˜offsetā€™. If you hover over any port you will see what type of object it is expecting and whether a default value is supplied. If there is no default value (as is the case for all of the inputs except ā€˜layerā€™ for this specific node), then the node will not execute until a value is supplied.

On another note, I see that the profile name youā€™ve supplied is ā€œEG - Surfaceā€ in double quotes. Because itā€™s a string node, the double quotes are not needed, unless of course you want the profile to be named ā€œEG - Surfaceā€ with the double quotes. If you put the same thing in a code block, then the double quotes would be needed so that it is interpreted as a string.

2 Likes

Hi @mzjensen

Thanks a lot, works like a charm

1 Like

This thread has been very helpful in getting my dynamo script all set up for adding surfaces to my profiles in bulk. Now I have some stray surfaces which had been added previously and Iā€™d like to clean them up. I am not seeing a lot of helpful info in the object.properties to sort them by source surface, but it would be great to have a tool that does the exact opposite of AignmentExtensions.AddSurfaceByProfile. Is there a relativley simple adjutment to the code that might allow this? If not, any advice on a workaround to remove specific surfaces from a large set of profiles?

Try this. The List.FilterByBoolMask node is key whenever you want to filter a list by a condition. You could add more of them to filter by Profile name, Alignment name, etc.

hello as I achieve this output of the object

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

# Add Assemblies for AutoCAD and Civil3D
clr.AddReference('AcMgd')
clr.AddReference('AcCoreMgd')
clr.AddReference('AcDbMgd')
clr.AddReference('AecBaseMgd')
clr.AddReference('AecPropDataMgd')
clr.AddReference('AeccDbMgd')

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

# The inputs to this node will be stored as a list in the IN variables.

adoc = Application.DocumentManager.MdiActiveDocument
civdoc = CivilApplication.ActiveDocument
editor = adoc.Editor

profileName=IN[0]
alignmentName=IN[1]
layerName=IN[2]
styleName=IN[3]
labelSetName=IN[4]

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

        with db.TransactionManager.StartTransaction() as t:
            # Place your code below         
            profId = Profile.CreateByLayout(profileName, civdoc,  alignmentName, layerName, styleName, labelSetName)
            obj=t.GetObject(profId,OpenMode.ForRead)

            # Commit before end transaction
            t.Commit()
            pass

# Assign your output to the OUT variable.
OUT =obj.Name

hi
try

alignId = align.InternalObjectId
OUT = alignId .ProfileByName(obj.Name)

hi @hosneyalaa
How to add a cogo point to a profile view with python ?

Civil 3D API
It does not support this

Hi Keithi
I have a similar kind of task to perform but using this method I can able to only add new PVI, what if I need to update some PVi value or need to delete them. I am not getting any node in dynamo to perform PVi Update/Remove. Can you please help.

The ProfilePVICollection has several methods to removed PVIs.
Autodesk Civil 3D Help | ProfilePVICollection Members | Autodesk

@Eden

Maybe this topic will help you