create a beveled cube

THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

On 16/06/2011 at 18:08, xxxxxxxx wrote:

ok, so i have tried a number of different things but i still cant get the SendModellingCommand to work. I have simplified my idea drastically to try and get the basic idea working, but i still am not doing something right. Essentially, all i want to do right now, is create a beveled cube using a python object. here is my scene file. i got it to stop crashing, but it will not bevel.
any help is greatly appreciated.

here is a link to download the c4d file
http://www.sendspace.com/file/zsg754

and here is the code within the python generator:

import c4d
#Welcome to hell

def main() :
  doc = c4d.documents.GetActiveDocument
  cube = c4d.BaseObject(c4d.Ocube)
  null = c4d.BaseObject(c4d.Onull)
  cube1 = MakeEditable(cube)
  cube2 = Bevel(cube1,30)
  return cube2

def ExtrudeInner(obj,offset,doc) :
  pass

def Bevel(op,offset) :
  bc = c4d.BaseContainer()
  bc[2042] = offset
  if(not op) | op.CheckType(c4d.Opolygon) | op.CheckType(c4d.Ospline) : return op
  doc = c4d.documents.BaseDocument()
  doc.InsertObject(op[1], None, None)
  obj = c4d.utils.SendModelingCommand(
                            command = 450000005,#bevel
                            list = obj,
                            settings = bc,
                            doc = doc )
  return obj[1]

def MakeEditable(op) :
  import c4d
  if (not op) | op.CheckType(c4d.Opolygon) | op.CheckType(c4d.Ospline) : return op

op = [op.GetClone()]
  doc = c4d.documents.BaseDocument()
  doc.InsertObject(op[0],None,None)
  op = c4d.utils.SendModelingCommand(
                            command = c4d.MCOMMAND_MAKEEDITABLE,
                            list = op,
                            mode = c4d.MODELINGCOMMANDMODE_EDGESELECTION,
                            doc = doc )
  return op[0]

THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

On 17/06/2011 at 03:00, xxxxxxxx wrote:

First of all, use ID's instead of Integers
instead of "2042" use "c4d.MDATA_BEVEL_OFFSET2"
But with "450000005" you seem to be right, there doesnt seem to be a id in the c4d module. O.o

Second: hehe my MakeEditable Function 😜
Third: Do you think about what you are doing when you modify a Function ? ^^

    bc[2042] = offset  
  if(not op) | op.CheckType(c4d.Opolygon) | op.CheckType(c4d.Ospline) : return op  
  doc = c4d.documents.BaseDocument()

The middle line doesn't make sense. It MUST be Polygon object to be beveled, not the other way round.

    obj = c4d.utils.SendModelingCommand(  
                            command = 450000005,#bevel  
                            list = obj,

Where the heck does that obj - variable come from ?
but you have never seen an exception because of this variable bacuase the function was ended before this part of the code was evaluated. (See above)

    doc.InsertObject(op[1], None, None)

why do you use __getitem__ here, and why with 1 ?!
op IS a baseObject in your case, not a list.

                             settings = bc,

"settings" is an unknow keyword for SendModelingCommand. The right keyword is called "bc".

    obj = c4d.utils.SendModelingCommand(  
                            command = 450000005,#bevel  
                            list = [op],  
                            bc = bc,  
                            doc = doc )  
  return obj[1]

If you would have read the SendModelingCommand documentation, you would have known that the return type of this Functions depends on its arguments.
In this case, they Modelingcommand is processed on the original object. The returnvalue is boolean value indicating wether the Execution was successful or not.

The correct code is as follows:

import c4d  
#Welcome to the world of Python  
  
def ExtrudeInner(obj,offset,doc) :  
  pass  
  
def Bevel(op,offset) :  
  bc = c4d.BaseContainer()  
  bc[c4d.MDATA_BEVEL_OFFSET2] = offset  
  bc[c4d.MDATA_BEVEL_MODE] = c4d.MDATA_BEVEL_MODE_LINEAR  
  if (not op) | (not op.CheckType(c4d.Opolygon)) : return op  
  doc = c4d.documents.BaseDocument()  
  doc.InsertObject(op, None, None)  
  print c4d.utils.SendModelingCommand(  
                            command = 450000005,#bevel  
                            list = [op],  
                            bc = bc,  
                            doc = doc,  
                            mode = c4d.MODIFY_EDGESELECTION )  
  return op.GetClone()  
  
def MakeEditable(op) :  
  if (not op) | op.CheckType(c4d.Opolygon) | op.CheckType(c4d.Ospline) : return op  
  
  op = [op.GetClone()]  
  doc = c4d.documents.BaseDocument()  
  doc.InsertObject(op[0],None,None)  
  op = c4d.utils.SendModelingCommand(  
                            command = c4d.MCOMMAND_MAKEEDITABLE,  
                            list = op,  
                            mode = c4d.MODELINGCOMMANDMODE_EDGESELECTION,  
                            doc = doc )  
  return op[0]  
  
def main() :  
  doc = c4d.documents.GetActiveDocument  
  cube = c4d.BaseObject(c4d.Ocube)  
  null = c4d.BaseObject(c4d.Onull)  
  cube1 = MakeEditable(cube)  
  cube2 = Bevel(cube1,10)  
  return cube2

Bevel object

THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

On 18/06/2011 at 21:23, xxxxxxxx wrote:

Wow, nux, all I can say is thank you. That was one of the most helpful posts I have ever recieved. not only did you fix the code but u helped me to understand where I was going wrong. Thank u so much dude. U rule.