I am really new to Python and trying to create while loop in Python script node of Dynamo. bellow is my efforts without any knowledge of python and basic search on google for while loop. so pardon me if its full of mistakes and errors, it would be really great if someone can guide me to get this sorted.
attached dyn for reference.ttr_test.dyn (31.7 KB)
try to add a tab
Thanks for the reply @c.poupin. though it will be difficult for me to understand this coding language, took some baby steps as per the article and corrected the script. still seems i am way out of track ? apart from indent do you think anything else needed in the code or workflow is correct ?
you are defined 2 alias you can use them
Hi @c.poupin Apologies for the late reply…
took some time and help and worked on the script …good news is its working now, but it wont exit the loop and never complete the run.
Please suggest if it can update the loop somehow
If you want to simplify things, you could remove lines 59-74. They are for handling transactions with the AutoCAD/Civil 3D database via the API, which doesn’t appear to be your goal.
a simple example to create a circle in Civil3D from a Dynamo Geometry
# Load the Python Standard and DesignScript Libraries
# Add Assemblies for AutoCAD and Civil3D
# 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 Autodesk.DesignScript.Geometry as DS
# 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.
dataEnteringNode = IN
adoc = Application.DocumentManager.MdiActiveDocument
editor = adoc.Editor
center = IN
#create a proto Geometry
circleDs = DS.Circle.ByCenterPointRadius(center, 50)
with adoc.Database as db:
with db.TransactionManager.StartTransaction() as t:
# Place your code below
acBlkTbl = t.GetObject(db.BlockTableId, OpenMode.ForRead)
acBlkTblRec = t.GetObject(acBlkTbl[BlockTableRecord.ModelSpace], OpenMode.ForWrite)
acCirc = Circle()
acCirc.Center = Point3d(circleDs.CenterPoint.X, circleDs.CenterPoint.Y, circleDs.CenterPoint.Z)
acCirc.Radius = circleDs.Radius
# Commit before end transaction
# Assign your output to the OUT variable.
OUT = circleDs
@c.poupin thanks for reply…its not a simple circle. if you look at the code, its trying to find the center and radius from a loop and at the moment its not exiting loop.