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: 

iLogic external rule for parts and assembly

1 REPLY 1
SOLVED
Reply
Message 1 of 2
gert-leonvanlier
306 Views, 1 Reply

iLogic external rule for parts and assembly

I am having issues with one of my external rules and I can't figure out why. The rule is working perfectly in a part document. This part becomes an asset for the Factory Design Suite. When I place this asset then into my layout I get the following error:

 

Inventor_TtU2r0htPd.png

 

 

 

 

 

 

 

 

 

 

 

 

I think it has something to do with the ComponentDefinition difference between a part and assembly, but I don't know how to solve this.

 

The rule is external because every asset in my library is using the same rule.

 

This is the code:

Dim oDoc As Inventor.Document = ThisApplication.ActiveDocument
Dim oCompDef As PartComponentDefinition = oDoc.ComponentDefinition
Dim InvApp As Application = ThisApplication
Dim oAnnotation3D As ModelAnnotation

i = 1
For Each ModelAnnotation In oCompDef.ModelAnnotations
	oAnnotation3D = oCompDef.ModelAnnotations.Item(i)
	If SharedVariable("State") = "Dimensions" And InStr(oAnnotation3D.Name, "Dimension") Then
		If oAnnotation3D.HealthStatus.value__ <> 11778 Then
			oAnnotation3D.Visible = False
		Else oAnnotation3D.Visible = True
		End If
	Else If InStr(oAnnotation3D.Name, "Dimension") Then
		oAnnotation3D.Visible = False
	End If	
i = i + 1
Next

A part that uses the rule and is working fine on its own is also attached.

1 REPLY 1
Message 2 of 2

I found a solution:

Sub Main()
	Dim topDoc As Document = ThisDoc.Document
	ProcessDoc(topDoc)
	
	For Each doc As Document In topDoc.AllReferencedDocuments
		ProcessDoc(doc)
	Next
End Sub

Sub ProcessDoc(doc As Document)
	If (doc.DocumentType = DocumentTypeEnum.kPartDocumentObject) Then
		Dim partDoc As PartDocument = doc
		ProcessPart(partDoc)
	End If
End Sub

Sub ProcessPart(partDoc As PartDocument)
	Dim oCompDef As PartComponentDefinition = partDoc.ComponentDefinition
	Dim InvApp As Application = ThisApplication
	Dim oAnnotation3D As ModelAnnotation
	i = 1
	For Each ModelAnnotation In oCompDef.ModelAnnotations
		oAnnotation3D = oCompDef.ModelAnnotations.Item(i)
		If SharedVariable("State") = "Dimensions" And InStr(oAnnotation3D.Name, "Dimension") Then
			If oAnnotation3D.HealthStatus.value__ <> 11778 Then
				oAnnotation3D.Visible = False
			Else oAnnotation3D.Visible = True
			End If
		Else If InStr(oAnnotation3D.Name, "Dimension") Then
			oAnnotation3D.Visible = False
		End If	
	i = i + 1
	Next
	
End Sub

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

Post to forums  

Technology Administrators


Autodesk Design & Make Report