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.
Solved! Go to Solution.
Solved by liujac. Go to Solution.
As a simple temporary solution:
So I suggest checking the distance and if it is grater than 0.99999 then change it to 0.99999. In this case the command at history timeline rounds-up the distance and shows 1.00 instead of 0.99999
Hi,
Thanks for reporting this issue. I logged a defect (UP-30784) in our internal system. We will fix it soon.
Regards,
Jack