Copy views to new drawing

Copy views to new drawing

Anonymous
Not applicable
378 Views
3 Replies
Message 1 of 4

Copy views to new drawing

Anonymous
Not applicable
Hello,

I have data sets of one sheet contains many views typically representing many component drawings . My requirement is I need to copy the views of single sheet to new drawings. As many component views are there, the new drawing should be created.

Any sample codes will be highly helpful. Snap shot of sheet is attached.

Thanks
Dinesh Babu
0 Likes
379 Views
3 Replies
Replies (3)
Message 2 of 4

Anonymous
Not applicable
You can use the DrawingView.CopyTo method to copy individual views from one
sheet into another. If you need to copy multiple views at the same time
(because of dependencies between the views), there isn't a formal API to do
that. You can use the following workaround code to achieve that.

Sanjay-


Sub CopyDrawingViews()

Dim oDoc As DrawingDocument
Set oDoc = ThisApplication.ActiveDocument

' Select the views to copy
oDoc.SelectSet.Clear
oDoc.SelectSet.Select oDoc.ActiveSheet.DrawingViews(1)
oDoc.SelectSet.Select oDoc.ActiveSheet.DrawingViews(2)

' Execute the copy command
Dim oCopyCmd As ControlDefinition
Set oCopyCmd =
ThisApplication.CommandManager.ControlDefinitions.Item("AppCopyCmd")
oCopyCmd.Execute

' Activate and select the destination sheet
oDoc.Sheets(2).Activate
oDoc.SelectSet.Select oDoc.ActiveSheet

' Execute the paste command
Dim oPasteCmd As ControlDefinition
Set oPasteCmd =
ThisApplication.CommandManager.ControlDefinitions.Item("AppPasteCmd")
oPasteCmd.Execute

End Sub
0 Likes
Message 3 of 4

Anonymous
Not applicable
Thanks for the response. Is there any way to copy the dependent views? the sample code only copies the main views in a sheet.

Dinesh
0 Likes
Message 4 of 4

Anonymous
Not applicable
The sample was hard-coded to select the 1st and 2nd views on the active
sheet. Have you tried modifying the sample to select all the relevant views?
Just as you would when copy-pasting using the user interface?

Sanjay-
0 Likes