Apply Idealizations to Individual Parts in Assembly Using iLogic

Apply Idealizations to Individual Parts in Assembly Using iLogic

charlesdwilliams03
Explorer Explorer
219 Views
0 Replies
Message 1 of 1

Apply Idealizations to Individual Parts in Assembly Using iLogic

charlesdwilliams03
Explorer
Explorer

Hello everyone,

I am trying to automate the process of applying idealizations to individual parts in an assembly based on their material properties using iLogic in Autodesk Inventor. I have written code that loops through each part in the assembly, checks its material, and then applies an idealization accordingly.

Here is a simplified version of the code:

 

Sub ApplyIdealizationsBasedOnMaterials()
' Get the assembly document
Dim oAsm As AssemblyDocument
oAsm = ThisApplication.ActiveDocument

' Loop over the assembly
For Each oSubAsm As ComponentOccurrence In oAsm.ComponentDefinition.Occurrences
' Ensure it is a part document
If oSubAsm.DefinitionDocumentType = kPartDocumentObject Then
Dim oSubPart As PartDocument
oSubPart = oSubAsm.ReferencedDocumentDescriptor.ReferencedDocument

' Get the material of the part
Dim partMaterial As Material
partMaterial = oSubPart.ComponentDefinition.Material

' Define the idealization based on the material
Dim idealizationId As String
Dim materialId As String
If partMaterial.Name = "Material 9" Then
materialId = "5"
idealizationId = "1"
Else ' Assume Steel ASTM A36
materialId = "3"
idealizationId = "2"
End If

' Construct the XML command for idealization
Dim strCmdForNewIdealization As String
strCmdForNewIdealization = "<NewIdealization Name=""Auto" & partMaterial.Name & """ ID=""" & idealizationId & """ Type=""2"" AddToFEModel=""1"" Color=""16711680"" CoordinateSystemID=""1"" MaterialID=""" & materialId & """ EntitiesCount=""0""/>"

' Run the command
AddinObj.Run(strCmdForNewIdealization)
End If
Next
End Sub

 

The issue I'm encountering is that each time the NewIdealization command is executed, it appears to apply the idealization to the entire assembly model, not just the individual part. Consequently, the final assembly ends up with the idealization of the last part in the loop, and I receive a warning message about parts containing multiple idealizations.

I'm wondering if there is a way to apply idealizations to individual parts rather than the whole assembly when running the NewIdealization command. I'd appreciate any guidance or suggestions on how to approach this.

Thank you in advance for your help!

0 Likes
220 Views
0 Replies
Replies (0)