Please Correct my code! SUBOBJECTS



  • On 20/04/2017 at 08:10, xxxxxxxx wrote:

    I need two nulls in my plugin.
    What i`m doing wrong? Sorry for that, but i just starting learning.)))))
    In python many underwater rocks or .....))) I'm just stupid for this. It is not enough information how to make subobjects in the plugin, even fewer code examples. (Sorry for my English))))))))))
    )

    class NullObject(plugins.ObjectData) :

    def __init__(self, PosiX = 0, PosiZ = 0) :
            self.PosiX = PosiX
            self.PosiZ = PosiZ

    def Build(self) :

    self.null = c4d.BaseObject(c4d.Onull)
            self.null.SetName('null 1 ')
            doc.InsertObject(self.null)

    self.null_t = c4d.BaseObject(c4d.Onull)
            self.null_t.SetName('null 2 ')
            doc.InsertObject(self.null_t, self.null)

    return self.null.GetClone()

    def Init(self, op) :
            op.SetName("NullObject")
            return True

    def GetVirtualObjects(self, op, hierarchyhelp) :
            op = c4d.BaseObject(c4d.Onull)

    ret = self.Build()  
            ret.InsertUnder(op)

    return ret

    if __name__ == "__main__":
        c4d.EventAdd()
        dir, file = os.path.split(__file__)
        icon = bitmaps.BaseBitmap()
        icon.InitWith(os.path.join(dir, "res", "icon.png"))
        plugins.RegisterObjectPlugin(id=PLUGIN_ID, str="NullObject",
                                    g=NullObject,
                                    description="NullObject", icon=icon,
                                    info=c4d.OBJECT_GENERATOR | c4d.OBJECT_INPUT,)



  • On 20/04/2017 at 21:28, xxxxxxxx wrote:

    Nope.



  • On 20/04/2017 at 23:01, xxxxxxxx wrote:

    I found a solution

    class NullObject(plugins.ObjectData) :

    def __init__(self, PosiX = 0, PosiZ = 0) :
            self.PosiX = PosiX
            self.PosiZ = PosiZ
            self.SetOptimizeCache(True)

    def Build(self) :
            doc = c4d.documents.GetActiveDocument()
            doc.StartUndo()

    self.null = c4d.BaseObject(c4d.Onull)
            self.null.SetName('Box ')
            doc.InsertObject(self.null)

    self.lowpolyIn = c4d.BaseObject(c4d.Onull)
            self.lowpolyIn.SetName('Em Lowpoly model (Collider)')
            doc.InsertObject(self.lowpolyIn,self.null)

    self.highpolyIn = c4d.BaseObject(c4d.Onull)
            self.highpolyIn.SetName('Em Highpoly model')
            doc.InsertObject(self.highpolyIn,self.null)

    self.wheelsIn = c4d.BaseObject(c4d.Onull)
            self.wheelsIn.SetName('Em Wheels')
            doc.InsertObject(self.wheelsIn,self.null)

    return self.null
            doc.EndUndo()

    def Init(self, op) :
            op.SetName("NullObject")
            return True

    def GetVirtualObjects(self, op, hierarchyhelp) :
            dirty = op.CheckCache(hierarchyhelp) or op.IsDirty(c4d.DIRTY_DATA)
            if dirty is False:
                return op.GetCache(hierarchyhelp)

    ret = self.Build()  
            ret.InsertUnder(op)

    return ret

    def Execute(self, op, doc, bt, priority, flags) :
            return True

    But here's how it works: https://drive.google.com/file/d/0B6LsRuoqyxhTQVA1WFh4ZWVNbnM/view?usp=sharing



  • On 21/04/2017 at 05:30, xxxxxxxx wrote:

    Hi,

    I'm glad your problem is solved.

    I'd just like to remind about some rules in these forums. MAXON's SDK Team does not debug code, usually. The line is fuzzy here, because often questions get asked, where it's not clear if it's a problem with Cinema's SDKs or a bug. But we will certainly never do so without a description of the actual goal, a description of the problem and where it goes wrong in the code. Of course you can still post questions like this here in the forums, I just want to point out you will need the help of our community in these cases. And in order to get that, it might be a good idea to ask a bit more politely. While this might be a simple language issue, "Correct my code!" sounds a bit harsh to me (neither being a native speaker myself), maybe an additional "please" could help a long way...

    I hope, you don't mind.



  • On 21/04/2017 at 18:23, xxxxxxxx wrote:

    Ok. Sorry if i be too harsh


Log in to reply