PDA

View Full Version : Python: Set Font in MoText Object


ernia
12-31-2011, 09:33 PM
Hello,
How can I set a font in the MoText object?

I have the ID:
MoText[c4d.PRIM_TEXT_FONT]
, but I don't know what data structure to set it to. For example:
MoText[c4d.PRIM_TEXT_FONT] = ?

Thanks!
Arik

donelgreeko
01-01-2012, 12:56 PM
Hi,

it accepts a FontData object.

Try this code snippet:


import c4d

font=c4d.FontData()
fontbc=c4d.gui.FontDialog()
font.SetFont(fontbc)
MoTextObject[c4d.PRIM_TEXT_FONT]=font
c4d.EventAdd()


Cheers, donelgreeko

Scott Ayers
01-01-2012, 03:48 PM
Can we set the font without using the GUI?
# Type Error: Object does not support item assignment
fontbc = font[c4d.FONTCHOOSER_DATA] "Alaska"

-ScottA

ernia
01-01-2012, 04:11 PM
Thanks Mr. Greeko!

That's the problem I initially ran into.
Looks like the font dialog box sends a container with the new font and python just sets that container in c4d. Can we just set the font in the container directly? Where in the container would it be?

NiklasR
01-01-2012, 06:47 PM
Sebastian, will the FontData class be added to Cinema 4D R12, too ? By now, your code is only suitable for R13.

Thanks,
Niklas

CGTalk Moderation
01-01-2012, 06:47 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.