Hi,
My assembly ' s are labelled with a custom property, called "art", which means article. For some lists, the welding must be inseparable. I made for this an ilogic rule, but it works, but it becomes not inseparable. I thick it is some small, can someone help me?
Dim oAsmDoc As AssemblyDocument oAsmDoc = ThisApplication.ActiveDocument oAsmName = ThisDoc.FileName(False) 'without extension Dim oRefDocs As DocumentsEnumerator oRefDocs = oAsmDoc.AllReferencedDocuments Dim oRefDoc As Document 'work the referenced models For Each oRefDoc In oRefDocs Dim oCurFile As Document oCurFile = ThisApplication.Documents.Open(oRefDoc.FullFileName, True) Dim art1 As Inventor.Property art1 = Nothing Try art1 = iProperties.Value("Custom", "art") If art1 = "WEL" Then oCurFile.ComponentDefinition.BOMStructure = BOMStructureEnum.kInseparableBOMStructure End If Catch 'MessageBox.Show("Error processing " & oCurFileName, "ilogic") End Try oCurFile.Close Next
Solved! Go to Solution.
Solved by morrenengineering. Go to Solution.
Hello. If I understood you correctly, then this should help you:)
Dim oDoc As Document = ThisApplication.ActiveDocument If TypeOf oDoc Is AssemblyDocument Then Dim oAssDoc As AssemblyDocument = oDoc For Each oRefDoc As Document In oAssDoc.ReferencedDocuments If TypeOf oRefDoc Is AssemblyDocument Then For Each art As Inventor.Property In oRefDoc.PropertySets.Item("Inventor User Defined Properties") If art.Value = "WEL" Then oRefDoc.ComponentDefinition.BOMStructure = BOMStructureEnum.kInseparableBOMStructure oRefDoc.SubType = "{28EC8354-9024-440F-A8A2-0E0E55D635B0}" End If Next End If Next End If
Andrii Humeniuk - CAD Coordinator, Autodesk Certified Instructor
LinkedIn | My free Inventor Addin | My Repositories
Did you find this reply helpful ? If so please use the Accept as Solution/Like.
Hello, it does give an error (in dutch):
Error on line 7 in rule: BOM-inseperatable, in document: C111.iam
De conversie van tekenreeks WEL naar type Double is ongeldig.
I had an old code, it works, but I would that it would nog depends on the filename, but on the "art" custom field.
The old code is attached.
Hello. Please try this:
Dim oDoc As Document = ThisApplication.ActiveDocument If TypeOf oDoc Is AssemblyDocument Then Dim oAssDoc As AssemblyDocument = oDoc For Each oRefDoc As Document In oAssDoc.ReferencedDocuments If TypeOf oRefDoc Is AssemblyDocument Then For Each oProp As Inventor.Property In oRefDoc.PropertySets.Item("Inventor User Defined Properties") If oProp.Name = "art" And oProp.Value = "WEL" Then If oRefDoc.ComponentDefinition.BOMStructure <> BOMStructureEnum.kInseparableBOMStructure Then oRefDoc.ComponentDefinition.BOMStructure = BOMStructureEnum.kInseparableBOMStructure End If End If Next End If Next End If
Andrii Humeniuk - CAD Coordinator, Autodesk Certified Instructor
LinkedIn | My free Inventor Addin | My Repositories
Did you find this reply helpful ? If so please use the Accept as Solution/Like.
Hi Andrii,
I can't accept your solution because there was a small mistake in it. Oprop.value had to become oprop.expression. Anyway, thank you very much for this great code and good help.
Dim oDoc As Document = ThisApplication.ActiveDocument If TypeOf oDoc Is AssemblyDocument Then Dim oAssDoc As AssemblyDocument = oDoc For Each oRefDoc As Document In oAssDoc.ReferencedDocuments If TypeOf oRefDoc Is AssemblyDocument Then For Each oProp As Inventor.Property In oRefDoc.PropertySets.Item("Inventor User Defined Properties") If oProp.Name = "art" And oProp.Expression = "WEL" Then If oRefDoc.ComponentDefinition.BOMStructure <> BOMStructureEnum.kInseparableBOMStructure Then oRefDoc.ComponentDefinition.BOMStructure = BOMStructureEnum.kInseparableBOMStructure End If End If Next End If Next End If
I've been working with the code for a day now, but it still doesn't do what I expected. He only changes it at the current level and not a level deeper. My first option did. Is that a simple line in the program?
Can't find what you're looking for? Ask the community or share your knowledge.