Community
Fusion API and Scripts
Got a new add-in to share? Need something specialized to be scripted? Ask questions or share what you’ve discovered with the community.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Marginal condition causes a bug in ConstructionPlaneInput.setByDistanceOnPath

3 REPLIES 3
SOLVED
Reply
Message 1 of 4
nnikbin
475 Views, 3 Replies

Marginal condition causes a bug in ConstructionPlaneInput.setByDistanceOnPath

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()))

  

Capture_02.png

 

 

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.

 

Capture_01.png

 

3 REPLIES 3
Message 2 of 4
nnikbin
in reply to: nnikbin

As a simple temporary solution:

  • Using 0.9999999 instead of 1.0 solves the issue when the active units of the design is set to "inch", but causes failure when the active units of the design is set to "foot"
  • Using 0.99999 instead of 1.0 solves the issue for "inch" and "foot"

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

Message 3 of 4
liujac
in reply to: nnikbin

Hi,

 

Thanks for reporting this issue. I logged a defect (UP-30784) in our internal system. We will fix it soon.

 

Regards,

Jack 

Message 4 of 4
nnikbin
in reply to: liujac

Hi Jack,

 

Thanks for logging the defect.

 

Regards,

Navid

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report