"Feature.setThread" function not working with NPT threads

"Feature.setThread" function not working with NPT threads

sdlF9MME
Participant Participant
711 Views
7 Replies
Message 1 of 8

"Feature.setThread" function not working with NPT threads

sdlF9MME
Participant
Participant

Hi.

Im trying to write a program that will automatically modifiy a part (hydraulic fluid port) depending on what type of port you want and what size (OSB, NPT, BSP, etc...) using iLogic. To modify the internal threads, im using the "feature.setThread" function, because the type of thread can change every time. The code runs fine for AINSI unified threads, but I cant get it to work with NPT threads. I always get this error message

ilogic1.png

At the moment, the line of code responsible looks like this:

Feature.SetThread("Thread2", "NPT","1/4-18 NPT","")

I have tried using  "1/4", 1/4, "1/4 - 18",  and many other variations but nothing seems to work. I tried following the following recommendation:

ilogic2.png

So I use "" for the thread class but I have no idea what they mean my "use thread size instead of designation", since "1/4" doesn't work. Anybody has insight on how to use this functiuon with NPT threads? Thanks

0 Likes
Accepted solutions (1)
712 Views
7 Replies
Replies (7)
Message 2 of 8

A.Acheson
Mentor
Mentor

Hi @sdlF9MME 

Have you tried using capture snippet for this feature? Place a NPT thread feature and then in the ilogic editor find the feature and right click and add. The sequence of the designations might be out of order in your current code. 

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
0 Likes
Message 3 of 8

sdlF9MME
Participant
Participant
i used the snippet tool on the NPT feature in a separate part and it is exactly the same code in both cases. Only it works in one case but not on the other. Im thinking maybe it has something to do with the geometry of the part. Looking into it.
0 Likes
Message 4 of 8

A.Acheson
Mentor
Mentor
Accepted solution

Hi @sdlF9MME 

I have just tried this out and the Set Thread function is malfunctioning at least in Inv 2020. If you do not change the size away from what it is currently nothing happens. In this example the current size is 1/8 and I just want to change the thread type from "NPT for PVC Pipe and Fitting" to "NPT". To achieve this I set the size to 1/4 then separately back to 1/8

Feature.SetThread("Hole1", "NPT","1/4", "")
Feature.ThreadDesignation("Hole1") = "1/8"

 

And also it is failing changing from a straight like "ANSI Unified Thread" thread to a tapered thread. This isn't possible it seems with the current function. 

 

Here is the API route which is more robust, See these links from the help section to define either the specific tapered tap info or the more generic hole tap info line and set the holefeature Tap Info. 

 

  Dim partDoc As PartDocument = ThisApplication.ActiveDocument

   Dim def As PartComponentDefinition = partDoc.ComponentDefinition

   ' Get the first thread feature
   Dim holeFeat As HoleFeature = def.Features.HoleFeatures("Hole1")

   ' Define the tapered tap information.
   'Dim tapInfo As TaperedThreadInfo = def.Features.HoleFeatures.CreateTaperedTapInfo(True, "NPT", "1/4")
   
   ' Define the generic tap information.
   Dim tapInfo As HoleTapInfo = def.Features.HoleFeatures.CreateTapInfo(True, "NPT", "1/8","",True,)
   
   ' Set the tap information.							
   holeFeat.TapInfo = tapInfo 

 

 

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
Message 5 of 8

sdlF9MME
Participant
Participant
Trying your method right now. Will get back to you
0 Likes
Message 6 of 8

A.Acheson
Mentor
Mentor

Hi @chandra.shekar.g 

Would it be possible to check the functionality of the ilogic "Feature.SetThread" function? It seems to not be working all that great. 

 

  • The function fails to work if one of the two variables has allready been set.  Variables are change size or type.
  • The function fails to work when changing type of thread from straight to taper. 

The API method work as expected. 

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
Message 7 of 8

chandra.shekar.g
Autodesk Support
Autodesk Support

@A.Acheson,

 

Can you please provide non confidential source iLogic code to investigate?

 

Thanks and regards,


CHANDRA SHEKAR G
Developer Advocate
Autodesk Developer Network



0 Likes
Message 8 of 8

A.Acheson
Mentor
Mentor

Hi @chandra.shekar.g 

Thanks for the response.

Step 1 place a holeand name Hole1 and set an initial straight thread of any size and type.

Step2. Set to tapered thread by running rule

Feature.SetThread("Hole1", "NPT","1/4", "")
MessageBox.Show("Changing thread type"
Feature.SetThread("Hole1", "NPT for PVC Pipe and Fitting","1/4", "")

 You will find an error changing from straight to tapered thread and if trying to change type with same size in the last line of the rule. 

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
0 Likes