Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to copy a Level of Detail to a Design View

5 REPLIES 5
SOLVED
Reply
Message 1 of 6
psp
Enthusiast
931 Views, 5 Replies

How to copy a Level of Detail to a Design View

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?

5 REPLIES 5
Message 2 of 6
jdkriek
in reply to: psp

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
Jonathan D. Kriek
MFG Solutions Engineer
KETIV Technologies, Inc.


Message 3 of 6
psp
Enthusiast
in reply to: psp

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

Message 4 of 6
jdkriek
in reply to: psp

Indeed, glad I could help 😉

Jonathan D. Kriek
MFG Solutions Engineer
KETIV Technologies, Inc.


Message 5 of 6
pawellewap
in reply to: jdkriek

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

 

 

Message 6 of 6

@jdkriek 

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.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report