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: 

In assembly or not

2 REPLIES 2
SOLVED
Reply
Message 1 of 3
mk92
224 Views, 2 Replies

In assembly or not

Hello,

 

ist there a way to check if a assembly is open alone or in an other assembly?

 

I need to switch the level of detail after opening the assembly. But these assemblys can be i another assembly which is also switching the level of detail.

And then Inventor shows up an error message.

 

The Code is:

Dim doc as AssemblyDocument = ThisDoc.Document 

Dim oLOD As LevelOfDetailRepresentation 

Dim oAsmCompDef As ComponentDefinition 
oAsmCompDef = doc.ComponentDefinition

Try
    oLOD = oAsmCompDef.RepresentationsManager.LevelOfDetailRepresentations.Item("iLogic").Activate(True)
Catch
Dim nLOD As LevelOfDetailRepresentation
    nLOD = oAsmCompDef.RepresentationsManager.LevelOfDetailRepresentations.Add("iLogic")
    oLOD = nLOD
Finally
    oLOD = oAsmCompDef.RepresentationsManager.LevelOfDetailRepresentations.Item("iLogic").Activate(True)
End Try

 

 

2 REPLIES 2
Message 2 of 3
ekinsb
in reply to: mk92

I think you should be able to compare the document you got back from ThisDoc.Document to the Application.ActiveDocument.  Even if another document has been in-place activated within an assembly, the top-level assembly remains the active document.  You can compare them using the Is statement like:

 

If ThisDoc.Document Is ThisApplication.ActiveDocument Then
	MsgBox("Top-Level assembly is being edited.")
Else
	MsgBox("A component in the assembly is being edited")
End If

 


Brian Ekins
Inventor and Fusion 360 API Expert
Mod the Machine blog
Message 3 of 3
mk92
in reply to: ekinsb

I'll try it!

 

But in the meantime i had the idea to suppress the rule in the subassembly from the Top-Level Assembly.

Is this possible?

 

It should also solve my problem!

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

Post to forums  

Autodesk Design & Make Report