At first attempt, it just works like sketch object and can edit and add lines, constraints etc.
But, it seems I can't work it like sketch object e.g. .addgeometry .addConstraints .setDriving... etc.
(also can't find seteditormode in earlier post)
I think I have misunderstood some fundamentals...?
Code: Select all
# Sketcher Python Object
import FreeCAD, FreeCADGui, Sketcher
App = FreeCAD
Gui = FreeCADGui
class SketchFeature: # class SketcherClass: in wmayer's example
def __init__(self, obj):
obj.addProperty("App::PropertyLinkList","Sketches","Sketches","Master Sketches")
obj.Proxy = self
def execute(self, fp):
FreeCAD.Console.PrintMessage("Execute completed before recompute ")
fp.recompute() # when used inside the execute() method of a custom feature class it invokes the method of the C++ base class
def onChanged(self, fp, prop):
'''Do something when a property has changed'''
FreeCAD.Console.PrintMessage("Change property: " + str(prop) + "\n")
# def __setstate__(self, state):
def __setstate__(self, res):
# self.object.setEditorMode("MapMode",1) # Not OK
# self.Object.setEditorMode("MapMode",1) # Not OK
# self.setEditorMode("Constraints",2) # Not OK
return None
Code: Select all
s=App.ActiveDocument.addObject("Sketcher::SketchObjectPython")
skf=SketchFeatureTemplate.SketchFeature(s)
s.ViewObject.Proxy=0
Typing s. return nothing above...see screen capture-2.
Thanks for any hints!
[EDIT]
As it is possibly a bug:-
OS: Linux
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.17.12920 (Git)
Build type: None
Branch: master
Hash: 8faa9f38bb70a598afc2bc39ea1645d416ab057e
Python version: 2.7.6
Qt version: 4.8.6
Coin version: 4.0.0a
OCC version: 7.1.0
Locale: English/UnitedStates (en_US)