Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations IDS on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Count dimension with text after/before

Status
Not open for further replies.

Xichlone

Mechanical
Jan 26, 2019
2
Sorry everyone.
I have some problems about creating the code to count all the dimension in Catia drawing, that contain specific text (text add after or before the dimensions). Please help me.
 
Replies continue below

Recommended for you

Here are the code I had discovered, but I want to develope it a little bit.
1. can I select all the dimension with that specify text (in this case is FIT text)
2. Does it has any method to find dimensions with 'positioned texts'

Sub CATMain()

Dim myDrawing As DrawingDocument

On Error Resume Next
Set myDrawing = CATIA.ActiveDocument
If (Err.Number <> 0) Then
MsgBox ("A CATDrawing must be active")

Exit Sub
End If
If (InStr(myDrawing.Name, ".CATDrawing")) = 0 Then
MsgBox ("The active window must be a CATDrawing")
Exit Sub
End If
Err.Clear
On Error GoTo 0

Dim selection1 As Selection
Set selection1 = myDrawing.Selection
selection1.Clear
selection1.Search "CATDrwSearch.DrwDimension.Visibility=Shown"

For i = 1 To selection1.count
Set MyDimension = selection1.Item(i).Value
Set MyDimValue = MyDimension.GetValue
MyDimValue.GetBaultText 1, MyBefore, MyAfter, MyUpper, MyLower
Dim afr, count
afr = Right(MyAfter, 4)
If afr = " FIT" Then
count = count + 1
End If
Next
MsgBox count

End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor