Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

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

CATIA V5 Drafting Script 1

Status
Not open for further replies.

walter356

Automotive
Mar 10, 2012
5
RO
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!


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
 
Replies continue below

Recommended for you

Is not quite what you want but will help you...

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
 
Yes
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:
Dim MyDocument As DrawingDocument
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
 
Hi All,

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?[pc2]

Regards
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Top