Well the code I tried to show is not what I have actually coded it was just an attempt to illustrate the problem.onekk wrote: ↑Sat May 30, 2020 1:09 pmmaybe using the code tags will be a better way, the indentation is not shown, in your code, so it is difficult to see what is wrong.
It seems, that a PythonObject class must be derived from an existing FreeCAD class, to inherit some basic property, but I'm not an expert.
see maybe :
https://github.com/FreeCAD/FreeCAD/blob ... /Shapes.py
https://github.com/FreeCAD/FreeCAD/blob ... eatures.py
https://github.com/FreeCAD/FreeCAD/blob ... bspline.py
For some hint on how to make an object.
Hope it helps
Code: Select all
class GDMLTessellated(GDMLcommon) : def __init__(self, obj, material) : obj.addProperty('App::PropertyBool','editable','GDMLTessellated', \ 'Editable').editable = False obj.addExtension('App::OriginGroupExtensionPython', self) obj.addProperty("App::PropertyEnumeration","material", \ "GDMLTessellated","Material") setMaterial(obj, material) self.Type = 'GDMLTessellated' self.Vertex =  self.Faces =  self.Object = obj obj.Proxy = self def onChanged(self, fp, prop): '''Do something when a property has changed''' #print(fp.Label+" State : "+str(fp.State)+" prop : "+prop) if 'Restore' in fp.State : return if prop in ['material'] : fp.ViewObject.ShapeColor = colourMaterial(fp.material) if prop in ['editable'] : if editable == True : addProperties() if prop in ['lunit'] : self.createGeometry(fp) def addVertex(self,v) : self.Vertex.append(v)
Code: Select all
tess = GDMLTessellated(obj,0)
Tried adding @expose as per the example in the post but get error expose not defined.keithsloan52 wrote: ↑Sun May 31, 2020 5:53 amThis seems to have some relevance https://forum.freecadweb.org/viewtopic. ... 1&start=10
As I don't really understand the use of proxy maybe I am missing a trick @wmayer