Open charlesneimog opened 1 year ago
Hi Charles, sorry for the super-late reply. Did you find a solution ?
If not, and if I understand what you want to do: you should define a class
in OM#, in such a way that the data connected to the input(s) would just be stored inside the box. Then you will need to simply redefine the function which opens the editor for this class. I think you could just start with
(defmethod open-editor ((self your-class))
;;; => do what you want
)
Hi Jean,
I could understand this part, but I do not know how to do this now:
Using the class run-py-f-internal
that is the same that OMLispFunctionInternal
, how can I get the input values of connected boxes?
Hot to get, for example, the value (1 2 3)
of the previous answer?
You can't really get the values from the object itself; you need to get it from the box, by querying the value of the input (with omNG-box-value
). That's not convenient, and not easy.
The patch evaluation mechanism evaluates a box and passes the values to another box, but the value (or function) inside a box can not know what's in the other boxes.
If your define your Py object as an OMClass
(or just using defclass
) you can store the connected values in the class slots, and use them when you open the editor (that's what I suggested before):
(defclass run-py-f-internal ()
((code :initform "" :accessor pre-delay) ;; no initarg: will not appear as an input
(param :initform nil :accessor param :initarg :param)))
(defmethod object-has-editor ((self run-py-f-internal)) t)
(defmethod get-editor-class ((self run-py-f-internal)) 'py-editor)
(defclass py-editor (omeditor) ())
(defmethod open-editor-window ((editor py-editor))
(print (param (object-value editor)))
;;; open your editor here...
)
Or you can define your own box for this (a subclass of OMBoxAbstraction
) and redefine open-editor
for that type of box. There you would have an opportunity to evaluate the inputs (but it's more of a hack!).
(defclass OMBoxPy (OMBoxAbstraction) ())
(defmethod get-box-class ((self run-py-f-internal)) 'OMBoxPy)
(defmethod open-editor ((self OMBoxPy))
(let ((param (omng-box-value (car (inputs box)))))
(print param)
;;; open your editor here...
))
Great, thank you very much for the help!
Hi Jean, I am working on the library om-py, for now I am using the
OMEditor
like in lisp functions to edit Python code.My aim: I'd like to, instead of open OMEditor from like in lisp function, Open VScode when double click in in py function.
To do that, I need the values from inputs connected in the
py
boxes, for example, the value of(1 2 3)
.Finally my question, how could I get this values from the
open-editor-window
method, with therun-py-function-editor
(equivalent torun-lisp-function-editor
).Did you understand?
Thanks!!