Drawing Copy / Paste

Drawing Copy / Paste

NachoShaw
Advisor Advisor
835 Views
8 Replies
Message 1 of 9

Drawing Copy / Paste

NachoShaw
Advisor
Advisor

Hi

 

In my drawing sheet, I am trying to get a copy / paste method of some selected text. Currently, I am selecting the text and running this

 

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")

 

but nothing happens...

 

is there any way that I can copy / paste selected text and / or other objects in the drawing sheet like view / symbol etc?

 

 

 

Cheers

 

Nacho

Nacho
Automation & Design Engineer

Inventor automation Programmer (C#, VB.Net / iLogic)
Furniture, Sheet Metal, Structural, Metal fab, Tradeshow, Fabrication, CNC

EESignature


Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.


0 Likes
836 Views
8 Replies
Replies (8)
Message 2 of 9

bshbsh
Collaborator
Collaborator

is that your actual and entire code? 'coz it doesn't execute those commands anywhere, no wonder nothing is happening. or did you omit those?

0 Likes
Message 3 of 9

NachoShaw
Advisor
Advisor

Hi

 

I Omitted those. Here is the full  / paste text-

 

'Set up select set for text
Dim docSelect As SelectSet
Set docSelect = oDrawDoc.SelectSet 

'set up 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 text object
docSelect.Select oText

' Execute the copy command.
copyCommand.Execute

' Execute the paste command.
pasteCommand.Execute

Cheers

 

Nacho

Nacho
Automation & Design Engineer

Inventor automation Programmer (C#, VB.Net / iLogic)
Furniture, Sheet Metal, Structural, Metal fab, Tradeshow, Fabrication, CNC

EESignature


Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.


0 Likes
Message 4 of 9

Anonymous
Not applicable

This may help you. I use this to copy entire drawings

 

SyntaxEditor Code Snippet

Dim dwgDoc As DrawingDocument = ThisDoc.Document
Dim newDwg As DrawingDocument

pmi = 2 'min page index you would like to copy
pma = 3 'max page index you would like to copy

For x = 1 To 3 'number of times you want to copy
    For page = pmi To pma ' will copy from page pmi to pma
    
    currentSheet = dwgDoc.Sheets.Item(page)
        Try
            'Create the dummy drawing document.
            newDwg = ThisApplication.Documents.Add(kDrawingDocumentObject, Nothing, False)
            
            'Copy the current sheet to the new document.
            Dim newSheet As Sheet = currentSheet.CopyTo(newDwg)
            
            'Copy the sheet back to the original drawing.
            Dim copiedSheet As Sheet = newSheet.CopyTo(dwgDoc)
            
            'Activate the new sheet.
            copiedSheet.Activate()
            
        Catch
            MessageBox.Show("Error occurred copying sheet.")
        End Try
    Next
Next

 

0 Likes
Message 5 of 9

NachoShaw
Advisor
Advisor

Hi

 

Thanks for your reply. Unfortunately, I am not trying to copy a sheet, I am trying to copy an object on the sheet which in this case is a selected Textbox. I need to copy it and paste it back into the same drawing automatically.

 

Cheers

 

Nacho

Nacho
Automation & Design Engineer

Inventor automation Programmer (C#, VB.Net / iLogic)
Furniture, Sheet Metal, Structural, Metal fab, Tradeshow, Fabrication, CNC

EESignature


Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.


0 Likes
Message 6 of 9

frederic.vandenplas
Collaborator
Collaborator
You'll need to dig deeper into API and use selectset to get the selected text, once you have that you'll be able to paste the content of the textbox to a new textbox and paste the content
If you think this answer fullfilled your needs, improved your knowledge or leads to a solution,
please feel free to "kudos"
0 Likes
Message 7 of 9

NachoShaw
Advisor
Advisor
H

I'm already using SelectSet to select the text object. I'm not looking to copy text into a new textbook, I need to copy the object and paste that. The object won't always be a text box. Example:

Select object (by using pick method)
Add to selectSet
Copy (same as ctrl c)
Paste (same as ctrl v)

This method should add the paste object to the mouse for positioning

Nacho

Nacho
Automation & Design Engineer

Inventor automation Programmer (C#, VB.Net / iLogic)
Furniture, Sheet Metal, Structural, Metal fab, Tradeshow, Fabrication, CNC

EESignature


Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.


0 Likes
Message 8 of 9

NachoShaw
Advisor
Advisor

Still working on this..... There must be a way of doing it. I read once - "If you can do it, you can code it"

 

I have attached a video to demonstrate what I am trying to do. I have used a Leader in this instance and the leader is called oLeaderNote in code. When I right click the leader, there is a Copy (Ctrl C) command. I need to invoke that by code only and paste it.

 

 

 

Nacho

Nacho
Automation & Design Engineer

Inventor automation Programmer (C#, VB.Net / iLogic)
Furniture, Sheet Metal, Structural, Metal fab, Tradeshow, Fabrication, CNC

EESignature


Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.


0 Likes
Message 9 of 9

NachoShaw
Advisor
Advisor

OK so I am slightly closer.

 

When the leader is manually clicked, it is available for copying. This can be seen in my attached video that shows the copy button being enabled when the leader is clicked.

 

Also in the video, you can see me cancel the selected leader and then run my code. The leader 'appears' to be selected (highlighted magenta) but the copy button remains disabled. This tells me that the select method isn't actually physically selected the leader.

 

So the question is, How can I properly select the leader (as if it was clicked) to enable copying without physically clicked the leader manually?

 

 

 

 

Cheers

 

Nacho

Nacho
Automation & Design Engineer

Inventor automation Programmer (C#, VB.Net / iLogic)
Furniture, Sheet Metal, Structural, Metal fab, Tradeshow, Fabrication, CNC

EESignature


Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.


0 Likes