×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

CATIA V5 Drafting Script

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!


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

RE: CATIA V5 Drafting Script

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
 

RE: CATIA V5 Drafting Script

(OP)
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

RE: CATIA V5 Drafting Script

Glad it was helpful.

Regards
Fernando
 

RE: CATIA V5 Drafting Script

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

RE: CATIA V5 Drafting Script

Hi,

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

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources