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: 

make BOM inseparable with ilogic and custom property

5 REPLIES 5
SOLVED
Reply
Message 1 of 6
morrenengineering
306 Views, 5 Replies

make BOM inseparable with ilogic and custom property

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

 

5 REPLIES 5
Message 2 of 6

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 - Leading design engineer

LinkedIn | My free Inventor Addin | My Repositories

Did you find this reply helpful ? If so please use the Accept as Solution/Like.

EESignature

Message 3 of 6

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.

Message 4 of 6

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 - Leading design engineer

LinkedIn | My free Inventor Addin | My Repositories

Did you find this reply helpful ? If so please use the Accept as Solution/Like.

EESignature

Message 5 of 6

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

 

Message 6 of 6

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.

Post to forums  

Technology Administrators


Autodesk Design & Make Report