Thanks Werner. I will adapt this to my FemShellThicknessTaskPanel.wmayer wrote:You must return True. ...How to reproduce: Copy the code into the PythonKnsole, double click on the new object. Try to click on OK or Cancel the dialog stays open
New problems araises with my App::FeaturePython. Assumed the App::FeaturePython is a new Fem Object. I would like to be able to use drag and drop in a MechanicalAnalysis object. How do I get the classTypeID or what do I need to add in src/Mod/Fem/Gui/ViewProviderAnalysis.cpp in Line 181 (https://github.com/FreeCAD/FreeCAD/blob ... s.cpp#L181)
code for creation of a App::FeaturePython and MechanicalAnalysis to test drag & drop:
Code: Select all
# simple scripted object class definition:
class MyFeaturePython:
def __init__(self, obj):
"'''Add a custom property to the FeaturePython'''"
obj.addProperty("App::PropertyBool","MySwitch","Base","ToolTipSwitchMyFeaturePython")
obj.MySwitch = False
obj.Proxy = self
def execute(self, fp):
"'''Do something when doing a recomputation, this method is mandatory'''"
FreeCAD.Console.PrintMessage("Recompute MyFeaturePython\n")
class _ViewProviderMyFeaturePython:
"A View Provider for the MyFeaturePython object"
def __init__(self, vobj):
vobj.Proxy = self
def attach(self, vobj):
self.standard = coin.SoGroup()
vobj.addDisplayMode(self.standard,"Standard");
def getDisplayModes(self,obj):
"'''Return a list of display modes.'''"
return ["Standard"]
def getDefaultDisplayMode(self):
"'''Return the name of the default display mode. It must be defined in getDisplayModes.'''"
return "Standard"
# create some objects
from pivy import coin
import MechanicalAnalysis
FreeCAD.newDocument()
MechanicalAnalysis.makeMechanicalAnalysis('myFEMAnalysis')
myobjApp = FreeCAD.ActiveDocument.addObject("App::FeaturePython","MyObject")
MyFeaturePython(myobjApp)
_ViewProviderMyFeaturePython(myobjApp.ViewObject)
FreeCAD.ActiveDocument.recompute()