Inventor Customization

Reply
Member
NEGMEC
Posts: 3
Registered: ‎05-16-2010
Message 1 of 5 (611 Views)

Level of Detail macro

611 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
herrwolf1
Posts: 54
Registered: ‎08-21-2008
Message 2 of 5 (601 Views)

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
herrwolf1
Posts: 54
Registered: ‎08-21-2008
Message 3 of 5 (599 Views)

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
NEGMEC
Posts: 3
Registered: ‎05-16-2010
Message 4 of 5 (567 Views)

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?

Mentor
MegaJerk
Posts: 266
Registered: ‎01-26-2011
Message 5 of 5 (552 Views)

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
--------------------------------------------------------------------------------------

You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.

Need installation help?

Start with some of our most frequented solutions to get help installing your software.

Ask the Community


Inventor Exchange Apps

Created by the community for the community, Autodesk Exchange Apps for Autodesk Inventor helps you achieve greater speed, accuracy, and automation from concept to manufacturing.

Connect with Inventor

Twitter

Facebook

Blogs

Pinterest

Youtube