10-14-2021
03:23 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
10-14-2021
03:23 PM
Hello
Maybe this script can help you. It checks in the main assembly and recursive in all subassemblies if a Level of Detail named "LoD" exists and activate it. If there's not a Level of Detail "LoD" it creates one and then activate it.
The name of the LoD can be changed in second line.
Sub Main
Dim sLoDName As String = "LoD"
Dim oAsmDoc As AssemblyDocument = ThisDoc.Document
Dim oOccs As Inventor.ComponentOccurrences=oAsmDoc.ComponentDefinition.Occurrences
LoD(oAsmDoc, sLoDName)
LoD(oOccs, sLoDName)
MsgBox("done")
End Sub
Private Sub LoD(ByVal oOccs As ComponentOccurrences, ByVal sLoDName As String)
Dim oCompDef As AssemblyComponentDefinition
Dim oOcc As Inventor.ComponentOccurrence
For Each oOcc In oOccs
If oOcc.DefinitionDocumentType = DocumentTypeEnum.kAssemblyDocumentObject Then
oCompDef= oOcc.Definition
Dim oLoD As LevelOfDetailRepresentation
For Each oLod In oCompDef.RepresentationsManager.LevelOfDetailRepresentations
If oLoD.Name = sLoDName Then
Exit For
End If
oLoD=Nothing
Next
If oLoD Is Nothing Then
oLoD = oCompDef.RepresentationsManager.LevelOfDetailRepresentations.Add(sLoDName)
End If
oOcc.SetLevelOfDetailRepresentation(sLoDName, True)
LoD(oOcc.Definition.Occurrences,sLoDName )
End If
Next
End Sub
Private Sub LoD(ByVal oAsmDoc As AssemblyDocument, ByVal sLoDName As String)
Dim oCompDef As AssemblyComponentDefinition = oAsmDoc.ComponentDefinition
Dim oLod As LevelOfDetailRepresentation
For Each oLod In oCompDef.RepresentationsManager.LevelOfDetailRepresentations
If oLod.Name = sLoDName Then
oLod.Activate
Exit For
End If
oLod=Nothing
Next
If oLod Is Nothing Then
oLod = oCompDef.RepresentationsManager.LevelOfDetailRepresentations.Add(sLoDName)
End If
If Not oCompDef.RepresentationsManager.ActiveLevelOfDetailRepresentation.Name=sLoDName Then
oCompDef.RepresentationsManager.LevelOfDetailRepresentations.Item(sLoDName).Activate
End If
End Sub
R. Krieg
RKW Solutions
www.rkw-solutions.com