Message 1 of 5
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I am starting to play around with the python API. I have a small script that draws a bunch of circles. Might a good soul explain to me how I should dimension said circles programmatically, so that they will be fully constrained?
See:
import adsk.core, adsk.fusion, adsk.cam, traceback, math
def run(context😞
ui = None
try:
app = adsk.core.Application.get()
ui = app.userInterface
design = app.activeProduct
unitsMgr = design.fusionUnitsManager
unitsMgr.distanceDisplayUnits = adsk.fusion.DistanceUnits.MillimeterDistanceUnits
# Get the root component of the active design.
rootComp = design.rootComponent
# Create a new sketch on the xy plane.
sketches = rootComp.sketches
xyPlane = rootComp.xYConstructionPlane
sketch = sketches.add(xyPlane)
circles = sketch.sketchCurves.sketchCircles
diameterFirst = 1
circle1 = circles.addByCenterRadius(adsk.core.Point3D.create(0, diameterFirst, 0), diameterFirst)
yRange=range(0,100,10)
for yn in yRange:
xRange=range(0,9,1)
x=0
y = yn * diameterFirst/9
circle1 = circles.addByCenterRadius(adsk.core.Point3D.create(0, y, 0), diameterFirst)
for n in xRange:
diameterNext=diameterFirst + .1
x=x+diameterFirst+diameterNext+0.2
pointNext = adsk.core.Point3D.create(x, y, 0)
circleInner = circles.addByCenterRadius(pointNext, diameterNext)
diameterFirst=diameterNext
except:
if ui:
ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))
Solved! Go to Solution.