cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Change Font Color with APIs

PBugnet
Super Contributor

Hello,

 

I would like to change the font color of an object type (Message) on a diagram by APIs.

 

For this, I found the method TextColorSet on a MegaDrawingItem but that don't work : The value is changed but there is no effect on the diagram.

 

The code is :

 

for each oDiag in Getselection("Select diagram where _idabs 'Bsk7Rf2GIL3D'")
 set MyDrawing = oDiag.drawing("RW")
 for each oDObjects in MyDrawing.DrawingObjects
   if GetObjectFromID(oDObjects.RepositoryObject.GetClassID).GetProp("_idabs") = "GsUiS9B5iCQ0" then 'Message
    set oDFont = oDObjects.DrawingItem.Font
    print oDObjects.DrawingItem.Font.TextColor
oDFont.TextColorSet 0,128,0,100 oDObjects.DrawingItem.Font = oDFont
print oDObjects.DrawingItem.Font.TextColor
end if next MyDrawing.Flush next

 

Someone has an idea ?

 

Thank you,

Philippe

 

2 Replies

selhatimi
MEGA
MEGA

hello,

 

you can use the example of code bellow :

 

Set oDiag =
GetObjectFromId("~x9silfhD2bB3[Logigramme]")

Set oDrw = oDiag.drawing("RW")

For Each oDO In oDrw.DrawingObjects

If GetObjectFromID(oDO.RepositoryObject.GetClassID).GetProp("_idabs")
= "GsUiS9B5iCQ0" Then 'Message

Set oDIMsg = oDO.DrawingItem

For Each oSubDI In oDIMsg.SubDrawingItems

If oSubDI.DrawClassName = "ModeObjAttribute" Then

set oDFont = oSubDI.Font

oDFont.TextColorSet 0,100,200,100

oSubDI.Font = oDFont

End If

Next

End If

Next

oDrw.Flush

Sami

gquiniou
Retired

You can have a look at this topic : it is the same issue but with the background color

http://community.mega.com/t5/Technical-Product/Diagram-APIs-DrwText-BackgroundColorSet/m-p/1069#M156