Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

check if hole has thread

5 REPLIES 5
SOLVED
Reply
Message 1 of 6
Charlies_3D_T
1975 Views, 5 Replies

check if hole has thread

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!

5 REPLIES 5
Message 2 of 6
JelteDeJong
in reply to: Charlies_3D_T

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.

EESignature


Blog: hjalte.nl - github.com

Message 3 of 6
Charlies_3D_T
in reply to: JelteDeJong

@JelteDeJong 

 

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

 

Message 4 of 6

Hi @Charlies_3D_T 

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")
Message 5 of 6
JelteDeJong
in reply to: Charlies_3D_T

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.

EESignature


Blog: hjalte.nl - github.com

Message 6 of 6
Charlies_3D_T
in reply to: JelteDeJong

@JelteDeJong 

 

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: 

 

https://forums.autodesk.com/t5/inventor-customization/how-to-add-appearance-from-an-assembly-to-the-...

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

Post to forums  

Autodesk Design & Make Report