select a polygon
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 27/03/2012 at 08:46, xxxxxxxx wrote:
this few lines create a cube, resize it, ctso it and insert it into your document.
import c4d from c4d import gui, utils def main() : obj = c4d.BaseObject(c4d.Ocube) obj[c4d.PRIM_CUBE_LEN] = c4d.Vector(30,30,100) res = utils.SendModelingCommand(command = c4d.MCOMMAND_CURRENTSTATETOOBJECT, list = [obj], mode = c4d.MODELINGCOMMANDMODE_ALL, bc = c4d.BaseContainer(), doc = doc)[0] doc.InsertObject(res) c4d.EventAdd() if __name__=='__main__': main()
for the rest follow the link i have given to you in my previous post, your five steps won't be
five lines of code. you will have to use smc and define the basecontainers for some of the
modelling commands.come back when you get stuck.
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 27/03/2012 at 08:54, xxxxxxxx wrote:
thanks you, i'll try this now.
What is the best way to coding in python inside cinema 4d and have also the undo/redo functions? -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 27/03/2012 at 09:00, xxxxxxxx wrote:
an external editor is the best way, but for the beginning i would stick with the builtin editor,
as you will have to execute the scipt often to find your syntax errors. i am using sublimetext2 ,
another popular choice would be notepad++. -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 27/03/2012 at 09:05, xxxxxxxx wrote:
there is that for MAC? is the code ready to use for C4D (i mean if i code the script, when i run c4d i've to update the code?)
How can i select the front polygon face of the cube created by the code you have indicated all i can see is code to select the edge but not the full polygon (made by 2 edges)?
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 27/03/2012 at 09:30, xxxxxxxx wrote:
selections are references in python, so you will set a polygon selection this way :
sel = obj.GetPolygonS() sel.Select(2)
changing the baseselect you got returned from GetPolygonS will also change the actual selection.
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 27/03/2012 at 13:28, xxxxxxxx wrote:
i've tried to do this:
import c4d
from c4d import gui, utilsdef main() :
obj = c4d.BaseObject(c4d.Ocube)
obj[c4d.PRIM_CUBE_LEN] = c4d.Vector(30,30,100)
res = utils.SendModelingCommand(command = c4d.MCOMMAND_CURRENTSTATETOOBJECT,
list = [obj],
mode = c4d.MODELINGCOMMANDMODE_ALL,
bc = c4d.BaseContainer(),
doc = doc)[0]
doc.InsertObject(res)
c4d.EventAdd()
doc.SetActiveObject(res)
sel = res.GetPolygonS()
sel.Select(2)
c4d.EventAdd()if __name__=='__main__':
main()but i've two problem:
- i do execute button but nothing happen
- i try to select the node the unselect and click execute and it create 2-3 cubes once
- no polygons are selected
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 27/03/2012 at 14:34, xxxxxxxx wrote:
doc.SetActiveObject(res)
doesn't work, res is the variable containing the result returned by utils.SendModelingCommand and not a reference to the object in your object manager.
def main() : obj = c4d.BaseObject(c4d.Ocube) obj[c4d.PRIM_CUBE_LEN] = c4d.Vector(30,30,100) res = utils.SendModelingCommand(command = c4d.MCOMMAND_CURRENTSTATETOOBJECT, list = [obj], mode = c4d.MODELINGCOMMANDMODE_ALL, bc = c4d.BaseContainer(), doc = doc)[0] sel = res.GetPolygonS() sel.Select(2) doc.InsertObject(res) c4d.EventAdd()
this would be the shortest way. even if doc.SetActiveObject(res) would be a propper statement, it would have no impact on your further code as selecting an object does not have any impact on your further python code. Baseodocument.SearchObject() would be the method you would use to get an object from the objectmanager. it returns an baseobject you could modify.
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 27/03/2012 at 22:28, xxxxxxxx wrote:
Btw, nice Editor Ferdinand! I guess this will be my favorite editor in the future.
Thanks!-Niklas
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 28/03/2012 at 06:22, xxxxxxxx wrote:
how can i do a selection for one face of the cube using c4d.utils.SendModelingCommand(command = c4d.ID_MODELING_LIVESELECTION,...
i can't figure it out
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 28/03/2012 at 06:42, xxxxxxxx wrote:
just use the last snippet i have posted, it will create a cube, scale it, convert it and select the face
with the index 2. please read the sdk, the python sdk is relative easy to understand despite some
weaknesses of it. i have explained the way selections are used within python, but you have actually
try to understand what i try to explain. -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 28/03/2012 at 07:37, xxxxxxxx wrote:
Littledevil, i always thanks you for your interest on my issue but using this code:
sel = res.GetPolygonS() sel.Select(2) doc.InsertObject(res) c4d.EventAdd()
but I get this error:
c4d.BaseObject' object has no attribute 'GetPolygonS'
Infact i've searched in SDK and BaseObject has not that function -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 28/03/2012 at 10:07, xxxxxxxx wrote:
it is a member of c4d.polygonobject which inherits from c4d.baseobject. res in my given example
is always a polygonobject, so we don't have to check. but if you just allocate some baseobject
it won't work, just as you couldn't select a polygon on a parametric object within c4d. -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 29/03/2012 at 00:37, xxxxxxxx wrote:
so do I need to type casting it? If so this doens't work:
poly_obj = c4d.PolygonObject(res)
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 29/03/2012 at 02:35, xxxxxxxx wrote:
Finally i'm been able to make my script works!!!
I'm very happy. The only problem i've is just when i click on "Execute" button the main function is called twince! why? -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 29/03/2012 at 05:32, xxxxxxxx wrote:
Originally posted by xxxxxxxx
so do I need to type casting it? If so this doens't work:
poly_obj = c4d.PolygonObject(res)
the constructor of PolygonObject doesn't accept BaseoObjects as paramters, its parameters
are PolygonObject(pcnt, vcnt). but apart this fact we are meant to use BaseObject(type)
to allocate objects in c4d. a new polygon object should be created this way :myPolygonObject = c4d.BaseObject(Opolygon)
read the c++ sdk baseoject description, it includes an extensive list of allocatable types in c4d.
and post your code or nobody will be able to help you. -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 29/03/2012 at 06:48, xxxxxxxx wrote:
It's very difficult to try to understand the sdk becouse is very little described and google/forum have very poor information about that and no examples around the net, but i'm understanding with big difficult and little by little.
Thanks