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: 

Assembly within assembly Detection

4 REPLIES 4
SOLVED
Reply
Message 1 of 5
phillip.shields
494 Views, 4 Replies

Assembly within assembly Detection

I would like to see if there is a routine that allows my iLogic code to detect if my assembly contains another assembly within it. If my assebly contains assemblies then I don't want "MyRule" to run. Else if it does then I want "MyRule" to run.

4 REPLIES 4
Message 2 of 5
Gruff
in reply to: phillip.shields

Write a function that returns a boolean.

 

in the function loop through the top level document's referencedDocuments property.

If any end in ".iam" stop looping and return a true.other wise return a false.

 

If you need to check part files as well then you will need to check each part files referencedDocuments Count property.  If it is > 0 then return true otherwise false.

Message 3 of 5
jdkriek
in reply to: phillip.shields

Something like this:

 

Dim oDoc As Document = ThisDoc.Document
Dim oRefDoc As Document
Dim AsmFound As Boolean
For Each oRefDoc In oDoc.AllReferencedDocuments
	If oRefDoc.DocumentType = kAssemblyDocumentObject Then
		AsmFound = True
		Exit For
	End If
Next
If AsmFound = False Then
	iLogicVb.RunRule("MyRule")
End If
Jonathan D. Kriek
MFG Solutions Engineer
KETIV Technologies, Inc.


Message 4 of 5
Gruff
in reply to: phillip.shields

Actually Jonathon He only needs to check the references under the top level, not the all the referenced in his assembly.  That is why I suggested ReferencedDocument instead of AllReferencedDocuments.

 

Just as you are using an If..Exit in your loop when there is no point in continuing further.

Message 5 of 5
phillip.shields
in reply to: jdkriek

Thanks that worked out great

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

Post to forums  

Autodesk Design & Make Report