Why coordinates shifts when ConstructionPlane changed?

Why coordinates shifts when ConstructionPlane changed?

ph0en1x01
Contributor Contributor
505 Views
3 Replies
Message 1 of 4

Why coordinates shifts when ConstructionPlane changed?

ph0en1x01
Contributor
Contributor

I am trying to create a sketch on an offset plane parallel to yZConstructionPlane. But every time, the coordinates shift on the lower right status bar. Can someone explain why Fusion does that?

Because of this, it gets tricky to put coordinates in Point3D.create(x,y,z). Is there any solution to this problem?

 

Here is the code sample:

import adsk.core
import adsk.fusion
import adsk.cam
import 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)
        rootComp = design.rootComponent
        sketches = rootComp.sketches

        yzPlane = rootComp.yZConstructionPlane
        planes = rootComp.constructionPlanes
        planeInput = planes.createInput()
        offsetDistance1 = adsk.core.ValueInput.createByString('250')
        planeInput.setByOffset(yzPlane, offsetDistance1)
        plane = planes.add(planeInput)

        sketch = sketches.add(plane)
        sketchPoints = sketch.sketchPoints


        centerPoint= adsk.core.Point3D.create(0, 0, 0)
        cornerPoint = adsk.core.Point3D.create(4, 4, 0)
        a = sketchPoints.add(centerPoint)
        b = sketchPoints.add(cornerPoint)

        rectangles = sketch.sketchCurves.sketchLines
        rectangle = rectangles.addCenterPointRectangle(centerPoint, cornerPoint)


    except:
        if ui:
            ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))

 
As you can see the coordinates given in x,y are shifted to y,z.

Reference Image.png

0 Likes
Accepted solutions (1)
506 Views
3 Replies
Replies (3)
Message 2 of 4

kandennti
Mentor
Mentor

Hi @ph0en1x01 .

 

Can you please publish an f3d file or code that can reproduce this?

0 Likes
Message 3 of 4

ph0en1x01
Contributor
Contributor
ok, I edited the question.
0 Likes
Message 4 of 4

kandennti
Mentor
Mentor
Accepted solution

@ph0en1x01 .

 

Thanks for the code.

 

I believe the result is correct because what is drawn in the sketch is drawn based on the position of the origin of the sketch.

If you want to draw based on the origin of the component, you can use the modelToSketchSpace method, but in this case the addCenterPointRectangle method will fail.

https://help.autodesk.com/view/fusion360/ENU/?guid=GUID-dfec5579-3ee5-432b-80d9-50710515bd71 

・・・
        rectangles = sketch.sketchCurves.sketchLines
        rectangle = rectangles.addCenterPointRectangle(centerPoint, cornerPoint)

        centerPoint_model: adsk.core.Point3D = sketch.modelToSketchSpace(centerPoint)
        cornerPoint_model: adsk.core.Point3D = sketch.modelToSketchSpace(cornerPoint)
        sketchPoints.add(centerPoint_model)
        sketchPoints.add(cornerPoint_model)
        rectangles.addCenterPointRectangle(centerPoint_model, cornerPoint_model)