Copy Paste Script
Copy Paste Script
(OP)
Hello Everyone,
I need a macro for copy pasting picture from one drawing sheet_01 background to another drawing sheet_01 background. I have like 1000+ parts for this job and it scares me a lot, not bcox of the work load but there is a greater chances of making a mistake.
The tricky part is the sheets are having different names, I need a general macro which can be used on every two drawings regardless of the names and titles.
Please guys help me out here.
I need a macro for copy pasting picture from one drawing sheet_01 background to another drawing sheet_01 background. I have like 1000+ parts for this job and it scares me a lot, not bcox of the work load but there is a greater chances of making a mistake.
The tricky part is the sheets are having different names, I need a general macro which can be used on every two drawings regardless of the names and titles.
Please guys help me out here.
Warm regards,
Akhtar Aziz





RE: Copy Paste Script
did you search and find anything close to what you need?
how much you know about vba / scripting ?
can you post your start and tell us when the problem is?
Thanks
indocti discant et ament meminisse periti
RE: Copy Paste Script
There are two different types of things that I need to copy from one drawing to another drawing.
1. Picture in the sheet background
2. Text in normal drawing sheet
I got successful with the text somehow but when I tried to record the macro for the picture, something weird happened. The macro executes normally buh the image is pasted in the form of raster or stl type with size reduced by like 10 times and you cannot edit it, select it or delete it.
I have attached an image to clear the confusion. I am trying to copy the picture "Controlled Copy" from drawing01 to drawing02 in the sheet background but it changes to something undetectable.
I don't have a knowledge of VBS, I just record the macro and then use my intuition to make it working or I post things on this forum and get help from the people.
Below is the script:
Sub CATMain()
Set specsAndGeomWindow1 = CATIA.ActiveWindow
specsAndGeomWindow1.ActivateNext
Set windows1 = CATIA.Windows
Set specsAndGeomWindow2 = windows1.Item("Controlled copy sample.CATDrawing")
specsAndGeomWindow2.Activate
Set drawingDocument1 = CATIA.ActiveDocument
Set selection1 = drawingDocument1.Selection
selection1.Clear
Set drawingSheets1 = drawingDocument1.Sheets
Set drawingSheet1 = drawingSheets1.Item("84615-805")
Set drawingViews1 = drawingSheet1.Views
Set drawingView1 = drawingViews1.Item("Background View")
Set drawingPictures1 = drawingView1.Pictures
Set drawingPicture1 = drawingPictures1.Item("Picture.6")
selection1.Add drawingPicture1
selection1.Copy
specsAndGeomWindow2.ActivateNext
specsAndGeomWindow1.Activate
Set drawingDocument2 = CATIA.ActiveDocument
Set selection2 = drawingDocument2.Selection
selection2.Clear
Set drawingSheets2 = drawingDocument2.Sheets
Set drawingSheet2 = drawingSheets2.Item("84465-810-1-L")
selection2.Add drawingSheet2
selection2.Paste
End Sub
Warm regards,
Akhtar Aziz
RE: Copy Paste Script
I copy a PNG picture inserted with "insert / picture" command from the background of doc1 to the background of doc2.
position and size are kept from doc1 to doc2 (so if doc2 if bigger, then position will have to be adjusted, also if scale1 and scale2 are not the same some action might be required... but here background view scale is 1 on both drawing)
CODE --> catvba
indocti discant et ament meminisse periti
RE: Copy Paste Script
That will bring your picture into the Mainview.
You can check the scale of the mainview by checking the scale of the sheet.
the scale of the background view is visible from VBA code
indocti discant et ament meminisse periti
RE: Copy Paste Script
I don't get the part of what is your CATIA level?
Position and size of the both of the documents are exactly the same. The drawing is A3.
I will try this code and let you know how it goes for me.
Warm regards,
Akhtar Aziz
RE: Copy Paste Script
Just tried to run your macro but it gave error on the following line:
Dim drawing1, drawing2 As DrawingDocument
don't know the reason .. !!!
Warm regards,
Akhtar Aziz
RE: Copy Paste Script
indocti discant et ament meminisse periti
RE: Copy Paste Script
Warm regards,
Akhtar Aziz
RE: Copy Paste Script
indocti discant et ament meminisse periti
RE: Copy Paste Script
Warm regards,
Akhtar Aziz
RE: Copy Paste Script
my script give me same result in R20 and R24
indocti discant et ament meminisse periti