×
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 macro : units

Catia V5 macro : units

Catia V5 macro : units

(OP)
Hello All,
In the below attached script, text size greater than 7 mm will selected in catia v5 drawing and changed to red color.
In the same context if I want to select text size which are equal to 0.156 inch then how should it be incorporated in the script. I think by default script is considering millimeter units and I need to specify the length in inches without converting 0.156 inches to millimeter.

Thanks in advance,

Regards,

Guru Charan T

RE: Catia V5 macro : units

Paste the code bellow in a CATScript and run it before what you found on internet (or yo can modify completely the code).

Option Explicit
Dim oDrwDoc As DrawingDocument
Dim oSheets As DrawingSheets
Dim oSheet As DrawingSheet
Dim oViews As DrawingViews
Dim oView As DrawingView
Dim oDims As DrawingDimensions
Dim oDim As DrawingDimension
Dim oDimVal As DrawingDimValue
Dim vc As Integer 'view count
Dim dc As Integer 'dimension count

Sub CATMain()

CATIA.DisplayFileAlerts = False

    Dim Message, Style, Title, Response, MyString
    Message = ("This macro will cchange all your drawing dimensions from current unit to millimeters (except those from main and background views)" &_
                            (chr(13)) &_
                        ""&(chr(13))&_
"   Do you want to continue ?")
    Style = vbYesNo + vbDefaultButton1    'Define default button
    Title = "Purpose "   
    Response = MsgBox(Message, Style, Title)
        If Response = vbYes Then    ' User chose Yes.
            MyString = "Yes"

Set oDrwDoc = CATIA.ActiveDocument
Set oSheets = oDrwDoc.Sheets
Set oSheet = oSheets.ActiveSheet
Set oViews = oSheet.Views
For vc = 3 To oViews.Count 'scan all views for dimensions except main view and background views
Set oView = oSheet.Views.Item(vc)
oView.Activate
Set oDims = oView.Dimensions
For dc = 1 To oDims.Count
Set oDim = oDims.Item(dc)
Set oDimVal = oDim.GetValue
oDimVal.SetFormatName 1, "NUM,DIMM"  'pay attention to number format and unit, for inches you can write "NUM.DINC" or "in"
Next 'dc
Next 'vc


End If

End Sub

Regards
Fernando
 

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