Inventor Customization

Inventor Customization

Reply
Member
3 Posts
0 Kudos
Registered: ‎05-16-2010
Post 1 of 5

Level of Detail macro

679 Views, 4 Replies
04-18-2011 01:57 AM

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

Valued Contributor
54 Posts
0 Kudos
Registered: ‎08-21-2008
Post 2 of 5

Re: Level of Detail macro

04-18-2011 09:49 AM 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()

 

 

Valued Contributor
54 Posts
0 Kudos
Registered: ‎08-21-2008
Post 3 of 5

Re: Level of Detail macro

04-18-2011 09:52 AM 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

 

 

Member
3 Posts
0 Kudos
Registered: ‎05-16-2010
Post 4 of 5

Re: Level of Detail macro

04-24-2011 03:37 PM in reply to: NEGMEC

Thanks herrwolf1

 

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

Valued Mentor
286 Posts
187 Kudos
Registered: ‎01-26-2011
Post 5 of 5

Re: Level of Detail macro

04-25-2011 09:32 AM 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 :smileysad: ). Use triggers to make it run on document open!

--------------------------------------------------------------------------------------

If my solution seems to remedy your problem, please press the Accept Solution button, -
as it increases my power levels and will eventually help to elevate me towards outer space.

Check out my iLogic injection tool here : http://goo.gl/ce1Qg
--------------------------------------------------------------------------------------
Post to the Community

Have questions about Autodesk products? Ask the community.

New Post