Setting a default Level of Detail

Setting a default Level of Detail

Anonymous
Not applicable
751 Views
2 Replies
Message 1 of 3

Setting a default Level of Detail

Anonymous
Not applicable

I know there's the setting in the Tools/Application Options/File dialogue that allows you to set a system wide setting of which LOD that opens each time you activate an assembly.

 

But what about a file specific setting where you are able to set a specific LOD that always opens for that specific assembly file? Or will that conflict with the system wide settings?

 

Granted, I know Inventor will open the last saved LOD (based on that system wide setting), but my client has users that, for a lack of better terms, are not paying attention or being aware of what LOD they are opening and thus editing the wrong LOD, etc. So now they want me to figure out a way of solving this.

 

Is there a way of doing this with a VBA or iLogic script? If so, can someone please help me out?

 

Thanks in advance

0 Likes
752 Views
2 Replies
Replies (2)
Message 2 of 3

mrattray
Advisor
Advisor
Dim doc as AssemblyDocument = ThisDoc.Document  
If doc.ComponentDefinition.RepresentationsManager.ActiveLevelOfDetailRepresentation.LevelOfDetail <> 56072 Then
Dim oLOD As LevelOfDetailRepresentation
Dim oAsmCompDef As ComponentDefinition
oAsmCompDef = doc.ComponentDefinition
oLOD = oAsmCompDef.RepresentationsManager.LevelOfDetailRepresentations.Item("Custom Level of Detail")
oLOD.Activate(True)
End If

 This snippet is a modified version of someone's iLogic code off of these forums. It looks at the current LOD type and if it is not a custom one it sets it to a predefined custom LOD.

Mike (not Matt) Rattray

0 Likes
Message 3 of 3

MegaJerk
Collaborator
Collaborator

This is the code that I use. It will also prevent the rule from running in anything other than an assembly. 

 

Dim CurrentDoc as AssemblyDocument = ThisDoc.Document  
If (Not (CurrentDoc Is ThisApplication.ActiveDocument)) Then Return

Dim doc as AssemblyDocument = ThisDoc.Document
If doc.ComponentDefinition.RepresentationsManager.ActiveLevelOfDetailRepresentation.Name <> "Custom_Level_of_Detail_Name_Here" Then 

Dim oLOD As LevelOfDetailRepresentation  
Dim oAsmCompDef As ComponentDefinition  
oAsmCompDef = doc.ComponentDefinition 
	Try 
		oLOD = oAsmCompDef.RepresentationsManager.LevelOfDetailRepresentations.Item("Custom_Level_of_Detail_Name_Here").Activate(True)
		Catch
		Dim nLOD As LevelOfDetailRepresentation
		nLOD = oAsmCompDef.RepresentationsManager.LevelOfDetailRepresentations.Add("Custom_Level_of_Detail_Name_Here")
		oLOD = oAsmCompDef.RepresentationsManager.LevelOfDetailRepresentations.Item("Custom_Level_of_Detail_Name_Here").Activate(True)
	End Try
End If

 



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

GitHub
0 Likes