Hello, is there any node similar to PVIandRadius or do you have maybe the Python code to use it momentarily civil 3d 2025?
@zachri.jensen and @hosneyalaa Please could you help me with this?
I’m not trying this before
Try AddFreeCircularCurveByPVIAndRadius Method by python code
https://help.autodesk.com/view/CIV3D/2025/ENU/?guid=fee99593-3c87-5093-dec2-464e116b603f
Can anyone help with the code in CPython?
Example.dyn (88.7 KB)
Intro-1.dwg (2.4 MB)
# 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 *
import Autodesk.Civil.DatabaseServices as civdbs
# The inputs to this node will be stored as a list in the IN variables.
dataEnteringNode = IN
# Get the active document
adoc = Application.DocumentManager.MdiActiveDocument
editor = adoc.Editor
civdoc = CivilApplication.ActiveDocument
# Input parameters
profile = IN[0] # Profile object
attach_point = IN[1] # PVI index to attach the curve
curve_length = IN[2] # Length of the circular curve
def AddFreeCircularCurve(profile, attach_point, curve_length):
with adoc.LockDocument():
with adoc.Database as db:
with db.TransactionManager.StartTransaction() as t:
try:
# Get the profile object
profileId = profile.InternalObjectId
profileObj = t.GetObject(profileId, OpenMode.ForWrite)
# Get PVIs collection
pvis = profileObj.PVIs
if attach_point >= pvis.Count - 1:
raise Exception("Attach point must be less than the total number of PVIs")
# Get the PVI points we'll work with
pvi1 = pvis.GetPVIAt(attach_point)
pvi2 = pvis.GetPVIAt(attach_point + 1)
# Calculate grade between points
grade = (pvi2.Elevation - pvi1.Elevation) / (pvi2.Station - pvi1.Station)
# Calculate curve parameters
halfLength = curve_length / 2.0
startStation = pvi1.Station + halfLength
endStation = pvi2.Station - halfLength
# Add the circular curve
curveParams = civdbs.ProfileCurveParameters()
curveParams.CurveType = civdbs.ProfileCurveType.Parabolic
curveParams.Length = curve_length
profileObj.AddVerticalCurve(attach_point, curveParams)
t.Commit()
return profileObj
except Exception as ex:
editor.WriteMessage("\nError: " + str(ex))
return None
# Execute the function
result = AddFreeCircularCurve(profile, attach_point, curve_length)
# Assign your output to the OUT variable
OUT = result
any ideas regarding this please
@hosneyalaa
@zachri.jensen
@Anton_Huizinga
# 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 *
import Autodesk.Civil.DatabaseServices as civdbs
# The inputs to this node will be stored as a list in the IN variables.
dataEnteringNode = IN
# Get the active document
adoc = Application.DocumentManager.MdiActiveDocument
editor = adoc.Editor
civdoc = CivilApplication.ActiveDocument
# Input parameters
profile = IN[0] # Profile object
attach_point = IN[1] # PVI index to attach the curve
curve_length = IN[2] # Length of the circular curve
def AddFreeCircularCurve(profile, attach_point, curve_length):
with adoc.LockDocument():
with adoc.Database as db:
with db.TransactionManager.StartTransaction() as t:
try:
# Get the profile object
profileId = profile.InternalObjectId
profileObj = t.GetObject(profileId, OpenMode.ForWrite)
# Get PVIs collection
pvis = profileObj.PVIs
if attach_point >= pvis.Count - 1:
raise Exception("Attach point must be less than the total number of PVIs")
# Get the PVI to attach the curve to
attachPVI = pvis.GetPVIAt(attach_point)
# Add the circular curve using the correct method
curve = profileObj.AddFreeCircularCurveByPVIAndLength(attachPVI, curve_length)
t.Commit()
return profileObj
except Exception as ex:
editor.WriteMessage("\nError: " + str(ex))
return None
# Execute the function
result = AddFreeCircularCurve(profile, attach_point, curve_length)
# Assign your output to the OUT variable
OUT = result
I can’t get it to work
TRY
# Add the circular curve using the correct method
profileObj.Entities.AddFreeCircularCurveByPVIAndLength(attachPVI, curve_length)
t.Commit()
return profileObj
I have tried but it still does not work