Message 1 of 4
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
When the active units of the design is set to inch or foot, passing 1.0 as the distance parameter to ConstructionPlaneInput.setByDistanceOnPath method creates an invalid state.
Here is a my code for testing this issue:
import adsk.core, adsk.fusion, adsk.cam, traceback def run(context): ui = None try: app = adsk.core.Application.get() ui = app.userInterface product = app.activeProduct design = adsk.fusion.Design.cast(product) rootComponent = design.rootComponent sketches = rootComponent.sketches p1 = adsk.core.Point3D.create(0, 0, 0) p2 = adsk.core.Point3D.create(5, 0, 0) sketch = sketches.add(rootComponent.xYConstructionPlane) sketchLines = sketch.sketchCurves.sketchLines sketchLine = sketchLines.addByTwoPoints(p1, p2) constructionPlanes = rootComponent.constructionPlanes constructionPlaneInput = constructionPlanes.createInput() constructionPlaneInput.setByDistanceOnPath(sketchLine, adsk.core.ValueInput.createByReal(0)) constructionPlane = constructionPlanes.add(constructionPlaneInput) constructionPlaneInput.setByDistanceOnPath(sketchLine, adsk.core.ValueInput.createByReal(0.5)) constructionPlane = constructionPlanes.add(constructionPlaneInput) constructionPlaneInput.setByDistanceOnPath(sketchLine, adsk.core.ValueInput.createByReal(1.0)) constructionPlane = constructionPlanes.add(constructionPlaneInput) except: if ui: ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))
As you can see the add-in fails in creating the 3rd construction plane. I guess some round-off errors in conversion between imperial and metric units results a larger than 1.0 parameter which causes this issue.
The same issue happens in using C++ API. There isn't any problem in running the code when the active unit of the design is set to one of the metric units.
Website: https://perceptino.com
Solved! Go to Solution.