×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Upper Case Macro

Upper Case Macro

Upper Case Macro

(OP)
I have the Backgroud_UpperCase_TXT.CATScript from the Catia Portable Script Center that I modified to include text in the main view as well.
The issue that I am running into is that when it changes everything to upper case, text boxes that have text with different formats in it all get changed to one format.
For example, some of the text is bolded and a different size, after the macro is run, all the text in that text box will be bolded and one size.
Is there a way to keep this from happening, I just want to make sure all my text is in upper case, I do not want the formatting to change.

CODE --> CATScript

Sub CATMain()

Dim sLF
Dim oDoc As Document
Dim sDrawingNumber
Dim oSheet As DrawingSheets
Dim oView As DrawingView
Dim oNewText As DrawingTexts
Dim i As Integer
'----------------
Set oDoc = CATIA.ActiveDocument

Set oSheet = oDoc.Sheets.Item(1)
oSheet.Activate

Set oView = oSheet.Views.Item("Background View")

For i = 1 To oView.Texts.Count

oView.Texts.Item(i).Text = UCase (oView.Texts.Item(i).Text) 

Next 

Set oView = oSheet.Views.Item("Main View")

For i = 1 To oView.Texts.Count

oView.Texts.Item(i).Text = UCase (oView.Texts.Item(i).Text)

Next

CATIA.ActiveWindow.ActiveViewer.Reframe

End Sub 

RE: Upper Case Macro

(OP)
It changes everything to upper case, but it changes the format in a text box that has multiple formats.
I am running Catia V5R23 SP3 Build Number 23 on Windows 7 Professional
I have attached the drawing i used to run this on.
I have also attached 3 pictures.
The way the font looks before the macro, after the macro, and the way i want it to look after the macro.
.

RE: Upper Case Macro

so much slower... I guess you will have to take each character as subtext and do UCase

Eric N.
indocti discant et ament meminisse periti

RE: Upper Case Macro

(OP)
How much slower do you think it would be?
How would you modify the code read each character as subtext?

RE: Upper Case Macro

in fact the substring will help you Get or Set the parameter:

CODE --> VBA

For Each oText In oView.Texts
        
            CTPmax = 16  ' 16 is the max value of CatTextProperty enum
                       
            ReDim textprop(CTPmax, Len(oText.Text))
            
            For CTP = 0 To CTPmax
                
                For i = 1 To Len(oText.Text)
                
                    textprop(CTP, i) = oText.GetParameterOnSubString(CTP, i, 1)

                Next

            Next
            
            oText.Text = UCase(oText.Text)
            
            ' CatTextProperty 8 (catParagraph) and 9 (catPlain) should not be impacted by LCase or UCase
            ' but setting them impact length of text
            
            For CTP = 0 To CTPmax
            
                If CTP = 8 Then CTP = 10

                For i = 1 To Len(oText.Text)

                    oText.SetParameterOnSubString CTP, i, 1, textprop(CTP, i)

                Next

            Next
        
        Next 

Still faster than manually...

Eric N.
indocti discant et ament meminisse periti

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources