CustomMeshObject and Python

hello,menno
i followed to experience custommeshobject with python. however, encounter a problem with error message ‘need public constractor’. can u help to take a look slight_smile:

custommesh.py (2.3 KB)

from System.Reflection import *
from System.Runtime.InteropServices import *
from Rhino.PlugIns import *
from Rhino.DocObjects import *
from Rhino.Geometry import *
from Rhino.DocObjects.Custom import *
from Rhino.Input.Custom import *
from System import *
from System.Collections.Generic import *
from Rhino import *
import rhinoscriptsyntax as rs
import clr
import scriptcontext,Rhino
from Rhino.Commands import *
from scriptcontext import doc
import Rhino,System
def drawmeshobject():  
    rc, objref = Rhino.Input.RhinoGet.GetOneObject("Select object", True, Rhino.DocObjects.ObjectType.AnyObject)
    if rc!=Rhino.Commands.Result.Success: return
    m = objref.Mesh()
    my = MyMeshObject(m)    
    # print my
    doc.Objects.Replace(objref, my)
    doc.Views.Redraw()
class MyMeshObject(CustomMeshObject):
    # def __init__():
        # pass
    # def MyMeshObject():
        # pass
    # def __init__(self):
        # pass
    def __init__(self,*args):
        if len(args)==1:
            try:
                # print args[0],type(args[0])
                # CustomMeshObject.__init__(args[0])
                # CustomMeshObject(args[0])
                # super(self,CustomMeshObject).__init__(args[0])
                # super(self,CustomMeshObject).CustomMeshObject(args[0])
                # super(self,CustomMeshObject)(args[0])
                self.SetMesh(args[0])
                self.__bb=args[0].GetBoundingBox(True)
                print self.__bb
                print 'self.Mesh',self.Geometry
                # self.Attributes=ObjectAttributes()
                # print 'self.Attributes',self.Attributes.ObjectColor,self.Attributes.LayerIndex ,self.Attributes.Name,self.Attributes.ObjectId  
            except Exception,e:
                print(str(e))
        else:
            super(self,CustomMeshObject).CustomMeshObject()
        # CustomMeshObject
        # required
    def OnDuplicate(self, source):
        other = source
        if None != other:
            self.__bb = other._bb
        super(self,CustomMeshObject).OnDuplicate(source)

def OnDraw(self, e):
    if self.__bb.IsValid:
        e.Display.DrawBox(self.__bb, Color.Red, 2)
    super(self,CustomMeshObject).OnDraw(e)
if __name__ == '__main__':
    drawmeshobject()

Creating a custom mesh object in Python is probably not possible hard to maintain due to the dynamic nature of Python.

Why do you need a custom mesh object? What problem does having a custom mesh object solve?