Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

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

CATIA V5 macro to update all text in CATDrawing

Status
Not open for further replies.

SwapnilB10

Mechanical
Joined
Dec 17, 2019
Messages
1
Location
DE
Hello everyone,

can anyone help me with creating a macro to update all the text available in view with suffix or prefix using an input box?
for ex. if I have text 1, 2 & n etc available in any view the macro should update it with H1, H2 & Hn respectively when user provide "H" in input field.

I have a below code which replaces all text boxes having text "1" with "H1" but this is limited to text having 1 in it.
i want to have it for all the text boxes with 2, 3 or 5 etc.

Code:
Sub Catmain()

n = 0
Set oDoc = CATIA.ActiveDocument
Set oSheets = oDoc.Sheets
Set oViews = oSheets.ActiveSheet.Views
Set oView = oViews.ActiveView
Set oTexts = oView.Texts

txt_to_src = "1"
txt_to_place = "H" & txt_to_src 

For Each srcText In oTexts
    If srcText.Text = txt_to_src Then
        srcText.Text = txt_to_place
        n = n + 1
    End If
Next

MsgBox n & " texts have been replaced"

End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top