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: 

Level of Detail macro

4 REPLIES 4
Reply
Message 1 of 5
NEGMEC
2093 Views, 4 Replies

Level of Detail macro

Hi

 

Can anyone help by providing a VBA script to to change the Level of display for an assembly AND ALL its sub-asseemblies automatically to an LOD that I called ilogic when opening the file.

I am running Inventor 2011 and I need this as it is creating some problems with the ilogic rules when they run....

 

Thanks for your help

4 REPLIES 4
Message 2 of 5
herrwolf1
in reply to: NEGMEC

Here is some .NET code. You will have to convert it to VBA. LOD works kind of funny from what I can tell. You must first set the LOD of the top assy and all sub-assy's and save the model. All my attempts to set the individual sub-assy's LOD result in an Inventor application crash.

 

 

        Dim oMyDoc As Inventor.AssemblyDocument
        oMyDoc = invApp.ActiveDocument

        ' Set the Level Of Detail...
        Dim oRepMgr As Inventor.RepresentationsManager
        oRepMgr = oMyDoc.ComponentDefinition.RepresentationsManager

        Dim oMasterLOD As Inventor.LevelOfDetailRepresentation
        oMasterLOD = oRepMgr.LevelOfDetailRepresentations.Item('iLogic")

        oMasterLOD.Activate()

 

 

Message 3 of 5
herrwolf1
in reply to: herrwolf1

Also, here is an iLogic rule that I place in the sub assemblies that require component suppression

 

Sub SetLOD(ByVal myLOD As String)
	ThisApplication = InventorVb.Application
	
	oMyDoc = ThisDoc.ModelDocument
	
	' Set the LOD to Master
------------------------------------------------------------------------------
	Dim oRepMgr As RepresentationsManager
    oRepMgr = oMyDoc.ComponentDefinition.RepresentationsManager

    Dim oMasterLOD As LevelOfDetailRepresentation
    oMasterLOD = oRepMgr.LevelOfDetailRepresentations.Item(myLOD)

    oMasterLOD.Activate()
	
	RuleParametersOutput() ' use this before DocumentUpdate
	InventorVb.DocumentUpdate() ' Update now
End Sub

 

 

Message 4 of 5
NEGMEC
in reply to: NEGMEC

Thanks herrwolf1

 

do you know how to change the LOD using i-logic?

Message 5 of 5
MegaJerk
in reply to: NEGMEC

For iLogic Code to change the LoD I use the following (which is of course still VB , but it runs inside of an ilogic rule!)

 

 

 

'''We need to make sure the LOD is set correctly : 

'''
'''

'''
'''Side note

'''Public Enum LevelOfDetailEnum
''' kMasterLevelOfDetail = 56065

'''kAllComponentsSuppressedLevelOfDetail = 56066
'''kAllPartsSuppressedLevelOfDetail = 56067

'''kAllContentSuppressedLevelOfDetail = 56068
'''kSandboxLevelOfDetail = 56069

'''kTransientLevelOfDetail = 56070
'''kSubstituteLevelOfDetail = 56071

'''kCustomLevelOfDetail = 56072
'''kLastActiveLevelOfDetail = 56073

'''End Enum



Dim doc as AssemblyDocument = ThisDoc.Document

If doc.ComponentDefinition.RepresentationsManager.ActiveLevelOfDetailRepresentation.LevelOfDetail <> 56072 'LevelOfDetailEnum.kMasterLevelOfDetail Then


Dim oLOD As LevelOfDetailRepresentation

Dim oAsmCompDef As ComponentDefinition

oAsmCompDef = doc.ComponentDefinition

oLOD = oAsmCompDef.RepresentationsManager.LevelOfDetailRepresentations.Item("ilogic")

oLOD.Activate(True)

End If

That will change the main level of detail, but I'm sure you could throw it into the rules of your subassemblies and get similar results (maybe 😞 ). Use triggers to make it run on document open!



If my solution worked or helped you out, please don't forget to hit the kudos button 🙂
iLogicCode Injector: goo.gl/uTT1IB

GitHub

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

Post to forums  

Autodesk Design & Make Report