I'm improving a project.When I copy an object, the new object will display this error, but my original object is OK.The "Data-Property" of the new object also displays the "shapetype" attribute. What's the reason?
File "Front_Surface.py", line 66, in onChanged
if obj.shapetype == "Conic":
<class 'AttributeError'>: 'FeaturePython' object has no attribute 'shapetype'
Code: Select all
class FrontSurface:
def __init__(self):
doc = FreeCAD.ActiveDocument
obj= doc.addObject("Part::FeaturePython", "FrontSurface")
obj.addProperty("App::PropertyEnumeration","shapetype","Shape","specifies type").shapetype=["Conic","Cylinder","Asphere"]
obj.addProperty("App::PropertyFloat", "curv", "Shape", "central curvature").curv = 0
obj.addProperty("App::PropertyFloat", "cc", "Shape", "conic constant").cc = 0
def onChanged(self, obj, prop):
proplist = ["curv", "cc"]
if prop in proplist:
if obj.shapetype == "Conic":
obj.shapeclass.curvature.set_value(obj.curv)
obj.shapeclass.conic.set_value(obj.cc)