Ilogic, creating a groove for the circlip

Ilogic, creating a groove for the circlip

vyivanchikov
Enthusiast Enthusiast
231 Views
2 Replies
Message 1 of 3

Ilogic, creating a groove for the circlip

vyivanchikov
Enthusiast
Enthusiast

Hello everybody!
I am writing to inquire about the possibility of your assistance in debugging a program on ILOGIC. Specifically, I am seeking help in creating an add-on that builds a groove for a retaining ring. I would be grateful for any assistance with debugging a programme on ilogic. I am working on creating an add-on that will build a groove for a retaining ring. In the assembly, I set the retaining ring, then the programme starts, I select the cylindrical groove, then specify the retaining ring, and... that's it.
I am relatively new to this area of programming, specifically the integration of AI, and I am keen to understand the nuances involved.
' === Selection of the cylindrical face ===
Dim selectedFace As Face

Try
selectedFace = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kPartFaceFilter, "Select a cylindrical face for groove insertion")
Catch
MessageBox.Show("Selection cancelled.", "ESC")
Return
End Try

If selectedFace Is Nothing OrElse selectedFace.SurfaceType <> SurfaceTypeEnum.kCylinderSurface Then
MessageBox.Show("A non-cylindrical face has been selected.’, “Error”)
Return
End If

Dim faceProxy As FaceProxy = selectedFace
Dim occ As ComponentOccurrence = faceProxy.ContainingOccurrence

If occ Is Nothing Then
MessageBox.Show(‘Component not found.’, ‘Error’)
Return
End If

If Not occ.DefinitionDocumentType = DocumentTypeEnum.kPartDocumentObject Then
MessageBox.Show(‘The selected component is not a part.’, ‘Error’)
Return
End If

' === Step 2: Enter component editing ===
occ.Edit()

' === Step 3: Select the size of the retaining ring (DIN 471) ===
Dim ringSizes() As String = {"D20", "D25", "D30", "D35", "D40"}
Dim selectedSize As String = InputListBox(‘Select retaining ring size (DIN 471):", ringSizes, ringSizes(0), ‘Size’, “Ring”)

If selectedSize = "" Then
MessageBox.Show(‘Size not selected.’, “Cancel”)
occ.ExitEdit(13443)
Return
End If

' === Step 4: Assign parameters by size ===
Dim D As Double, b As Double, t As Double

Select Case selectedSize
Case "D20" : D = 19.8 : b = 1.1 : t = 0.55
Case "D25" : D = 24.8 : b = 1.1 : t = 0.55
Case "D30" : D = 29.8 : b = 1.4 : t = 0.65
Case "D35" : D = 34.8 : b = 1.4 : t = 0.65
Case "D40" : D = 39.8 : b = 1.75 : t = 0.85
Case Else
MessageBox.Show(‘Unknown size.’, ‘Error’)
occ.ExitEdit(13443)
Return
End Select

' === Step 5: Check iFeature file ===
Dim iFeaturePath As String = "C:\iFeatures\GrooveDIN471.ide"
If Not System.IO.File.Exists(iFeaturePath) Then
MessageBox.Show(‘iFeature file not found: ‘ & iFeaturePath, “Error”)
occ.ExitEdit(13443)
Return
End If

' === Step 6: Get the active part document ===
Dim oPartDoc As PartDocument = ThisApplication.ActiveEditDocument

' === Step 7: Create iFeature and set parameters ===
Dim iFeatDef As iFeatureDefinition
iFeatDef = oPartDoc.ComponentDefinition.iFeatures.CreateiFeatureDefinition(iFeaturePath)

iFeatDef.InputParameters.Item("D").Value = D
iFeatDef.InputParameters.Item("b").Value = b
iFeatDef.InputParameters.Item("t").Value = t

' Binding to the selected cylindrical face
If iFeatDef.InputEntities.Count > 0 Then
iFeatDef.InputEntities.Item(1).InputEntity = faceProxy
End If

' Insert iFeature
oPartDoc.ComponentDefinition.iFeatures.Add(iFeatDef)

' === Step 8: Exit editing and finish ===
occ.ExitEdit(13443) ' kToParent

MessageBox.Show(‘Groove successfully inserted for ring ‘ & selectedSize, “Done”)
Error 70:
@public member 'iFeatures' on type 'PartComponentDefinition' not found.@@

how to deal with it?
Inventor 2023, SP4, WIN10 22H

0 Likes
232 Views
2 Replies
Replies (2)
Message 2 of 3

bradeneuropeArthur
Mentor
Mentor

Would using an I-feature of Inventor not easier to use in your programming?

Regards,

Arthur Knoors

Autodesk Affiliations & Links:
blue LinkedIn LogoSquare Youtube Logo Isolated on White Background


Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:
Drawing List!|
Toggle Drawing Sheet!|
Workplane Resize!|
Drawing View Locker!|
Multi Sheet to Mono Sheet!|
Drawing Weld Symbols!|
Drawing View Label Align!|
Open From Balloon!|
Model State Lock!
Posts and Ideas:
My Ideas|
Dimension Component!|
Partlist Export!|
Derive I-properties!|
Vault Prompts Via API!|
Vault Handbook/Manual!|
Drawing Toggle Sheets!|
Vault Defer Update!

! For administrative reasons, please mark a "Solution as solved" when the issue is solved !


 


EESignature

0 Likes
Message 3 of 3

vyivanchikov
Enthusiast
Enthusiast

Thanks for the reply!
Of course, it might be easier.
I wish it were simpler. Why not?)
Inventor has a function to auto-select bolts and nuts when we use the component library? Why don't companies build such a function in by default, inserting grooves grooves etc.?
Yes, I am subscribed to you on another social network, I follow your new products for inventor

0 Likes