Thread Engagement Macro

I am looking to create or customize a macro, that will go thru all of the fasteners in a given assembly and calculate the thread engagement, ensure that the right fastener is used in the right hole wizard hole and ensure that the fastener is not bottoming out in the tapped hole. This macro would be used as a design check function automating the manual thread engagement calculation on each fastener in which there are many in our assemblies. We do not use toolbox, so none of that functionality can be used. Is there something like this already out there that I could leverage? If not, then are there any suggestions on how to go about finding all of the fasteners in the subassembly, finding the hole properties of the hole the fastener is located in, finding the amount of fastener engagement into that hole? Any help is greatly appreciated. Thanks.

SolidworksApi/macros
Comments 10
MB
MB 2021-04-08

They have utilites for this

123GO by Logopress | SOLIDWORKS 

MP
MP 2021-04-08

Josh Brady wrote:

You have not stated any level of current API knowledge.  However, this one is complex enough that, unless you are already pretty experienced in the SW API, it's going to be most cost-efficient for you to pay someone to do it.  It probably won't be particularly cheap, but to go from zero to the ability level required by this macro would probably take 2 months full-time study for someone with a knack for coding.  And then you'd have to actually write it.

And there'd be some testing involved, too.  This is definitely not trivial...

JH
JH 2021-04-08

I have been writing Solidworks macros on an off as needed for the last 10 years, so I am pretty experienced with the API. I usually try to see if someone has already done something similar that I can leverage, but I haven't found anything close for this macro.

FL
FL 2021-04-08

It maybe easier to write a macro to insert fastener with correct length.

JB
JB 2021-04-08

Joshua Hutton wrote:

I have been writing Solidworks macros on an off as needed for the last 10 years, so I am pretty experienced with the API. I usually try to see if someone has already done something similar that I can leverage, but I haven't found anything close for this macro.

I don't know of anything existing.

Along the lines of what Frederick stated, I wrote some code a long time ago to attempt to insert the correct fasteners in the first place.

This task is pretty daunting.

First, you have to figure out how to determine if something is a fastener.  You already stated that you don't use Toolbox.  Not knowing anything about your models, we can't really suggest much.  Going by filename or some custom property and force everyone by policy to use the right files would be one way.  But if someone downloads stuff from McMaster, good luck.

Then you have to find the thru holes associated with each fastener.  If your fastener is always mated to the hole, you may be able to analyze the mates associated with the fastener.  However, this wouldn't work if you use feature driven component patterns (which you should for efficient modeling).  Maybe you can just find all the fasteners that are actually mated and assume that patterned instances are OK since they should match the seed...

Now you have to analyze the geometry of the thru hole.  Hopefully you can figure out how to find the cylindrical face of the hole and then find its length.  I think when I was doing it I got lazy and divided the area by the circumference (both easily acccessible values) to get length.  

Now you have to somehow find the tapped hole associated with the fastener.  Maybe you can use the fastener head/origin and axis with RayIntersections to find the bottom of a blind tap.  Not sure I have an idea at all how to find the tap hole if it's tapped thru.  

FL
FL 2021-04-08

First find a fastener.

Then find the face on the head.

Find face at end of thread.

Find face touching the head.

Find all the parts the fastener pass through.

Decide which one is at the end.

Calculate thickness of all those part.

Check length of the fastener.

Make sure it has at least 1x dia engagement.

Pretty simple, right?

MP
MP 2021-04-08

Frederick Law wrote:

First find a fastener.

Then find the face on the head.

Find face at end of thread.

Find face touching the head.

Find all the parts the fastener pass through.

Decide which one is at the end.

Calculate thickness of all those part.

Check length of the fastener.

Make sure it has at least 1x dia engagement.

 

Pretty simple, right?

Yeah, I don't know what ‌ was going on about...This should be pretty simple...

JH
JH 2021-04-08

I agree with the procedure. I can find all of the fasteners by traversing the feature tree for items that have the custom property IsFastener set to 1. The parts that I don't know how to do is identify particular faces like the face on the head of the fastener and the faces of the mating pieces without manually selecting them. Any thoughts or similar examples?

FL
FL 2021-04-08

Joshua Hutton wrote:

The parts that I don't know how to do is identify particular faces like the face on the head of the fastener and the faces of the mating pieces without manually selecting them. Any thoughts or similar examples?

You might need to add planes in the fastener with specific name so you can get them from API.

I don't know how to find all the parts the bolt go through.

Hence I'll do the macro for user to mate the bolt and calculate the length.

JB
JB 2021-04-08

You have not stated any level of current API knowledge.  However, this one is complex enough that, unless you are already pretty experienced in the SW API, it's going to be most cost-efficient for you to pay someone to do it.  It probably won't be particularly cheap, but to go from zero to the ability level required by this macro would probably take 2 months full-time study for someone with a knack for coding.  And then you'd have to actually write it.