On 07/03/2018 at 17:37, xxxxxxxx wrote:
Hi,
I'm trying to create a simple gui to create a cube. Currently, it looks like this
https://www.dropbox.com/s/upcc1wykyall32a/c4d057_createCube02.jpg?dl=0
Based on the image above, my current problem is adding the labels in the side. And adding a cm to the number boxes.
Is there a way I can do that?
I tried using the .AddStaticText but it breaks the code and removes all the input boxes in the GUI.
Here is the working script:
import c4d
from c4d import gui
#Welcome to the world of Python
nameBox = 1001
sliderBox = 1002
numberBox = 1003
Create = 1004
class CreateCube(gui.GeDialog) :
def CreateLayout(self) :
self.SetTitle('Create Cube')
self.AddEditText(nameBox, c4d.BFH_SCALEFIT)
self.AddEditSlider(sliderBox, c4d.BFH_SCALEFIT)
self.AddEditNumber(numberBox, c4d.BFH_SCALEFIT)
self.AddButton( Create, c4d.BFH_SCALEFIT , name='Create Cube')
self.GroupEnd()
return True
def Command (self, id, msg) :
if id==Create:
cube = c4d.BaseObject(c4d.Ocube)
text_value = self.GetString(nameBox)
slider_value = self.GetInt32(sliderBox)
number_value = self.GetInt32(numberBox)
cube[c4d.ID_BASELIST_NAME]=text_value
cube[c4d.PRIM_CUBE_LEN,c4d.VECTOR_X]=slider_value
cube[c4d.PRIM_CUBE_LEN,c4d.VECTOR_Y]=slider_value
cube[c4d.PRIM_CUBE_LEN,c4d.VECTOR_Z]=slider_value
cube[c4d.PRIM_CUBE_SUBX]=number_value
cube[c4d.PRIM_CUBE_SUBY]=number_value
cube[c4d.PRIM_CUBE_SUBZ]=number_value
self.cube = cube
self.Close()
return True
def main() :
dialog = CreateCube()
dialog.Open(c4d.DLG_TYPE_MODAL_RESIZEABLE, defaultw=200,defaulth=200)
cube = dialog.cube
doc.InsertObject(cube)
c4d.EventAdd()
if __name__=='__main__':
main()
Thank you for your time.