CATIA V5 Drafting Script
CATIA V5 Drafting Script
(OP)
Hi guys.
I am trying to make a script to get the dimensions from the drawing and send them in to the BoM.
I am stuck at getting the dimension value and assigning it to a string.
I tried to make this one work, one of Fernando's, which changes the color of all dimensions and by using "sel" instead of "all", it does change only the selected dimension.
How can I get the main value of the dimension?
Thanks!
I am trying to make a script to get the dimensions from the drawing and send them in to the BoM.
I am stuck at getting the dimension value and assigning it to a string.
I tried to make this one work, one of Fernando's, which changes the color of all dimensions and by using "sel" instead of "all", it does change only the selected dimension.
How can I get the main value of the dimension?
Thanks!
CODE
Dim drawingDocument1 As Document
Set drawingDocument1 = CATIA.ActiveDocument
'~ ******* select all dimensions in drawing
Dim selection1 As Selection
Set selection1 = drawingDocument1.Selection
selection1.Search "CATDrwSearch.DrwDimension,all"
'~ ******* change color of selection (it will be magenta - RGB code 255,0,255)
Set visPropertySet1 = selection1.VisProperties
visPropertySet1.SetRealColor 255,0,255,0
selection1.Clear
Set drawingDocument1 = CATIA.ActiveDocument
'~ ******* select all dimensions in drawing
Dim selection1 As Selection
Set selection1 = drawingDocument1.Selection
selection1.Search "CATDrwSearch.DrwDimension,all"
'~ ******* change color of selection (it will be magenta - RGB code 255,0,255)
Set visPropertySet1 = selection1.VisProperties
visPropertySet1.SetRealColor 255,0,255,0
selection1.Clear





RE: CATIA V5 Drafting Script
CODE
Sub CATMain()
Dim oDrw As DrawingDocument
Set oDrw = CATIA.ActiveDocument
Dim oView As DrawingView
Set oView = oDrw.Sheets.Item(1).Views.Item(3) 'First Sheet, first view (in my case a Front View)
Dim oDim As DrawingDimension
Dim dimsBefore()
'Collect dimensions names and values
For i = 1 To oView.Dimensions.Count
Set oDim = oView.Dimensions.Item(i)
ReDim Preserve dimsBefore(1, i)
dimsBefore(0, i) = oDim.Name
dimsBefore(1, i) = oDim.GetValue.Value
MsgBox oDim.GetValue.Value 'Display the result for dimesion number i
Next
End Sub
Regards
Fernando
RE: CATIA V5 Drafting Script
Thanks!
the .GetValue.Value I was missing.
Now, it prints the value of the selected dimension(s) in the order which they have been selected and regardless of the view.
CODE
Set MyDocument = Catia.ActiveDocument
Dim MyDimension As DrawingDimension
Dim I As Long
Dim selection1 As Object 'Selection for CATScript
Set selection1 = MyDocument.Selection
selection1.Search "CATDrwSearch.DrwDimension,sel"
For I = 1 To selection1.Count
Set MyDimension = selection1.Item(I).Value
MsgBox MyDimension.GetValue.Value 'Display the result for dimesion number i
Next
RE: CATIA V5 Drafting Script
Regards
Fernando
RE: CATIA V5 Drafting Script
Is anywhere I can find the arguments/different search strings for selection1.Search "CATDrwSearch.Drw???,???" or any way we can select all texts in a window from 0,0 to 100,100?
Regards
RE: CATIA V5 Drafting Script
I would do a workaround.....setup a print area, then zoom to print area, then search text on screen area.
I believe if you will search in documentation for PageSetup (Object) , you will get more ideas.
Regards
Fernando
https://picasaweb.google.com/102257836106335725208