TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: 77077 on June 03, 2015, 02:17:52 AM

Title: change vlx 's command
Post by: 77077 on June 03, 2015, 02:17:52 AM
eg.
VLX name: attmodify 
VLX command: am

Code: [Select]
(defun c:new_command ()
(if (not (member 'ddmodify (vl-list-loaded-vlx)))
(load "attmodify.VLX")
)
(c:am)
)
Title: Re: change vlx 's command
Post by: Lee Mac on June 03, 2015, 07:13:26 AM
If the VLX was compiled to a separate namespace, you will probably need to use something like:

Code - Auto/Visual Lisp: [Select]
  1. (defun c:am nil
  2.     (if (member 'attmodify (vl-list-loaded-vlx))
  3.     )
  4.     (princ)
  5. )

Otherwise, try something like:

Code - Auto/Visual Lisp: [Select]
  1. (defun c:am nil (c:attmodify))

You can use vl-list-loaded-vlx to determine whether the VLX has been compiled to its own namespace, since this function should only list symbols identifying separate-namespace VLX applications.
Title: Re: change vlx 's command
Post by: 77077 on June 03, 2015, 07:43:59 AM
If the VLX was compiled to a separate namespace, you will probably need to use something like:

Code - Auto/Visual Lisp: [Select]
  1. (defun c:am nil
  2.     (if (member 'attmodify (vl-list-loaded-vlx))
  3.     )
  4.     (princ)
  5. )

Otherwise, try something like:

Code - Auto/Visual Lisp: [Select]
  1. (defun c:am nil (c:attmodify))

You can use vl-list-loaded-vlx to determine whether the VLX has been compiled to its own namespace, since this function should only list symbols identifying separate-namespace VLX applications.

Hi lee, Thanks for reply.

I mean some different VLX, But have same command . so need change VLX's command.
Title: Re: change vlx 's command
Post by: Lee Mac on June 03, 2015, 08:34:22 AM
I mean some different VLX, But have same command . so need change VLX's command.

You cannot modify a VLX.
Title: Re: change vlx 's command
Post by: 77077 on June 03, 2015, 09:47:20 AM
I mean some different VLX, But have same command . so need change VLX's command.

You cannot modify a VLX.

Yes , So, I post this thread.

It's another way(Method)

eg: a.vlx & b.vlx  have same command "zbbz"

I use this method

Code - Auto/Visual Lisp: [Select]
  1. (defun c:test1 (/ FILE)
  2.   (cond
  3.     ((and c:zbbz
  4.           (VL-ACAD-UNDEFUN 'C:zbbz)
  5.           (setq file (findfile "a.vlx"))
  6.      )
  7.      (load file)
  8.      (C:zbbz)
  9.     )
  10.   )
  11. )
  12. (defun c:test2 (/ FILE)
  13.   (cond
  14.     ((and C:zbbz
  15.           (VL-ACAD-UNDEFUN 'C:zbbz)
  16.           (setq file (findfile "b.vlx"))
  17.      )
  18.      (load file)
  19.      (C:zbbz)
  20.     )
  21.   )
  22. )
  23.  
Title: Re: change vlx 's command
Post by: Marco Jacinto on June 03, 2015, 10:04:14 AM
Lee, can you explain why if the vlx is compiled to a separate Namespace you nid to use sendcommand, I had some problems with a vlx that can run in one PC, but when I distribute it, it doesn´t work anymore.

Saludos
Marco Jacinto
Title: Re: change vlx 's command
Post by: Lee Mac on June 03, 2015, 12:41:55 PM
Lee, can you explain why if the vlx is compiled to a separate Namespace you nid to use sendcommand, I had some problems with a vlx that can run in one PC, but when I distribute it, it doesn´t work anymore.

Hi Marco,

When working with AutoLISP, all symbols & functions are usually defined either within the document namespace or blackboard namespace (if vl-bb-set is used); in this way, all defined symbols (functions / constants / global variables etc.) defined in the namespace for one document (drawing) will be accessible by (and may also interfere with!) all other defined symbols in the same namespace, but cannot be accessed by functions defined in another namespace, e.g. in another drawing, unless a function such a vl-propagate has been used to propagate the symbol across multiple namespaces.

Hence, if a VLX is compiled to a separate namespace, all symbols & functions defined by the VLX will reside in a separate namespace (perhaps think of it like a 'container') isolated from the document & blackboard namespaces, and such functions won't be accessible by functions evaluated within the document namespace, unless either exported using vl-doc-export, or defined directly in the document namespace using the vl-doc-set function evaluated from within the VLX namespace.

Here's (http://autode.sk/I4gsdN) another brief explanation of a namespace (from an AutoLISP perspective).

Lee
Title: Re: change vlx 's command
Post by: Marco Jacinto on June 04, 2015, 09:29:37 AM
Thanks for your response Lee.

I have always assumed that the c: functions were exported by the compiler by default, so I didn't figure out the problem when my c: functions and all others weren't exposed to the drawing, even when I explicitly exported them via vl-doc-export.

Will do some test to see if I can understand an apply the concepts
Title: Re: change vlx 's command
Post by: Q1241274614 on July 07, 2015, 06:46:04 AM
If the VLX was compiled to a separate namespace, you will probably need to use something like:

Code - Auto/Visual Lisp: [Select]
  1. (defun c:am nil
  2.     (if (member 'attmodify (vl-list-loaded-vlx))
  3.     )
  4.     (princ)
  5. )

It looks very comfortable.

Otherwise, try something like:

Code - Auto/Visual Lisp: [Select]
  1. (defun c:am nil (c:attmodify))

You can use vl-list-loaded-vlx to determine whether the VLX has been compiled to its own namespace, since this function should only list symbols identifying separate-namespace VLX applications.

Hi lee, Thanks for reply.

I mean some different VLX, But have same command . so need change VLX's command.