MoGraph "alphabet" export each letter

Become a member of the CGSociety

Connect, Share, and Learn with our Large Growing CG Art Community. It's Free!

THREAD CLOSED
 
Thread Tools Search this Thread Display Modes
  02 February 2013
MoGraph "alphabet" export each letter

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()

Last edited by tjoynt : 02 February 2013 at 06:31 PM.
 
  02 February 2013
Thread automatically closed

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.
__________________
CGTalk Policy/Legalities
Note that as CGTalk Members, you agree to the terms and conditions of using this website.
 
Thread Closed share thread



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
CGSociety
Society of Digital Artists
www.cgsociety.org

Powered by vBulletin
Copyright 2000 - 2006,
Jelsoft Enterprises Ltd.
Minimize Ads
Forum Jump
Miscellaneous

All times are GMT. The time now is 02:14 AM.


Powered by vBulletin
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.