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:

## Finding all profiles of a Circular Sketch

7 REPLIES 7
Message 1 of 8
201 Views, 7 Replies

## Finding all profiles of a Circular Sketch

I have a created a circular sketch whose construction plane is a flat surface, as below.

This creates three profiles as labelled from 1 to 3.

Basing code off this forum post, I was able to reliably find profile 1 by using the SketchPoint at the center of the sketch. My question is how can I find profile 2?

Labels (1)
7 REPLIES 7
Message 2 of 8

Why doesn't your method to find profile 1 also work for profile 2? Besides finding one by a point inside the profile, you can also determine how the profiles differ geometrically and use that information. For example, from a profile, you can get its area properties. Profile 3 will have the largest area. That might also work with 1 and 2, depending on how consistent the position and sizes of the circles are. Another way is to use the centroids of the profiles. Having an imaginary line that goes from the center of one circle through the center of the other, the centroids will be in order along that line, profile 3, 1, 2. The sweep angle of the arcs made by the small circle might also differ between profiles 1 and 2. I think I would use the centroid approach. It seems like it would be the most dependable and fairly simple.

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

It doesn't work for profile 2 because the sketch point needs to be within the profile 😕

How difficult do you think it would be to generalize the centroid method to work with any combination of overlapping sketches? e.g. even with the centroid method, once I have the order of 3, 1, 2 (or 2, 1, 3) I'd still need to figure out if 2 or 3 is the one I need (in order for the code to work generally).

Message 4 of 8

I'm not sure what else I can do to help. You're correct that you must determine which of the three profiles you need to use. If you're using the same sketch interactively to create an extrusion, how do you visually determine which of the profiles to use? You're deciding to choose a particular one based on some logic. Now, how can you incorporate that same logic into a program? That can also be a challenge, and there might be different ways to do it, but there isn't one rule for all cases here, and I don't understand what's needed in your specific case.

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

Yep, make sense, thanks for your help anyway. I'll keep trying different things until I can find something that works!

I suppose I was wondering if there was an easy way to do this with the API. For example, access all profiles related to a sketch from the sketch object instead of the component object. I understand that this might not be doable due to the way Fusion handles profiles (I think I might have read this somewhere)?

Message 6 of 8

I don't understand your last statement. I think the only way to access profiles is from the Sketch object they are defined within.

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

Ah yes sorry, got a little confused. What I meant was currently you have to do something like

``````# Draw a circle.
circles = sketch.sketchCurves.sketchCircles

# Get the profile defined by the circle.
prof = sketch.profiles.item(0)``````

The problem here being that identifying the correct profile is tricky when you just have

``````# Not particularly easy to select the right profile
sketch.profiles``````

But having something like the following which gave me sketch profiles 1 and 2 (from the diagrams above) could be nice from a user point of view potentially? I'm not sure if this is something that is possible though.

``````# Draw a circle.
circles = sketch.sketchCurves.sketchCircles

# Get the profile defined by the circle.
circle1.profiles``````

Message 8 of 8

That is possible with the API today, with a little work. The information is there; it's just that code must be written to dig it out and make sense of it. Here's a variation of the original problem, where three circles have been drawn.

This results in the four profiles shown below.

Circle 1 defines A, B, and C

Circle 2 defines A, B, and C

Circle 3 defines A and D.

To get this using a program the following is available in the API. The Profile object supports the profileLoops property, which returns a ProfileLoops object. A loop defines a connected set of geometry that defines the shape of the profile Profiles B, C, and D all have one loop. Profile A has two loops, one that defines its outer loop and another that defines the inner loops for the hole made by circle 3.

A profile loop specifies if it defines the outside or the inside of the profile. For example, with Profile A, one of the loops will be the outer loop, and from the loop, you can get the profile curves that make up the loop. The geometry of the two ProfileCurve objects of the outer loop will be two arcs that will be returned as Arc3D objects. Also, from the ProfileCurve object, you can get the sketch geometry that resulted in its creation. In this case, one of the profile curves will return circle 1 and the other will return circle 2. The other loop is an inner loop and has a single profile curve which is defined by circle 3.

Using that information, it's possible to write a function that will determine:

Circle 1 contributes to profiles A, B, and C

Circle 2 contributes to profiles A, B, and C

Circle 3 contributes to profiles A and D.

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

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