Sketches go to axis

Sketches go to axis

kabanda
Participant Participant
1,828 Views
4 Replies
Message 1 of 5

Sketches go to axis

kabanda
Participant
Participant

I am a newbie to Fusion 360 but not to programming. 

It appears that my sketches are not going in the right direction and y and z coordinates are transposed.

Take this simple example script:

def demo_Lines_addTwoPointRectangle(sketch: adsk.fusion.Sketch):
    # Define two points
    pointOne = adsk.core.Point3D.create(0, 0, 0)
    pointTwo = adsk.core.Point3D.create(5, 15, 0)

    # Create the rectangle using the points
    rectangles = sketch.sketchCurves.sketchLines 
    rectangle = rectangles.addTwoPointRectangle(pointOne, pointTwo)

The rectangle is drawn towards the negative z direction even though both points have zero for z dimesion?
The point marked in the diagram is actually (5,0,-15)cm as noted at the bottom right of the UI.
Can someone please point me where my 'fundamental' mistake is coming from?

 

0 Likes
Accepted solutions (1)
1,829 Views
4 Replies
Replies (4)
Message 2 of 5

Jorge_Jaramillo
Collaborator
Collaborator

Hi,

 

I believe the problem is with the sketch you pass as parameter to the function.

Which sketch it is?  It is xZPlane based sketch?

 

If you replace it by a xYPlane based sketch your function will work OK.

But if you still need to use the current sketch, you might need to convert the points to the sketch geometry.

 

The problem comes from the fact that the points are placed with world geometry values and the sketch treat them as being local geometry (the internal geometry within the sketch).

 

Hope this help.

 

Regards,

Jorge Jaramillo

 

 

0 Likes
Message 3 of 5

kabanda
Participant
Participant

Yes, if I replace it with xYPlane the results appear correctly for that plane but I am not sure at what point in my script I made it impossible to honour the xZPlane since I want the sketch on that plane. There is nothing else in the script (which is only drawing this sketch) which has changed the sketche's orientation with respect to the world co-ordinate system. The sketch is in rootComp?

0 Likes
Message 4 of 5

BrianEkins
Mentor
Mentor
Accepted solution

Try this:

    pointOne = sketch.modelToSketchSpace(adsk.core.Point3D.create(0, 0, 0))
    pointTwo = sketch.modelToSketchSpace(adsk.core.Point3D.create(5, 15, 0))

 

Each sketch has its own coordinate system, and all geometry within the sketch is based on this coordinate system. When you create a sketch, you don't have any control over the orientation of the sketch, and Fusion does whatever it does. This is the same as in the UI. However, when interactively drawing geometry, it doesn't matter what the coordinates are since you are typically constraining relative to other geometry. 

---------------------------------------------------------------
Brian Ekins
Inventor and Fusion 360 API Expert
Website/Blog: https://EkinsSolutions.com
0 Likes
Message 5 of 5

kabanda
Participant
Participant
Thanks Brian,
That's helped.
0 Likes