Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

LISP error

14 REPLIES 14
Reply
Message 1 of 15
Anonymous
2574 Views, 14 Replies

LISP error

Every time I try to load a custom LISP file and execute it I get the following error: Error: no function definition: VLAX-ENAME->VLA-OBJECT Cannot invoke (command) from *error* without prior call to (*push-error-using-command*). Converting (command) calls to (command-s) is recommended. Command: Thoughts? AUTOCAD 2017 on Windows 10
Tags (2)
14 REPLIES 14
Message 2 of 15
ВeekeeCZ
in reply to: Anonymous

Try to add this line as the very first one of your lsp file

(vl-load-com)

Message 3 of 15
Anonymous
in reply to: ВeekeeCZ

Unfortunately that never works for this error. 

 

Message 4 of 15
ВeekeeCZ
in reply to: Anonymous

That should work unless it's broken - read THIS

Message 5 of 15
Anonymous
in reply to: ВeekeeCZ

App repair did not help either.

Message 6 of 15
CodeDing
in reply to: Anonymous

@Anonymous,

 

Are you able to post your code? That might help others assist you.

 

Best,

~DD

~DD
Senior CAD Tech & AI Specialist
Need AutoLisp help? Try my custom GPT 'AutoLISP Ace':
https://chat.openai.com/g/g-Zt0xFNpOH-autolisp-ace
Message 7 of 15
Kent1Cooper
in reply to: Anonymous

The latter part is coming from your *error* handler, which must contain a (command) function, such as Undo End or something.  That's no longer allowed after I think Acad2015, without jumping through some other hoops.  Just do what they say -- change the word (command ... to (command-s ... inside the *error* handler [you don't need to do so anywhere else in the code].  Something else is triggering  the *error* handler, so you also need to fix that, and I would think (vl-load-com) as suggested would fix the described no-function-definition part.

Kent Cooper, AIA
Message 8 of 15
roland.r71
in reply to: Kent1Cooper


@Kent1Cooper wrote:

The latter part is coming from your *error* handler, which must contain a (command) function, such as Undo End or something.  That's no longer allowed after I think Acad2015, without jumping through some other hoops.  Just do what they say -- change the word (command ... to (command-s ... inside the *error* handler [you don't need to do so anywhere else in the code].  Something else is triggering  the *error* handler, so you also need to fix that, and I would think (vl-load-com) as suggested would fix the described no-function-definition part.


To that I'ld like to add, it can come from ANY (ill defined) *error* handler.

I've seen it happen many times. People replace the original *error* handler, without restoring it (instead of making it local). Resulting in these kind of messages appearing even if the function loaded/run doesn't have (it's own) *error* handler.

 

So, locate the *error* function causing this first. (which means checking each lisp file loaded) - IF it's not caused by the function you try to load.

Message 9 of 15
roland.r71
in reply to: CodeDing

Always a good practice, if you have a code problem to be solved.

No explanation can ever replace 'the real thing' (for example, it would be easy to see if your *error* handler is the cause, or not & if you are using command calls, or not (& what to change to get it working)

 

Now it's just a "guessing game".

Message 10 of 15
Anonymous
in reply to: CodeDing

the code:

;; BlockReplace.lsp
;; Two commands: BRS = Block Replace: Selected; BRA = Block Replace: All
;; Both commands:
;; 1) Ask User for Block name to use to replace other Blocks with.
;; 2) Ask again for Block name if it is neither defined in current drawing nor
;; a drawing in a Support File Search Path.
;; 3) Remember that Block name [separately for each], and offer as default on
;; subsequent use. If no default yet in current command, offer default from
;; other command if present; if not, regular Insert's default if present.
;; 4) Retain layer, insertion point, scales, rotation, extrusion direction, any
;; overrides, etc. of all replaced Block insertions.
;; 5) Also replace any Minsert objects among selection in BRS or of correct
;; Block name in BRA.
;; See further details at head of each command definition.
;; Kent Cooper, last edited 10 October 2012

(vl-load-com)

(defun brerr (errmsg)
(if (not (wcmatch errmsg "Function cancelled,quit / exit abort,console break"))
(princ (strcat "\nError: " errmsg))
); if
(command "_.undo" "_end")
(setvar 'cmdecho cmde)
(princ)
); defun -- brerr

(defun *ev (ltr); evaluate what's in variable name with letter
(eval (read (strcat "*br" ltr "name")))
); defun - *ev

(defun brsetup (this other / temp)
(setq cmde (getvar 'cmdecho))
(setvar 'cmdecho 0)
(command "_.undo" "_begin")
(while
(or
(not temp); none yet [first time through (while) loop]
(and (not (*ev this)) (not (*ev other)) (= temp (getvar 'insname) ""))
; no this-command or other-command or Insert defaults yet, on User Enter
(and ; availability check
(/= temp ""); User typed something other than Enter, but
(not (tblsearch "block" temp)); no such Block in drawing, and
(not (findfile (strcat temp ".dwg"))); no such drawing in Search paths
); and
); or
(setq temp
(getstring
(strcat
(if (and temp (/= temp "")) "\nNo such Block or Drawing available." "")
"\nBlock to Replace existing Block(s) with"
(cond
((*ev this) (strcat " <" (*ev this) ">")); prior Block in this command, if any
((*ev other) (strcat " <" (*ev other) ">")); prior Block in other command, if any
((/= (getvar 'insname) "") (strcat " <" (getvar 'insname) ">")); Insert's default, if any
(""); no default on first use if no this-command or other-command or Insert defaults
); cond
": "
); strcat
); getstring & temp
); setq
); while
(set (read (strcat "*br" this "name"))
(cond
((/= temp "") temp); User typed something
((*ev this)); default for this command, if any
((*ev other)); default for other command, if any
((getvar 'insname)); Enter on first use with Insert's default
); cond
); set
(if (not (tblsearch "block" (*ev this))); external drawing, not yet Block in current drawing
(command "_.insert" (*ev this) nil); bring in definition, don't finish Inserting
); if
); defun -- brsetup


(defun C:BRS ; = Block Replace: Selected
;; To Replace User-selected Block(s) of any name(s) with User-specified Block name.
;; [Notice of selected Block(s) on locked Layers is within selection; not listed at end
;; as in BRA; off or frozen Layers are irrelevant with User selection.]
;; Rejects Xrefs, but does replace any Windows Metafile objects among selection.
(/ *error* cmde ss repl notrepl ent)
(setq *error* brerr)
(brsetup "s" "a")
(prompt (strcat "\nTo replace Block insertion(s) with " *brsname ","))
(setq
ss (ssget ":L" '((0 . "INSERT"))); Blocks/Xrefs/Minserts/WMFs on unlocked Layers
repl (sslength ss) notrepl 0
); setq
(repeat repl
(setq ent (ssname ss 0))
(if (not (assoc 1 (tblsearch "block" (cdr (assoc 2 (entget ent)))))); not Xref
(vla-put-Name (vlax-ename->vla-object ent) *brsname); then
(setq notrepl (1+ notrepl) repl (1- repl)); else
); if
(ssdel ent ss)
); repeat
(prompt (strcat "\n" (itoa repl) " Block(s) replaced with " *brsname "."))
(if (> notrepl 0) (prompt (strcat "\n" (itoa notrepl) " Xref(s) not replaced.")))
(command "_.undo" "_end")
(setvar 'cmdecho cmde)
(princ)
); defun -- BRS


(defun C:BRA ; = Block Replace: All
;; To Replace All insertions of designated Block name with User-specified different Block.
;; Designation of Block name to replace by either selection of Block or Typing.
;; Replaces insertions in all spaces and layouts.
;; Does not replace those on locked or frozen Layers [does on Layers that are off, but
;; see comments below to not replace those], or nested insertions.
(/ *error* cmde done esel edata oldname ss repl notrepl ent elay layst)
(setq *error* brerr)
(brsetup "a" "s")
(while (not done)
(setvar 'errno 0)
(initget "Type")
(setq esel
(entsel
(strcat
"\nSelect Block to replace all instances with "
*braname
" or [Type-it]: "
); strcat
); entsel
); setq
(cond
( (= esel "Type")
(while
(not
(and
(setq oldname (getstring "\nBlock name: "))
(tblsearch "block" oldname); Block definition exists in drawing
); and
); not
(prompt "\nBlock name not defined --")
); while
(setq done T)
); Type-it condition
( (= (getvar 'errno) 0); picked something
(if
(and
(setq edata (entget (car esel)))
(wcmatch (cdr (assoc 0 edata)) "INSERT")
(setq oldname (cdr (assoc 2 edata)))
(not (assoc 1 (tblsearch "block" oldname))); not Xref
); and
(setq done T); then
(prompt "\nSelected object not a Block/Minsert/WMF --"); else
); if
); picked-something condition
((prompt "\nNothing selected --")); missed -- 'errno = 7
); cond
); while
(setq
ss (ssget "_X" (list '(0 . "INSERT") (cons 2 oldname))); all such Blocks/Minserts
repl (sslength ss) notrepl 0
); setq
(repeat repl
(setq
ent (ssname ss 0)
elay (tblsearch "layer" (cdr (assoc 8 (entget ent))))
layst (cdr (assoc 70 elay)); contains frozen/locked status
); setq
(if (or (= (logand layst 1) 1) (= (logand layst 4) 4)); on locked [1] or frozen [4] Layer
;; to have it NOT replace those on Layers that are turned OFF, replace above line with following lines:
;; (if (or (= (logand layst 1) 1) (= (logand layst 4) 4) (minusp (cdr (assoc 62 elay))))
;; ; on locked [1] or frozen [4] or off [negative color number] Layer
(setq notrepl (1+ notrepl) repl (1- repl)); then
(vla-put-Name (vlax-ename->vla-object ent) *braname); else
); if
(ssdel ent ss)
); repeat
(prompt (strcat "\n" (itoa repl) " " oldname " Block(s) replaced with " *braname "."))
(if (> notrepl 0) (prompt (strcat "\n" (itoa notrepl) " on locked/frozen Layer(s) not replaced.")))
;; if NOT replacing those on Layers that are turned OFF, replace above line with following line:
;; (if (> notrepl 0) (prompt (strcat "\n" (itoa notrepl) " on off/locked/frozen Layer(s) not replaced.")))
(command "_.undo" "_end")
(setvar 'cmdecho cmde)
(princ)
); defun -- BRA

(prompt "\nBlock Replace: BRS = Select insertion(s), BRA = All insertions of selected Block.")

Message 11 of 15
Kent1Cooper
in reply to: Anonymous

That was written before (command) fell out of favor within *error* handlers.  I have since edited it, and I don't recall whether I've changed anything else about it, but I did make that change.  Give the attached updated version a try.

Kent Cooper, AIA
Message 12 of 15
Anonymous
in reply to: Kent1Cooper

Same error. 

Message 13 of 15
roland.r71
in reply to: Anonymous

In that case the error is most likely caused elsewhere. (as Kent's latest version doesn't use any command calls inside the *error*, & both old and new already had the (vl-load-com) present)

Are you loading any other lisp files?

(from acad.lsp, acaddoc.lsp or using appload)

 

If so, remove them ALL & re-add them, one by one until the error occurs, to find the real culprit.

 

edit:

It's possible the ActiveX error requires a reinstall or editing the registry to correct a bad install.

See: https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/error-no-function-definition-vlax-en... for more info & tips on that.

Message 14 of 15
Anonymous
in reply to: roland.r71

Some of the apps are grayed out in the load UI. Could this just be an administrator rights issue?

Capture.JPG

Message 15 of 15
roland.r71
in reply to: Anonymous

No, afaik, it means you can not unload them (which goes for ActiveX & lisp)

But you can still remove them. (meaning, it remains loaded for the current session/drawing, but will no longer be loaded afterwards. Where unload will have effect on the current session)

 

As vl.arx appears to be loaded, the vla function should be recognized. So that's one more thing pointing at a corrupted acad installation.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Forma Design Contest


AutoCAD Beta