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!

Numbering Dimensions Macro 1

Status
Not open for further replies.

LILE

Automotive
Jan 25, 2018
8
KR

Hello everyone.
I make some macro.
I want to numbering all Dimensions for draft.
So, I write some code.
-------------------------------------------------
Sub CATMain()

Dim MyDoc As DrawingDocument
Dim MySelection As Selection
Dim MySheet As drawingsheet
Dim MyDrawingView As DrawingView
Dim MyDimensions As DrawingDimensions
Dim MyDimension As DrawingDimension
Dim MyText As DrawingText
Dim oValues(5)
Dim drawingview1 As DrawingView
Dim Dimensions1 As DrawingDimensions
Dim Dimension2 As DrawingDimension
Dim Text1 As DrawingText

Set MyDoc = CATIA.ActiveDocument
Set MySheet = MyDoc.DrawingRoot.ActiveSheet
Set MySelection = MyDoc.Selection
If MySelection.Count = 0 Then

MsgBox "Nothing Selected"
Exit Sub

Else
For k = 1 To MySelection.Count

If MySelection.Item(k).Type = "DrawingView" Then

Set MyDrawingView = MySelection.Item(1).Value
Set MyDimensions = MyDrawingView.Dimensions

For i = 1 To MyDimensions.Count
Set MyDimension = MyDimensions.Item(i)
Dim MyDimV
Set MyDimV = MyDimension
Call MyDimV.GetBoundaryBox(oValues)
Set MyText = MyDrawingView.Texts.Add("No. 000" & i, oValues(0), oValues(1))
If MySelection.Item(k).Type = "drawingview" Then
Set drawingview1 = MySelection.Item(2).Value
Set Dimensions1 = drawingview1.Dimensions

For j = 1 To Dimensions1.Count
Set Dimension1 = Dimensions1.Item(j)
Dim MyDimX
Set MyDimX = Dimension1
Call MyDimX.GetBoundaryBox(oValues)
Set Text1 = drawingview1.Texts.Add("No. 000" & i + j, oValues(0), oValues(1))

Next
End If
Next
End If
Next
End If

End Sub
-----------------------------------------
This code don't activate normally.
Only activate One view.
Next view is not activate.
But I want activate all view.
If one view have 10 dimesions then next view's number start 11.
hlep,,,
 
Replies continue below

Recommended for you

hello Mr.Lite
I check your macro, but its showing an error while executing it.
will you please check so that I can further tried to add on your requirement in this.
 
I took the liberty of altering your code...
I added J as the loop variable to get consecutive numbering of ALL dimensions.
Removed some code, and added indentations...

Sub CATMain()
Dim MyDoc As DrawingDocument
Dim MySelection As Selection
Dim MySheet As DrawingSheet
Dim MyDrawingView As DrawingView
Dim MyDimensions As DrawingDimensions
Dim MyDimension As DrawingDimension
Dim MyText As DrawingText
Dim oValues(5)
Dim drawingview1 As DrawingView
Dim Dimensions1 As DrawingDimensions
Dim Dimension2 As DrawingDimension
Dim Text1 As DrawingText
Dim J As Integer
Dim View

Set MyDoc = CATIA.ActiveDocument
Set MySheet = MyDoc.DrawingRoot.ActiveSheet
J = 0
For Each View In MySheet.Views
Set MyDimensions = View.Dimensions

For i = 1 To MyDimensions.count
J = J + 1
Set MyDimension = MyDimensions.Item(i)
Dim MyDimV
Set MyDimV = MyDimension
Call MyDimV.GetBoundaryBox(oValues)
Set MyText = View.Texts.Add("No. 000" & J, oValues(0), oValues(1))
Next​
Next
End Sub

regards,
LWolf
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top