Use the API to programatically project a components origin onto a sketch.

Use the API to programatically project a components origin onto a sketch.

jimsneddon6
Participant Participant
464 Views
3 Replies
Message 1 of 4

Use the API to programatically project a components origin onto a sketch.

jimsneddon6
Participant
Participant

Hope someone can help. How do I project a component's Origin onto a component sketch?

I am writing my first addIn and, using the API documentation, succeeded in programatically drawing my first sketch, dimensioning with parameter references, and constraining the lines, but I am stuck with my last requirement. My sketch is within a sub component I created and I think I need to Project the Origin Point (OP) of this component onto my sketch, so that I can use a Coincidence constraint between it a line end point in my sketch to finally constrain my whole sketch. I have searched the API but cannot see how to do this.

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

BrianEkins
Mentor
Mentor
Accepted solution

It is possible to project a point onto a sketch, but in your case, you don't need to because Fusion automatically projects the origin into a sketch when you create it. You can see this by creating a sketch and then moving your mouse over the origin. You'll see a point highlight when the mouse moves over it. There is a sketch point, but it stays hidden until the mouse is over it. I believe it should always be available in the API as the first SketchPoint in the SketchPoints collection of the sketch.

---------------------------------------------------------------
Brian Ekins
Inventor and Fusion 360 API Expert
Website/Blog: https://EkinsSolutions.com
Message 3 of 4

jimsneddon6
Participant
Participant

Many thanks Brian, you have saved me pulling out what little hair I have left. I have used that very point on many designs when using my mouse without even considering its existence. I certainly would have spent time trying to find out how to access it. Just in case some other newbie to the API with the same problem stumbles across this answer, the simple change to my code:

 

    # pointO = adsk.core.Point3D.create(0, 0, 0) ..out with the old
    pointO = sketch.sketchPoints[0]  # ..in with the new
 
Community forums like this put the Internet on the awesome end of the scale. Again many thanks.
0 Likes
Message 4 of 4

jimsneddon6
Participant
Participant

I add this as a newbie for any others in the same boat. While doing some other coding I noticed a simpler way to get a sketch's origin point:

In my previous reply I stated I'd used the following (once Brian had lit the way):

    sketch.sketchPoints[0]

but a more specific access, that I also didn't previously know about, is

    sketch.originPoint()

 

Always learning, even the simple stuff.