- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I have run into some unexpected constraints when creating some curves (lines specifically). I now know why they are happening and in most cases prevent them from happening. The fact is, they are hidden constraints. They don't show up on any of the constraint lists. They happen when you refer to a defined point. For example, sketch.originPoint. I can almost understand that constraint and why it would be hidden. But it also happens when you refer to a point on another curve.
In the following script, a line is created, then another line the refers to the origin and endpoint of the first line. The print statements show no constraints (Am I doing the prints right?) on the line or in the sketch. But if we run the sketch we will find the second line constrained to the origin and the endpoint of the first line. The constraint to the endpoint does show up when editing the sketch. The constraint to the origin is truly hidden.
import adsk.core, traceback def run(context): ui = None try: app = adsk.core.Application.get() ui = app.userInterface doc = app.documents.add(adsk.core.DocumentTypes.FusionDesignDocumentType) design = adsk.fusion.Design.cast(app.activeProduct) # Get the root component of the active design. rootComp = adsk.fusion.Component.cast(design.rootComponent) # Create a new sketch on the xy plane. sketches = rootComp.sketches; xyPlane = rootComp.xYConstructionPlane testSketch = adsk.fusion.Sketch.cast(sketches.add(xyPlane)) # Get testSketch health state health = testSketch.healthState if health == adsk.fusion.FeatureHealthStates.ErrorFeatureHealthState or health == adsk.fusion.FeatureHealthStates.WarningFeatureHealthState: msg = testSketch.errorOrWarningMessage constructionLine = testSketch.sketchCurves.sketchLines.addByTwoPoints(adsk.core.Point3D.create(0,1), adsk.core.Point3D.create(1,1)) constructionLine.isConstruction = True sketchLine = testSketch.sketchCurves.sketchLines.addByTwoPoints(testSketch.originPoint, constructionLine.endSketchPoint) for aConstraint in sketchLine.geometricConstraints: print(aConstraint) for aConstraint in testSketch.geometricConstraints: print(aConstraint) except: if ui: ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))
Solved! Go to Solution.