Bug Report (minor): dimensions between 2 sketches via API crashes fusion360

Bug Report (minor): dimensions between 2 sketches via API crashes fusion360

OceanHydroAU
Collaborator Collaborator
450 Views
3 Replies
Message 1 of 4

Bug Report (minor): dimensions between 2 sketches via API crashes fusion360

OceanHydroAU
Collaborator
Collaborator

See also: CER_219887783

 

I made you a sample so you can reproduce this crash yourself.

 

Open "text commands", click the Py button:-

 

Screen Shot 2020-05-20 at 2.00.26 am.png

Then Paste the following, one-line-at-a-time, into the box.

 

sketch1 = adsk.core.Application.get().activeProduct.rootComponent.sketches.add(   adsk.core.Application.get().activeProduct.rootComponent.xYConstructionPlane)
point3d1 = adsk.core.Point3D.create(1.0, 1.0, 0)
point1 = sketch1.sketchPoints.add(point3d1)

sketch2 = adsk.core.Application.get().activeProduct.rootComponent.sketches.add(   adsk.core.Application.get().activeProduct.rootComponent.xYConstructionPlane)
point3d2 = adsk.core.Point3D.create(2.0, 2.0, 0)
point2 = sketch2.sketchPoints.add(point3d2)

r = sketch2.sketchDimensions.addDistanceDimension(point1, point2, 1, point3d2) # Save your work first - this crashes Fusion 360.

 

Should be an easy one to fix 🙂

 

Good luck.

0 Likes
451 Views
3 Replies
Replies (3)
Message 2 of 4

Phil.E
Autodesk
Autodesk

Thanks, ticket logged. 





Phil Eichmiller
Software Engineer
Quality Assurance
Autodesk, Inc.


0 Likes
Message 3 of 4

kandennti
Mentor
Mentor

Hi @OceanHydroAU .

 

As with the GUI, I think it is necessary to include once when dimensioning between different sketches.
Therefore, I don't feel it is a bug.

import adsk.core, adsk.fusion, traceback

_app = adsk.core.Application.cast(None)
_ui = adsk.core.UserInterface.cast(None)

def run(context):
    try:
        global _app, _ui
        _app = adsk.core.Application.get()
        _ui = _app.userInterface
        des  :adsk.fusion.Design = _app.activeProduct
        root :adsk.fusion.Component = des.rootComponent

        sketch1 = root.sketches.add(root.xYConstructionPlane)
        point3d1 = adsk.core.Point3D.create(1.0, 1.0, 0)
        point1 = sketch1.sketchPoints.add(point3d1)

        sketch2 = root.sketches.add(root.xYConstructionPlane)
        point3d2 = adsk.core.Point3D.create(2.0, 2.0, 0)
        point2 = sketch2.sketchPoints.add(point3d2)

        # include point1 into sketch2
        includeList = sketch2.include(point1)
        oriH = adsk.fusion.DimensionOrientations.HorizontalDimensionOrientation

        sketch2.sketchDimensions.addDistanceDimension(includeList[0], point2, oriH, point3d2)
    except:
        if _ui:
            _ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))
0 Likes
Message 4 of 4

OceanHydroAU
Collaborator
Collaborator

A product crash requiring a restart is a bug (someone dereferenced a pointer wrongly) - good to know there's a workaround if people need this now though.  In my case, it was a mistake - I didn't actually want 2 sketches, but I felt it was a serious enough problem to tell Autodesk about.

0 Likes