Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations waross on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Copy Drawing Page

Status
Not open for further replies.

Kapmc

Automotive
Sep 7, 2006
39
0
0
US
Does anyone know how to copy a specific page out of a drawing into another drawing using Vb?

I do remember this being ask before but I can't seem to find that post.

Thanks
Kapmc
 
Replies continue below

Recommended for you

The Ctrl+C and Ctrl+V is not working for you?

but try this

Note! The code shown only copies geometry, not text or pictures.

'******************************
'******************************

'Assumes one blank drawing as the active document
'and one open template drawing called "Template1.CATDrawing", with titleblock
'geometry drawn in the background view
'Titleblock geometry will be pasted into the background of the new blank drawing

Sub catmain()

Dim NewDrawing As DrawingDocument
Dim TemplateDrawing As DrawingDocument

Set NewDrawing = CATIA.ActiveDocument
Set TemplateDrawing = CATIA.Documents.Item("Template1.CATDrawing")

TemplateDrawing.Activate 'Activates the template drawing
Dim TemplateDrawingBackground As DrawingView
Set TemplateDrawingBackground = TemplateDrawing. _
Sheets.ActiveSheet.Views.Item(2) 'background

Dim TemplateSelection As Selection
Set TemplateSelection = TemplateDrawing.Selection
TemplateSelection.Search ("Drafting.Geometry;All")
TemplateSelection.Copy

'Paste the copied geometry into the new drawing:
NewDrawing.Activate 'activates the new, blank drawing
Dim NewDrawingBackground As DrawingView
Set NewDrawingBackground = NewDrawing. _
Sheets.ActiveSheet.Views.Item(2) 'background

Dim NewDrawingSelection As Selection ' Selections are for one document only
Set NewDrawingSelection = NewDrawing.Selection

NewDrawingSelection.Add NewDrawingBackground
NewDrawingSelection.Paste

End Sub


'******************************
'******************************


*edit*
Try in CATIA's search editor to find the expression that will select everything(geometry,text...) in the drawing,
and replace "Drafting.Geometry;All" with the found expression
*edit*

I stole this code snippet from a post by Bjorn D

Regards,
Derek
 
Derek:

Ya you know me why use the simple path when you can complicate the issue.

Thanks for the code I will give it a try.

Kapmc.
 
Status
Not open for further replies.
Back
Top