Try reload(). See here:. ... lit=reloadTry reload(). See here:. ... lit=reloadjosegegas wrote: ↑Wed Nov 20, 2019 5:04 amHi. Every time I make a change to the code, to test if it works as intended, I have to close FreeCAD and open it again, so that it "loads" the module with the changes... This is making me loose too much time. Is there a way to avoid this? Like forcing FreeCAD to load the module without closing it and opening again? I've tested to go from one workbench to another, but it seems FreeCAD loads all only once. How do you guys work?
I think what you want sounds like is possible but only in C++. That's basically what realthunder did in 0.19. Now when you hover over an object in the tree view, the corresponding element is highlighted in the 3D view.I think what you want sounds like is possible but only in C++. That's basically what realthunder did in 0.19. Now when you hover over an object in the tree view, the corresponding element is highlighted in the 3D view.josegegas wrote: ↑Wed Nov 20, 2019 12:08 pmAnother quick question. Is there any method that gets executed when the user clicks (single click) on a given object in the tree view? What I want to achieve: When the user clicks on an object, some other objects in the 3D scene get highlighted. Is this possible?
selection observer can handle selectionsselection observer can handle selections
Code: Select all
class SelObserver: def addSelection(self,doc,obj,sub,pnt): print ("Selection added",obj) s =SelObserver() FreeCADGui.Selection.addObserver(s) # install the function mode resident #FreeCADGui.Selection.removeObserver(s) # Uninstall the resident function
Code: Select all
class FreeCadNodeBase(NodeBase): '''common methods for FreeCAD integration''' def __init__(self, name="FreeCADNode",**kvargs): super(FreeCadNodeBase, self).__init__(name) self._debug = False self._preview=False @timer def compute(self, *args, **kwargs): if self._debug: say("debug on for ",self) import nodeeditor.dev reload (nodeeditor.dev) a=eval("nodeeditor.dev.run_{}(self)".format(self.__class__.__name__)) if self._debug: say("Done:",self) if self._preview: say("create preview") self.preview()
Code: Select all
class FreeCAD_Blinker(FreeCadNodeBase): ''' blinker sender ''' def __init__(self, name="baked",**kvargs): super(self.__class__, self).__init__(name) self.inExec = self.createInputPin(DEFAULT_IN_EXEC_NAME, 'ExecPin', None, self.compute) self.outExec = self.createOutputPin(DEFAULT_OUT_EXEC_NAME, 'ExecPin') self.signal=self.createInputPin('signalName', 'StringPin', 'blink') self.data=self.createInputPin('signalMessage', 'StringPin') self.d3=self.createInputPin('signalObject', 'FCobjPin') self.d3=self.createInputPin('sleep', 'FloatPin')
Code: Select all
def run_FreeCAD_Blinker(self): ....