Search code examples
autolisp

Unbound symbols in reactor data after loading the drawing


I have added a modification reactor to my table. The reactor has a callout function in it's data. callout is a function am:trench-updated

(vlr-pers 
  (vlr-object-reactor 
     (list table)
     (list (cons :am:dictionary dictionary)
           (cons :am:modified callout))
     (list (cons :vlr-modified 'am:table-modified))))

In the reactor I extract these callouts from the list:

(defun am:object-get (object field)
    (cdr (assoc field object)))

(defun am:table-modified (reactor-object)
  (setq reactor-data (vlr-data reactor-object)
        callout (am:object-get reactor-data :am:modified))
  (apply callout (list ...)))

It works fine until I save-load the drawing. After the load, callout contains the correct name, but nil value.

Before and after


Solution

  • An AutoLISP function will only be defined within the scope of the document namespace and will therefore need to be redefined when the document (drawing file) is reopened. I'm unsure why such function would be undefined following a save operation however.

    I would personally suggest that you avoid the use of persistent reactors in favour of rebuilding transient reactors on drawing startup. In my experience, persistent reactors are never truly persistent.