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!

Script for Dual dimensions 2

Status
Not open for further replies.

metipradeep

Aerospace
Apr 22, 2013
14
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

 
Replies continue below

Recommended for you

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
 
Yup
Exactly, without knowing the exact scenario, it'll be difficult to give a proper solution.

 
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
 
 http://files.engineering.com/getfile.aspx?folder=33f24ade-630f-4a1c-8679-c6849bf42147&file=dual_dimm_2.jpg
Hi,

Kindly post the error message you are getting.

Regards,
Maddy.
 
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
 
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.
 
 http://files.engineering.com/getfile.aspx?folder=34218cf1-a049-4257-a55e-84a4b5d5ed7c&file=dual_3.3.jpg
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
 
 http://files.engineering.com/getfile.aspx?folder=e8cb2c8d-d7b6-4161-9385-fe92a8f8d6db&file=Dual_Value_split.part1.rar
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
 
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.

 
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.
 
Hi Maddy,

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

Thanks
Pradeep
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor