copy part *.ipt to clipboard

copy part *.ipt to clipboard

Anonymous
Not applicable
891 Views
5 Replies
Message 1 of 6

copy part *.ipt to clipboard

Anonymous
Not applicable

Hi,

Is there any code similar to one below that copys part.ipt to the clipboard?

 

Imports System.Windows.Forms

Sub Main
   Clipboard.SetText(Description)
End Sub

 Any help is appreciated.

Thanks,

0 Likes
Accepted solutions (1)
892 Views
5 Replies
Replies (5)
Message 2 of 6

ekinsb
Alumni
Alumni

Can you please be a more specific about what you need and what you're trying to do.  I'm unclear if you want it to be the equivalent of selecting a .ipt file in Windows Explorer and doing ctrl-C or selecting the top node in the browser and doing ctrl-C or even something else.  The results in the two cases I mentioned, as far as what goes on the clipboard, are completely different.


Brian Ekins
Inventor and Fusion 360 API Expert
Mod the Machine blog
0 Likes
Message 3 of 6

Anonymous
Not applicable

Brian,

I`m trying to find a code equivalent to selecting an ipt part In inventor in the assembly view tree and doing CTRL+C.

Thank you,

0 Likes
Message 4 of 6

ekinsb
Alumni
Alumni
Accepted solution

There isn't direct exposure of the Copy and Paste functionality on the ComponentOccurrence object, which is the API object that represents each of the nodes in the assembly tree (parts and subassemblies).  However, it is possible to directly call Inventor commands.  The code below illustrates this.

Public Sub CopyPaste()
    Dim asmDoc As AssemblyDocument
    Set asmDoc = ThisApplication.ActiveDocument

    Dim occ As ComponentOccurrence
    Set occ = asmDoc.ComponentDefinition.Occurrences.ItemByName("L:1")
    
    ' Get references to the copy and paste commands.
    Dim controlDefs As ControlDefinitions
    Set controlDefs = ThisApplication.CommandManager.ControlDefinitions
    Dim copyCommand As ControlDefinition
    Set copyCommand = controlDefs.Item("AppCopyCmd")
    Dim pasteCommand As ControlDefinition
    Set pasteCommand = controlDefs.Item("AppPasteCmd")

    ' Select the occurrence.
    asmDoc.SelectSet.Clear
    Call asmDoc.SelectSet.Select(occ)
    
    ' Execute the copy command.
    copyCommand.Execute
    
    ' Execute the paste command.
    pasteCommand.Execute
End Sub

 


Brian Ekins
Inventor and Fusion 360 API Expert
Mod the Machine blog
Message 5 of 6

Anonymous
Not applicable
Great! it works! I would never come up with something similar myself!
Thanks!
0 Likes
Message 6 of 6

DeerSpotter
Collaborator
Collaborator

this doesnt work anymore, could you please fix?

Image and video hosting by TinyPic
..........................................................................................................................
Did you find this reply helpful ? If so please use the Accept as Solution or Kudos button below.
..........................................................................................................................


See My LinkedIn Profile
0 Likes