×
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

Script for Dual dimensions
2

Script for Dual dimensions

Script for Dual dimensions

(OP)
Hi,

I have a requirement where in, I want to give dual dimensioning to drawing which is having views already dimensioned with "inch" as primary dimension. I want to give dual dimensioning with "mm" as secondary dimension selecting all dimensions at once.
Can anybody please provide a "VB OR CATScript" which will serve my purpose. Thanks in advance for your help.

Pradeep

RE: Script for Dual dimensions

Hi,

Please find code as below.
' Courtesy to Ferdo

Sub CATMain()
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 MyDimension As DrawingDimension
Dim MyValue As DrawingDimValue
Dim I, J
Dim iIndex

Set oDrwDoc = CATIA.ActiveDocument
Set oSheets = oDrwDoc.Sheets
Set oSheet = oSheets.ActiveSheet
Set oViews = oSheet.Views

For I = 3 To oViews.Count ' scan all views for dimensions except main view and background views
Set oView = oViews.Item(I)
oView.Activate
Set oDims = oView.Dimensions
For J = 1 To oDims.Count
Set MyDimension = oDims.Item(J)
Set MyValue = MyDimension.GetValue
MyDimension.DualValue = catDualBellow ' Dimension dual value display mode.
' MyDimension.DualValue = 1 ' Dimension dual value display mode.
' MyDimension.DualValue = 2 ' Dimension dual value display mode.
' catDualNone or 0 None.
' catDualBellow or 1 Bellow.
' catDualFractional or 2 Fractical.
' catDualSideBySide or 3 Side by side.
' For Main Value
iIndex = 1 ' main value
' If already in inch then don't use
' MyValue.SetFormatName iIndex, "in"
' MyValue.SetFormatPrecision iIndex, "0.00010"
' For Dual Value
iIndex = 2 ' dual value
MyValue.SetFormatName iIndex, "mm"
MyValue.SetFormatPrecision iIndex, "0.00010"
Next 'Dimension Loop End
Next 'Views Loop End
End Sub

Hope this is what you are expecting.
Regards,
Maddy

RE: Script for Dual dimensions

Yup
Exactly, without knowing the exact scenario, it'll be difficult to give a proper solution.

RE: Script for Dual dimensions

(OP)
Hi Maddy,

Thanks for your time.

I checked out the script given by you above, but it is not yielding the desired results.
I am getting an error trying to run the script. Please see attachment.
My requirement is to select all the dimensions in drawing at once & give dual dimension to it. Say if the dimensions given are in "inch" then Script should give the second dimension in "mm" and viceversa.

Thanks
Pradeep

RE: Script for Dual dimensions

Hi,

Kindly post the error message you are getting.

Regards,
Maddy.

RE: Script for Dual dimensions

It seems that you are running the code with visual basic editor.

open notepad.
Just copy the code and paste it.
Save it as "FileName.CATScript"

Add the folder to libraries.

Goto macro libraries.
Select the macro
Run
Regards,
Maddy

RE: Script for Dual dimensions

(OP)
Hi Maddy,

Thanks for your time.

As Iam new to CATIA scripting, Iam unable to follow what you are saying.
Please see the attachments for the steps I followed:
In attachments named "Dual 1,2,3,4", I tried to add the code saved as "CATScript" but the file will not be shown in option. Only ".VBA" files are showed.

In second set of attchments "Dual 1.1, 2.2, 3.3", I tried to open the script directly by double, but still no luck.

Please help!!!!

Thanks in advance.

RE: Script for Dual dimensions

Hi,

Please find the attached new script (file is 28 MB) and hope it is clear this time.
Extract it after downloading.

Goto macro libraries add the new folder (where you have saved the file.) to macro libraries
or simply run the script where you have saved it
(Note: please open only one session of CATIA and drawing file should be opened in it)
or copy the script file to the existing macro library folder

Video is attached for you guidance.

Regards,
Maddy
file is split into 6 parts

RE: Script for Dual dimensions

(OP)
Hi Maddy,

Can you please share the link for video, and the files are in ".rar" extension, should I save them in ".catvba" extn??
The files are not giving any extract options!!!

Please help!!
Thanks in advance
Pradeep

RE: Script for Dual dimensions

video is inside the archive file itself.

download all parts to one folder
open any one file out of 6 archive files or right click on one file then extract.
you will see the catscript and video file extracted.

RE: Script for Dual dimensions

download and install winrar or winzip or 7zip then you will see the extract option.

without these software's installed you wont find the extract option.

RE: Script for Dual dimensions

(OP)
Hi Maddy,

I have "7 Zip" installed in my system, still no luck.
Please share link for video, That would be helpful.

Thanks
Pradeep

RE: Script for Dual dimensions

(OP)
Hi Maddy,

Thanks alot!!! It works, just awesome.
Results are absolutely wat I was expecting (indeed more than what I was expecting)!!
Cheers!!

Thanks once again!
Pradeep

RE: Script for Dual dimensions

Hi Pradeep,

You are welcome,

Do help other people's queries in case if you know something which another person is trying to figure out.
And help each other.

Regards,
Maddy

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