On 30/07/2015 at 02:40, xxxxxxxx wrote:
I am currently trying to create an input box, where someone can put a number in and then the number will be used for different kind of things.
So I created this field.
x = gui.InputDialog("Object ID", "ID")
that works fine, but I am always getting a string back. But I need an integer or an vector. So how can I tell my InputDialog, that this should be an integer or a vector? I know that I can create a vector by using c4d.Vector(). But how do I connect it with the InputDialog?
Would be great, if someone could help me.
Thanks a lot
On 30/07/2015 at 04:36, xxxxxxxx wrote:
non elegant and silly example:
from c4d import gui
def main() :
s = gui.InputDialog("Object ID", "10.5 25 3")
x, y, z = s.split(), s.split(), s.split()
print c4d.Vector(float(x), float(y), float(z))
Learn how to work http://www.tutorialspoint.com/python/python_strings.htm
and int/float and etc. http://www.tutorialspoint.com/python/python_numbers.htm
On 31/07/2015 at 02:35, xxxxxxxx wrote:
there are no pre-made dialogs for numeric values. Ilya's solution is one way and definitely works, but this also may get tedious to check and care for user input errors.
Another option would be to create your own dialog using GeDialog class with proper gadgets for floats or vectors. There are several examples in the Python SDK setting up custom dialogs. For example the Py-MemoryViewer.
On 31/07/2015 at 06:10, xxxxxxxx wrote:
Somewhere over forum, Niklas post solution how to use resources from Resedit solution inside c4d without plug-in skeleton.
Anna, you can prepare simple dialogs in resedit with gadget - Vector(id = 23)*, add functions and invoke in c4d environment.
It will add custom gui to scripts.
* - which Andreas pointed
On 01/08/2015 at 07:27, xxxxxxxx wrote:
Hey you two,
thanks a lot for your answers, it is really helpful I am currently reading through all the infos and trying to write something to show. I guess I will come back with lots of more questions.
Thanks a lot again
On 01/08/2015 at 08:53, xxxxxxxx wrote:
another primitive example, select object and execute script:
from c4d import gui
class Test_Dlg(gui.GeDialog) :
def addvector(self) :
doc = c4d.documents.GetActiveDocument()
op = doc.GetActiveObject()
if not op: return False
def CreateLayout(self) :
#creat the layout of the dialog
self.GroupBegin(GROUP_ID1, c4d.BFH_SCALEFIT, 4, 1)
self.AddStaticText(ST, c4d.BFH_SCALE, name="Value of vector data:")
self.GroupBegin(GROUP_ID1, c4d.BFH_SCALEFIT, 2, 1)
self.AddButton(BUTTON1, c4d.BFH_SCALE, name="Apply")
def InitValues(self) :
#initiate the gadgets with values
def Command(self, id, msg) :
#handle user input
dlg = Test_Dlg()
dlg.Open(c4d.DLG_TYPE_MODAL, xpos=600, ypos=350, defaultw=400, defaulth=100)