I can find a method to copy a Design View to a Level of Detatil (DesignViewRepresentation.CopyToLevelOfDetail)
But the opposite way (i.e. LevelOfDetailRepresentation.CopyToDesignView) doesn't seem to exist - it is possible in the GUI.
Will I have to traverse the complete structure and set visibillity one by one to obtain the function then? Or are there a better/faster way to go?
Solved! Go to Solution.
Solved by psp. Go to Solution.
Solved by jdkriek. Go to Solution.
If you are able to activate and select the LOD through API, you could use the CommandManager (same command used in UI)
ThisApplication.CommandManager.ControlDefinitions.Item("AssemblyCopyLODRepToViewRepCommand").Execute
Something like this:
Public Sub LOD() If ThisApplication.ActiveDocument.DocumentType <> kAssemblyDocumentObject Then Exit Sub Dim oAsmDef As AssemblyComponentDefinition Set oAsmDef = ThisApplication.ActiveDocument.ComponentDefinition Dim oRepManager As RepresentationsManager Set oRepManager = oAsmDef.RepresentationsManager ' Name of LOD Dim oLODRep As LevelOfDetailRepresentation Set oLODRep = oRepManager.LevelOfDetailRepresentations.Item("LevelofDetail1") ' Activate LOD Call oLODRep.Activate ' Select the LOD... ' Copy the LOD ThisApplication.CommandManager.ControlDefinitions.Item("AssemblyCopyLODRepToViewRepCommand").Execute End Sub
Thank you. That almost does what I was looking for.
But selecting the LOD isn't enough. It needs to have focus in the browser, so I ended up with this (iLogic code):
If ThisDoc.Document.DocumentType = Inventor.DocumentTypeEnum.kAssemblyDocumentObject Then Dim RepName="iLogic" Dim doc As AssemblyDocument = ThisDoc.Document Try ' Delete Design View if one exist prior doc.ComponentDefinition.RepresentationsManager.DesignViewRepresentations.Item("Master").activate doc.ComponentDefinition.RepresentationsManager.DesignViewRepresentations.Item(RepName).delete Catch End Try ' Find LOD in browser and give it focus Dim oLODRep As LevelOfDetailRepresentation = _ doc.ComponentDefinition.RepresentationsManager.LevelOfDetailRepresentations.Item(RepName) doc.BrowserPanes.Item("Model").Activate Dim oNativeBrowserNodeDef As NativeBrowserNodeDefinition = doc.BrowserPanes.GetNativeBrowserNodeDefinition(oLODRep) doc.BrowserPanes.ActivePane.TopNode.AllReferencedNodes(oNativeBrowserNodeDef).Item(1).DoSelect ' Copy LOD to Design View ThisApplication.CommandManager.ControlDefinitions.Item("AssemblyCopyLODRepToViewRepCommand").Execute End If
Regards
PSP
Hello. I have a problem accessing the file through the path.
Open assembly
filename as "c:\Test\File_test.iam"
RepName as "iLogic"
Dim odoc As AssemblyDocument odoc = ThisApplication.Documents.Open(filename, False) Try ' Delete Design View if one exist prior odoc.ComponentDefinition.RepresentationsManager.DesignViewRepresentations.Item("Master").activate odoc.ComponentDefinition.RepresentationsManager.DesignViewRepresentations.Item(RepName).delete Catch End Try
' Find LOD in browser and give it focus Dim oLODRep As LevelOfDetailRepresentation = _
odoc.ComponentDefinition.RepresentationsManager.LevelOfDetailRepresentations.Item(RepName) odoc.BrowserPanes.Item("Model").Activate Dim oNativeBrowserNodeDef As NativeBrowserNodeDefinition = _
odoc.BrowserPanes.GetNativeBrowserNodeDefinition(oLODRep) odoc.BrowserPanes.ActivePane.TopNode.AllReferencedNodes(oNativeBrowserNodeDef).Item(1).DoSelect
' Copy LOD to Design View ' can not be :( odoc.CommandManager.ControlDefinitions.Item("AssemblyCopyLODRepToViewRepCommand").Execute
its not working, ?
Help
Actually helped me here https://forums.autodesk.com/t5/inventor-customization/setting-representation-level-of-detail-fails-d...
To figure out if the active LOD has an existing node, thanks alot.