Continue to Site

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!

Upper Case Macro 1

Status
Not open for further replies.

jzecha

Aerospace
Jan 20, 2016
235
US
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:
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
 
Replies continue below

Recommended for you

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.
Before_a9dj9v.jpg
After_j2jsqo.jpg
Result_I_Want_vw8nps.jpg
.
 
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
 
How much slower do you think it would be?
How would you modify the code read each character as subtext?
 
in fact the substring will help you Get or Set the parameter:

Code:
        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
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Top