03-05-2021
04:16 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
03-05-2021
04:16 AM
Cleaned up the code and found out how to read the node of LOD whereby you can identify if it exists or not.
Dim asDoc As AssemblyDocument = ThisDoc.Document aComp = asDoc.ComponentDefinition 'Position der Detailgenauigkeit erfassen Dim ActLOD As String = aComp.RepresentationsManager.ActiveLevelOfDetailRepresentation.Name 'Definieren der Detailgenauigkeit Dim oLODRep As LevelOfDetailRepresentation = asDoc.ComponentDefinition.RepresentationsManager.LevelOfDetailRepresentations.Item(ActLOD) 'Browser knoten definieren Dim oNativeBrowserNodeDef As NativeBrowserNodeDefinition 'Versuchen die Aktive Detailgenauigkeit im Browserknoten zu definieren Try oNativeBrowserNodeDef = asDoc.BrowserPanes.GetNativeBrowserNodeDefinition(oLODRep) ' MsgBox(ActLOD & " | " & "Aktiv vorhanden") Catch ' MsgBox(ActLOD & " | " & "Aktive nicht vorhanden") ActLOD = "Hauptansicht" End Try 'Temporäre und für Abmessungen notwendige Detailgenauigkeit erstellen Try 'Für Abmessungen ohne Referenzbauteile aComp.RepresentationsManager.LevelOfDetailRepresentations.Item("Ohne Referenzbauteile").Activate(True) Catch aComp.RepresentationsManager.LevelOfDetailRepresentations.Add("Ohne Referenzbauteile") aComp.RepresentationsManager.LevelOfDetailRepresentations.Item("Ohne Referenzbauteile").Activate(True) End Try 'Alle referenzbauteile unterdrücken Dim aOcc As ComponentOccurrence ' Für jede Occurrence (subobjekt in BG) prüfen ob Referenzteil und wenn ja unterdrücken For Each aOcc In aComp.Occurrences If aOcc.BOMStructure = kReferenceBOMStructure Then 'dann unterdrücken aOcc.Suppress Else aOcc.Unsuppress End If Next XMax = Round(Measure.ExtentsLength, 0) YMax = Round(Measure.ExtentsWidth, 0) ZMax = Round(Measure.ExtentsHeight, 0) 'write measures into iProperty, L=x, B=y, H=z iProperties.Value("Custom", "Abmessung-Test") = XMax & " x " & YMax & " x " & ZMax '& " mm" 'Anschließend wieder Detailgenauigkeit von vorher oder Temp aktivieren aComp.RepresentationsManager.LevelOfDetailRepresentations.Item(ActLOD).Activate(True)
Somehow this fails though in my main routine, something with the try catch which makes trouble.