Making Spline Mask Editable

On 01/11/2013 at 10:44, xxxxxxxx wrote:

I'm running this in a generator object.

I want to make the Spline Mask editable so I can do more to it, however it returns an empty spline object.

import c4d
from c4d.utils.noise import C4DNoise
  
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() :
    obj = c4d.BaseObject(c4d.Osplinetext)
    objMask = c4d.BaseObject(1019396) #Spline Mask
    
    obj[c4d.PRIM_TEXT_TEXT] = "Test"
    objTemp1 = MakeEditable(obj)
    
    objTemp1[c4d.SPLINEOBJECT_INTERPOLATION] = 4
    objTemp1[c4d.SPLINEOBJECT_ANGLE] = 90
    objTemp1[c4d.SPLINEOBJECT_MAXIMUMLENGTH] = 25
 
    objTemp1.InsertUnder(objMask)
    
    obj3 = MakeEditable(objMask) #This line seems to kill it...
   
    obj3.Message (c4d.MSG_UPDATE)
    c4d.EventAdd()
    return obj3
    #return objMask #this works when it hasn't been make editable yet

Any hints as to what I'm missing would be wonderful. Thanks so much,

Chris Schmdit

On 01/11/2013 at 11:06, xxxxxxxx wrote:

Hi Chris,

I can reproduce your problem and reported to the developers. There'll be an answer soon. One note on
your code though: Do not call c4d.EventAdd() from a Python Generator or Tag, only from commands (aka
scripts). It is 1. completely redundant and 2. can lead to an infinite unbreakable refresh of your scene.

Best,
-Niklas

On 02/11/2013 at 15:30, xxxxxxxx wrote:

@ CHris,

print obj3 did give me <c4d.SplineObject object called 'Spline Mask/Spline' with ID 5101 at 0x0E541620> so it is working

adding doc.InsertObject(obj3) will insert an edited spline

You can use obj3 as global variable to use in another function.

import c4d
from c4d.utils.noise import C4DNoise
  
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 ReturnObj3() :
    global obj3 #declaring this variable as global will make it available in other functions
    obj = c4d.BaseObject(c4d.Osplinetext)
    objMask = c4d.BaseObject(1019396) #Spline Mask
    
    obj[c4d.PRIM_TEXT_TEXT] = "Test"
    objTemp1 = MakeEditable(obj)
    
    objTemp1[c4d.SPLINEOBJECT_INTERPOLATION] = 4
    objTemp1[c4d.SPLINEOBJECT_ANGLE] = 90
    objTemp1[c4d.SPLINEOBJECT_MAXIMUMLENGTH] = 25
 
    objTemp1.InsertUnder(objMask)
    
    obj3 = MakeEditable(objMask)
   
    obj3.Message (c4d.MSG_UPDATE)
    c4d.EventAdd()
    
    
def main() :
    ReturnObj3()
    print obj3
    
if __name__=='__main__':
    main()

Hope this help

On 04/11/2013 at 12:24, xxxxxxxx wrote:

Thanks for the replies guys!

I solved that problem with a connect object instead of a spline mask before I saw the post from Focus3D. I have another question to follow up though.

I've simplified the code as much as I can. If I remove a point, and update the number of points in the spline the generator is still returning a phantom point.

Insert this code into a Python Generator, make it editable, select all the points and move them. There is a 'point' that can't be selected. Stuck here... any help would be killer.

import c4d
import math
from c4d.utils.noise import C4DNoise
#Welcome to the world of Python
  
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() :
    obj = c4d.BaseObject(c4d.Osplinetext)
    obj[c4d.PRIM_TEXT_TEXT] = "S"
    
    obj2 = MakeEditable(obj)
    obj2[c4d.SPLINEOBJECT_TYPE] = 0 #lin
    
    basePoints = obj2.GetAllPoints()
    pointCount = obj2.GetPointCount()
    pointList1 = []
    count3 = 0
    while (count3 < pointCount) :
  
        if(count3 != 0) :
            print "Point ", count3, basePoints[count3]," added"
            newPoint = basePoints[count3]
            pointList1.append(newPoint)
        count3 += 1
   
    print len(pointList1)
    obj2.ResizeObject(len(pointList1))
    obj2.SetAllPoints(pointList1)
    obj2.Message (c4d.MSG_UPDATE)
    return obj2

Thanks again!

On 04/11/2013 at 13:09, xxxxxxxx wrote:

Well I seem to have gotten around that by initiating a new spline object. Would still be curious why the first example didn't work though...

    obj3 = c4d.SplineObject(len(pointList1), c4d.SPLINETYPE_LINEAR)
    obj3[c4d.SPLINEOBJECT_CLOSED] = True
    obj3.SetAllPoints(pointList1)
    obj3.Message (c4d.MSG_UPDATE)
    return obj3

On 05/11/2013 at 16:30, xxxxxxxx wrote:

@Chris,
Which version of Cinema4D are you using?
I tried your first code with c4d R13.061 with the Python Generator and it is working.
try to close and restart cinema 4d.

On 06/11/2013 at 10:07, xxxxxxxx wrote:

I'm currently tinkering in R14

On 06/11/2013 at 17:53, xxxxxxxx wrote:

@Chris,
for R14, you are right it is not working but if you use command = c4d.MCOMMAND_CURRENTSTATETOOBJECT instead of command = c4d.MCOMMAND_MAKEEDITABLE, it will work.
Also try to use myDoc=c4d.documents.GetActiveDocument().

Hope this will help.

On 08/11/2013 at 11:45, xxxxxxxx wrote:

Thanks Focus, learning little by little.