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: 

Get thread centre point in the API

7 REPLIES 7
SOLVED
Reply
Message 1 of 8
DWhiteley
476 Views, 7 Replies

Get thread centre point in the API

I have managed to get to the 'threadfeature' for a threaded hole.

My question, is how do I find the centre point of the threaded hole from 'threadfeature'?

 

Many thanks in advance.

 

Dave Whiteley

 

7 REPLIES 7
Message 2 of 8
BrianEkins
in reply to: DWhiteley

You're right that the thread feature itself doesn't provide any information about its location in space.  However, it looks like there are a couple of relatively easy solutions. 

 

The first is to get the original cylinders that were used as input to create the thread.  However, those cylinders aren't available after the thread has been created because they may have been consumed.  However, you can roll the timeline back to just before the thread feature was created and then query for the cylinders using the inputCylindricalFace property of the ThreadFeature.  Then you'll need to move the timeline back to where it was.

 

The second is to look for a cylinder that was created as a result of adding the thread feature.  I checked and it looks like even when you model the threads that all thread types will create a cylinder as part of the geometry to model the thread.  I like this approach better because it's strictly a query operation and doesn't involve making changes to the model.  To do this you will use the faces property of the ThreadFeature and then use the geometry property of each face and look for the face whose geometry is a Cylinder type of object.  Then you can use properties on the cylinder to find the position and axis, which will be the same for the thread.

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

That's superb, thanks Brian. 

Message 4 of 8
DWhiteley
in reply to: BrianEkins

Hi Brian,

 

I think I'm nearly there.

I can't seem to get the correct centre point. I was hoping to obtain a point at the top centre of a drilled and tapped hole. Method 2 seems to give a centre point of the cylinder in some strange position.

Is there any way I can get this info?

 

Annotation 2020-04-24 173827.png

Message 5 of 8
BrianEkins
in reply to: DWhiteley

It's not always obvious what the "top" of the hole is.  Although admittedly it is in 99.99% of the cases, here's one where it's not.  Is the top where the axis emerges or at the highest point where any part of the cylinder exists?  

HoleTop.png

 

The latter case is easier to handle and will also provide the "correct" answer in the other 99.99% of the cases.  The approach is to get the bounding box of the cylindrical face and get the Z value of the max point (assuming the Z-axis defines up in your case) and use that as the Z value of your point.  The X and Y values will come from the cylinder point.

---------------------------------------------------------------
Brian Ekins
Inventor and Fusion 360 API Expert
Website/Blog: https://EkinsSolutions.com
Message 6 of 8
DWhiteley
in reply to: BrianEkins

Yes I suppose I could get the COG of the part and use that to determine which end of the cylinder is top?

Many thanks for your assistance again.
Message 7 of 8
BrianEkins
in reply to: DWhiteley

I don't see how the center of gravity will help.  If the orientation of the part is known and consistent you can code your program for that.  If the part can be in any orientation, then there is a lot more work to be done and probably some input needed from the user to define what direction is "up".

---------------------------------------------------------------
Brian Ekins
Inventor and Fusion 360 API Expert
Website/Blog: https://EkinsSolutions.com
Message 8 of 8
dave.whiteley
in reply to: BrianEkins

Hi Brian,

 

The second option works for me until I have a threaded hole in a pattern.

If I try and iterate through the threaded hole features in the component, I only get the original feature.

How can I access the positions of the threaded holes if they are in a pattern?

 

I'm really lost on this one!

 

Dave

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

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report