PDA

View Full Version : MoGraph "alphabet" export each letter


tjoynt
02-21-2013, 03:42 PM
This is x-posted from c4dcafe. I figured there might be some users here not there and vice versa. Sorry if that's frowned upon.

I'm trying to create a script where the user will set a specific font, run the script, and it will export out lowercase,uppercase, and numbers, as .OBJs.
Eventually I'd like to add simple materials and baking textures to it, but I just want to get the initial script down first.

I haven't found any good documentation on setting Font (i see it's sorta new in R13), but found one where the user selected an object and used that font.

Here's what I have hacked together so far. It currently keeps every letter, so only A works, and then every letter after has every previous letter...

I need to add some simple features initially:
- Choose font easier
- Name MoText as letter
- Delete previous letter

Any ideas?

import c4d import string from c4d import FontData from string import ascii_uppercase doc = c4d.documents.GetActiveDocument() selectedObj = doc.GetActiveObject() def main(): for i in range(0,3): letter = string.ascii_lowercase[i] MoText = c4d.BaseObject(1019268) font = selectedObj[c4d.PRIM_TEXT_FONT] MoText[c4d.PRIM_TEXT_TEXT] = letter MoText[c4d.PRIM_TEXT_FONT] = font doc.InsertObject(MoText) c4d.EventAdd() c4d.documents.SaveDocument(doc, c4d.storage.GeGetStartupPath()+"/"+letter+".obj", 0, c4d.FORMAT_OBJEXPORT) if __name__=='__main__': main()


UPDATE: Little update. Figured out how to delete stuff (why is there so much stuff not in the Python C4D Documentation?? and where can I find it all in one place?)
This does at minimum what I want. I need to work on collapsing the MoText into one single object, but I think I found that.
The next part is adding a simple material and baking it. I don't think that's going to be easy or possible.

import c4d
import string
from c4d import FontData
from string import ascii_uppercase

doc = c4d.documents.GetActiveDocument()
font=c4d.FontData()
fontbc=c4d.gui.FontDialog()
font.SetFont(fontbc)
def main():
for i in range(0,26):
letter = string.ascii_lowercase[i]
Text = c4d.BaseObject(1019268)
Text[c4d.PRIM_TEXT_TEXT] = letter
Text[c4d.PRIM_TEXT_FONT] = font
doc.InsertObject(Text)
c4d.EventAdd()
c4d.documents.SaveDocument(doc, c4d.storage.GeGetStartupPath()+"/"+letter+".obj", 0, c4d.FORMAT_OBJEXPORT)
Text.Remove()
if __name__=='__main__':
main()

CGTalk Moderation
02-21-2013, 03:42 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.