CATScript
CATScript
(OP)
Hi,
Looking over the forum has helped me a lot, but now I am looking for a bit of help. I am very much a begineer in the cat script side of things and currently use the record macro function.
Im currently trying to create some script that will do the following:
- Copy v4 2D Drawing data
- Paste into V5 drawing
When using the macro, and running it it always comes up with an error. 'The CSO is empty, Copy operation can not be performed'
The macro recorder code is below.
Private Sub CommandButton1_Click()
Dim document1 As Document
Set document1 = CATIA.ActiveDocument
Dim selection1 As Selection
Set selection1 = document1.Selection
Set selection1 = CATIA.ActiveDocument.Selection
CATIA.DisplayFileAlerts = False
selection1.Copy
Dim windows1 As Windows
Set windows1 = CATIA.Windows
Dim specsAndGeomWindow1 As SpecsAndGeomWindow
Set specsAndGeomWindow1 = windows1.Item("Drawing2")
specsAndGeomWindow1.Activate
specsAndGeomWindow1.WindowState = catWindowStateMaximized
Dim drawingDocument1 As DrawingDocument
Set drawingDocument1 = CATIA.ActiveDocument
Dim selection2 As Selection
Set selection2 = drawingDocument1.Selection
selection2.Clear
Dim drawingRoot1 As DrawingRoot
Set drawingRoot1 = drawingDocument1.GetItem("CATIADrawingDrawing0")
selection2.Add drawingRoot1
selection2.Paste
Dim specsViewer1 As SpecsViewer
Set specsViewer1 = specsAndGeomWindow1.ActiveViewer
specsViewer1.Reframe
Any help would be greatly apprciated.
Looking over the forum has helped me a lot, but now I am looking for a bit of help. I am very much a begineer in the cat script side of things and currently use the record macro function.
Im currently trying to create some script that will do the following:
- Copy v4 2D Drawing data
- Paste into V5 drawing
When using the macro, and running it it always comes up with an error. 'The CSO is empty, Copy operation can not be performed'
The macro recorder code is below.
Private Sub CommandButton1_Click()
Dim document1 As Document
Set document1 = CATIA.ActiveDocument
Dim selection1 As Selection
Set selection1 = document1.Selection
Set selection1 = CATIA.ActiveDocument.Selection
CATIA.DisplayFileAlerts = False
selection1.Copy
Dim windows1 As Windows
Set windows1 = CATIA.Windows
Dim specsAndGeomWindow1 As SpecsAndGeomWindow
Set specsAndGeomWindow1 = windows1.Item("Drawing2")
specsAndGeomWindow1.Activate
specsAndGeomWindow1.WindowState = catWindowStateMaximized
Dim drawingDocument1 As DrawingDocument
Set drawingDocument1 = CATIA.ActiveDocument
Dim selection2 As Selection
Set selection2 = drawingDocument1.Selection
selection2.Clear
Dim drawingRoot1 As DrawingRoot
Set drawingRoot1 = drawingDocument1.GetItem("CATIADrawingDrawing0")
selection2.Add drawingRoot1
selection2.Paste
Dim specsViewer1 As SpecsViewer
Set specsViewer1 = specsAndGeomWindow1.ActiveViewer
specsViewer1.Reframe
Any help would be greatly apprciated.





RE: CATScript
http://excelspreadsheetshelp.blogspot.com - http://scripting4v5.com
RE: CATScript
RE: CATScript
Why don't you use Migratev4tov5 from Tools-Options ? You want something specific ? It can be done but....why complicated when it can be easy ?
Regards
Fernando
RE: CATScript
Regards
Fernando
RE: CATScript
Im trying not to use the migration tool, As the program I am designing should do the following operations.
1. Open up folder where V4 data is
2. Open blank V5 drawing sheet
3. Copy Over v4 data to v5 sheet
4. Change Text, Dimensions, Levels, Colour all to new standard
5. Save file with the inputs from the Userform.
So far, I have 1,2 and 4 complete, with 5 nearly there.
Just struggling with number 4.
RE: CATScript
Regards
Fernando
RE: CATScript
I have attached a sample v4 file.
RE: CATScript
Sorry for late response, I've been very busy...
I tried to do what you want but I didn't succeed...probably the only way to do it as you wish is open the .model file, use sendkeys to switch from *Master sheet to SHT 4 sheet (using arrow right), then use search to select everything in SHT 4, copy and paste in v5 drawing.
The problem is I cannot switch from first sheet to the second one (using sendkeys) which is in fact the most important thing.
Anyway, I still believe is much easier to use conversion tool and after that enter in v5 drawings to correct what you want (if this cannot be done directly when you are using conversion tool).
Regards
Fernando