Hello,
Do one of you know how i can check with ilogic if the hole feature has thread?
I want a code that checks if the hole is a normal hole or a threaded hole.
Thanks for the help!
Solved! Go to Solution.
Solved by JelteDeJong. Go to Solution.
hi, does this work for you?
[iLogic]
Dim feature As PartFeature = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kPartFeatureFilter, "Select a hole") If (feature.Type <> ObjectTypeEnum.kHoleFeatureObject) Then MsgBox("This is not an hole feature") End If Dim hole As HoleFeature = feature Dim info As HoleTapInfo = hole.TapInfo If (info Is Nothing) Then MsgBox("This hole is not threaded") Else MsgBox("This hole is thread: " + info.ThreadDesignation) End If
Jelte de Jong
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
Blog: hjalte.nl - github.com
Hello,
Not working like i want.
I explained myself bad i think.
I want the rule to be automaticaly so it goes true all the PartFeatures. And i detect if its a hole and a cut or extrude and does something then.
With your rule i need to select a hole. I need for example the rule below when the hole is thread then i = i + 1. But when i try to adapt your code it's not working.
For Each oFeature In oFeatures 'check if its a hole If TypeOf oFeature Is ExtrudeFeature And oFeature.Suppressed = False And oFeature.Name.Contains("Hole") Then 'increment one i = i + 1 End If Next
Do you just want to count how many faces in the part has threads?
Like this?
Dim pDoc As PartDocument = ThisDoc.Document Dim i As Integer For Each oBod As SurfaceBody In pDoc.ComponentDefinition.SurfaceBodies For Each oFace As Face In oBod.Faces If oFace.ThreadInfos IsNot Nothing Then i += 1 Next Next Messagebox.Show("Threaded faces in part: " & i, "Number of threads")
Jhoel Forshav
Download my free Inventor Addin - Hole Projector
LinkedIn | Ideas | Contributions | Blog posts | Website
If you need to find the features to changed them. then you could also use this code:
Dim doc As PartDocument = ThisDoc.Document Dim features = doc.ComponentDefinition.Features Dim numberOfThreadedHoleFeatures As Integer = 0 For Each hole As HoleFeature In features.HoleFeatures Dim info As HoleTapInfo = hole.TapInfo If (info IsNot Nothing) Then numberOfThreadedHoleFeatures = numberOfThreadedHoleFeatures + 1 ' Your hole changing code go's here End If Next MsgBox("Number of holes with thread: " & numberOfThreadedHoleFeatures) ' you can skip this loop if you just want to count the number of tread features For Each thread As ThreadFeature In features.ThreadFeatures ' Your thread changing code go's here Next MsgBox("Number of threadfeatures (on a extrude or cut feature): " _ & features.ThreadFeatures.Count)
Jelte de Jong
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
Blog: hjalte.nl - github.com
Can i ask you if you want to take a look at an other problem? In this problem i want to have for example a assembly painted and then i need the color placed in a custom property inside this assembly so that when i make a drawing i can get the color on the drawing.
I don't want to paint the parts because in real life you first assembly the welding assembly and after it goes to the painting stage. I hope you can help me.
I have this rule for placing the color inside a property inside a part:
Dim oDoc As Document oDoc = ThisDoc.Document If ThisDoc.Document.ActiveAppearance.DisplayName.Contains("RAL") then iProperties.Value("Custom", "Color") = Left(ThisDoc.Document.ActiveAppearance.DisplayName, 8) End If
Here is the link with my question:
Can't find what you're looking for? Ask the community or share your knowledge.