On 15/05/2013 at 06:44, xxxxxxxx wrote:
Here is the code:
import c4d
import os
import sys
from c4d import gui, plugins, bitmaps, documents, utils
from c4d.modules import mograph
PLUGIN_ID = 1000003 # Test ID
#Global Variables
FOOT_X = 16.0
FOOT_Y = 4.0
FOOT_Z = 24.0
#Groups
GroupFoot = 20100
#CreateObjectMethods
def AddLeftFoot(doc) :
global L_Foot
L_Foot = c4d.BaseObject(c4d.Ocube)
L_Foot[c4d.PRIM_CUBE_LEN, c4d.VECTOR_X] = FOOT_X
L_Foot[c4d.PRIM_CUBE_LEN, c4d.VECTOR_Y] = FOOT_Y
L_Foot[c4d.PRIM_CUBE_LEN, c4d.VECTOR_Z] = FOOT_Z
L_Foot[c4d.ID_BASEOBJECT_REL_POSITION,c4d.VECTOR_Y] = FOOT_Y/2
L_Foot.SetName('L_Foot')
doc.InsertObject(L_Foot)
c4d.EventAdd()
#SliderDialog
class InitializeSubDialog(c4d.gui.SubDialog) :
def CreateLayout(self) : #Layout
self.SetTitle("Character Values")
#Group Foot
self.GroupBegin(GroupFoot, c4d.BFH_SCALEFIT, 2, 0, "Foot")
self.GroupBorderSpace(5, 5, 5, 5)
self.GroupBorder(c4d.BORDER_GROUP_IN)
self.AddStaticText(0, c4d.BFH_LEFT, 0, 0, "Foot_X", 0)
self.AddEditSlider(20101, c4d.BFH_SCALEFIT, 500, 0)
self.GroupEnd()
return True
def InitValues(self) : #Initialize Layout Values (Called when the dialog is initialized by the GUI.)
self.SetReal(id = 20101, value = None, min = 5.0, max = 20.0, step = 1.0, format = c4d.FORMAT_METER)
return True
def Command(self, id, msg) : #Commands
global L_Foot
if (id == 20101) : #Foot_X SLider
FOOT_X = self.GetReal(20101)
L_Foot[c4d.PRIM_CUBE_LEN, c4d.VECTOR_X] = FOOT_X
c4d.EventAdd()
return True
#InitialDialog
class InitializeDialog(c4d.gui.GeDialog) :
def CreateLayout(self) : #Layout
self.SetTitle("Character Creator")
self.AddStaticText(0, c4d.BFH_CENTER, 0, 0, "GENDER", 0)
self.AddComboBox(10001, c4d.BFH_CENTER, 200, 0)
self.AddChild(10001, 0, "MALE")
self.AddChild(10001, 1, "FEMALE")
self.AddSeparatorH(200, c4d.BFH_CENTER)
self.AddButton(10002, c4d.BFH_CENTER, 150, 0, "Create Character")
return True
def InitValues(self) : #Initialize Layout Values (Called when the dialog is initialized by the GUI.)
return True
def Command(self, id, msg) : #Commands
if (id == 10002) : #Button Create Character
GENDER = self.GetLong(10001)
print GENDER
doc = c4d.documents.GetActiveDocument()
AddLeftFoot(doc)
InitializeSubDialog().Open(dlgtype = c4d.DLG_TYPE_ASYNC, pluginid = PLUGIN_ID, defaultw = 500, defaulth = 600)
return True
c4d.EventAdd()
return True
class Initialize(c4d.plugins.CommandData) :
dialog = None
def Init(self, op) :
return True
def Message(self, type, data) :
return True
def Execute(self, doc) :
if self.dialog is None:
self.dialog = InitializeDialog()
return self.dialog.Open(dlgtype = c4d.DLG_TYPE_ASYNC, pluginid = PLUGIN_ID, defaultw = 200, defaulth = 160)
if __name__ == "__main__":
bmp = c4d.bitmaps.BaseBitmap()
dir, file = os.path.split(__file__)
fn = os.path.join(dir, "res", "IconChar.tif")
bmp.InitWith(fn)
print "Character Creator Loaded."
result = plugins.RegisterCommandPlugin(PLUGIN_ID, "Character Creator", 0, bmp, "Character Creator", Initialize())