Set text color Drafting Macro
Set text color Drafting Macro
(OP)
Hello all,
I'm trying to set the red color on a text I have added with the following code taken from VBA help:
Property Color( ) As long
Returns or sets the color of the drawing text.
Example:
This example sets the Color type of the MyText drawing text to red
redCol =-16776961 'Encoded RGBA color within long integer (R=255 G=0 B=0 A=255)
MyText.Color = redCol
Code I'm trying:
MyText.SetFontSize 0, 0, 20
redCol = -16776961
MyText.Color = redCol 'ERROR
SetFontSize works perfectly but the line for the colour doesn't...
Another thing I've tried is this code, based on a search I have done in the forum, but doesn't work neither:
MyText.visProperties1.SetRealColor 255, 0, 0, 1
Any ideas?
(I'm coding on VBA)
I'm trying to set the red color on a text I have added with the following code taken from VBA help:
Property Color( ) As long
Returns or sets the color of the drawing text.
Example:
This example sets the Color type of the MyText drawing text to red
redCol =-16776961 'Encoded RGBA color within long integer (R=255 G=0 B=0 A=255)
MyText.Color = redCol
Code I'm trying:
MyText.SetFontSize 0, 0, 20
redCol = -16776961
MyText.Color = redCol 'ERROR
SetFontSize works perfectly but the line for the colour doesn't...
Another thing I've tried is this code, based on a search I have done in the forum, but doesn't work neither:
MyText.visProperties1.SetRealColor 255, 0, 0, 1
Any ideas?
(I'm coding on VBA)





RE: Set text color Drafting Macro
CODE --> CATScript
Regards
Fernando
https://picasaweb.google.com/102257836106335725208 - Romania
https://picasaweb.google.com/103462806772634246699... - EU
RE: Set text color Drafting Macro
What I'm trying to do is put in red only the word I've just written.
Sub InsertText()
Set MyDrawingDoc = CATIA.ActiveDocument
Set MyDrawingSheets = MyDrawingDoc.Sheets
Set MyDrawingSheet = MyDrawingSheets.ActiveSheet
Dim MyDrawingViews As DrawingViews
Set MyDrawingViews = MyDrawingSheet.Views
Dim InsertText As String
InsertText = InputBox("Insert Text")
'Set myText.... As DrawingText - adding texts
Set myText = MyDrawingViews.ActiveView.Texts.Add(InsertText, 33, 75)
myText.SetFontSize 0, 0, 20
myText.VisProperties.SetRealColor 255, 0, 0, 0 'ERROR
End Sub
RE: Set text color Drafting Macro
selection1.Search "CATDrwSearch.DrwText.TextString=*,all"
So, you can use immediately after inserting a specific search or adapt the code to your needs.
Regards
Fernando
https://picasaweb.google.com/102257836106335725208 - Romania
https://picasaweb.google.com/103462806772634246699... - EU
RE: Set text color Drafting Macro
CODE --> CATScript
Sub CATMain() Set MyDrawingDoc = CATIA.ActiveDocument Set MyDrawingSheets = MyDrawingDoc.Sheets Set MyDrawingSheet = MyDrawingSheets.ActiveSheet Dim MyDrawingViews As DrawingViews Set MyDrawingViews = MyDrawingSheet.Views Dim InsertText As String InsertText = InputBox("Insert Text") 'Set myText.... As DrawingText - adding texts Set myText = MyDrawingViews.ActiveView.Texts.Add(InsertText, 33, 75) myText.SetFontSize 0, 0, 20 '~ 'Change the color of the text in RED Set Drwselect = CATIA.ActiveDocument.Selection DrwSelect.Add myText DrwSelect.VisProperties.SetRealColor 255, 0, 0, 0 End SubRegards
Fernando
https://picasaweb.google.com/102257836106335725208 - Romania
https://picasaweb.google.com/103462806772634246699... - EU
RE: Set text color Drafting Macro
I didn't find the way of putting the variable in the following code...
selection1.Search "CATDrwSearch.DrwText.TextString= ____ "
Actually, I have to put a string followed by the variable, anyway... now works perfectly.
Thank you very much Berto.