Author Topic: Defun and vl-propagate, together  (Read 2382 times)

0 Members and 1 Guest are viewing this topic.

mkweaver

  • Bull Frog
  • Posts: 352
Defun and vl-propagate, together
« on: May 15, 2009, 07:07:20 AM »
Putting these two together should provide a way to defun a procedure and vl-propagate it out to all open drawings.

This is what I have, but I can't seem to get it to work:
Code: [Select]
(defun DefunAll( name deflist / )
  (defun name(car deflist) (cdr deflist))
  (vl-propagate name)
  )
Code: [Select]
(defunall 'c:test '(()(princ "\nThis is a test")(princ)))
Suggestions?

Lee Mac

  • Seagull
  • Posts: 12923
  • London, England
Re: Defun and vl-propagate, together
« Reply #1 on: May 15, 2009, 07:33:25 AM »
I thought vl-propagate was used for setting a variable throughout drawings..

Why not approach it this way:

Code: [Select]
(defun DefunAll ()
  (vl-load-com)
  (foreach doc (vla-get-Documents
                 (vlax-get-acad-object))
    (princ "\nThis is a test."))
  (princ))

mkweaver

  • Bull Frog
  • Posts: 352
Re: Defun and vl-propagate, together
« Reply #2 on: May 15, 2009, 09:30:33 AM »
With lisp there's not much difference between a variable and code.  I can get this to work thus:

Code: [Select]
(defun-q c:test()(princ "\nThis is a test")(princ))
Then:
Code: [Select]
(vl-propagate 'c:test)
After the above, c:test is a defined function in all drawings open(ed) in the current session.  I would like to avoid the defun-q.

wizman

  • Bull Frog
  • Posts: 290
Re: Defun and vl-propagate, together
« Reply #3 on: May 15, 2009, 10:11:21 AM »
With lisp there's not much difference between a variable and code.  I can get this to work thus:

Code: [Select]
(defun-q c:test()(princ "\nThis is a test")(princ))
Then:
Code: [Select]
(vl-propagate 'c:test)
After the above, c:test is a defined function in all drawings open(ed) in the current session.  I would like to avoid the defun-q.


hi mkweaver, defun-q with c: does not work for me, but this does:

Code: [Select]
(defun-q test()(princ "\nThis is a test")(princ))

(vl-propagate 'test)


and this one also works not using defun-q:

Code: [Select]
(setq test1 '(()(princ "\nThis is a test")(princ)))

(vl-propagate 'test1)