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!

Hi I want to create a macro to cha 1

Status
Not open for further replies.

NaWin55

Mechanical
Mar 21, 2020
97
IN
Hi
I want to create a macro to change all the dimensions of the drafting document
i have created this macro but its not working properly.
here is the macro

Option Explicit
Sub CATMain()

Dim myDrawDoc As DrawingDocument
Set myDrawDoc = CATIA.ActiveDocument

Dim drawSheets As DrawingSheets
Set drawSheets = myDrawDoc.Sheets

Dim drawiSheet As DrawingSheet
Set drawiSheet = drawSheets.ActiveSheet

Dim drawviews As DrawingViews
Set drawviews = drawiSheet.Views

Dim i As Integer
Dim oSel As Selection
Set oSel = CATIA.ActiveDocument.Selection
oSel.Clear
oSel.Search ("Drafting.View,scr")
For i = 1 To oSel.Count
Dim Drawview As DrawingView
Set Drawview = drawviews.Item(i)
MsgBox Drawview.Name
Next

Dim drawDims As DrawingDimensions
Set drawDims = Drawview.Dimensions

Dim j As Integer
Dim oSel2 As Selection
Set oSel2 = CATIA.ActiveDocument.Selection
oSel2.Clear
oSel2.Search ("Drafting.Dimension,all")
For j = 1 To oSel.Count
Dim drawDim As DrawingDimension
Set drawDim = drawDims.Item(j)
drawDim.GetValue.SetFormatName 1, "cm"
Next
End Sub

Here is the error
DimError_xg9xch.png


Here is the drawing file image
I want the macro to change dimensions of the drawing doc to cm or mm or m
DraftDoc_uoai82.png


Thanks
 
Replies continue below

Recommended for you

You can do this manually in 2 simple steps:

1. select all the dimensions by clicking in the power input box (lower-right corner of window) and type: t=dimen*
2. with all the dimensions highlighted, use the drop-down window in Numberical Properties toolbar to choose a metric style (NUM.DIMM or CM, or M)


NaWin: what are the units of the dimensions in your drawing above?
 
Hi jackk
but i want to do it with macro i just want to know how to loop and select all dimensions
just run the macro it changes the dimensions in only one step

Dimensions are in mm
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top