Jump to content

Convert BricsCAD's LISP to run on AutoCAD


ctrlaltdel

Recommended Posts

This LISP runs on BricsCAD but has an error when running on AutoCAD 2014.

 

Please help to covert the below LISP to run on AutoCAD 2014.

 

Thanks

 

(defun c:test ( / nentselLst nestLevel)
 (if
   (and
     (setq nentselLst (nentsel))
     (= 4 (length nentselLst))
     (<= 0 (setq nestLevel (- (length (cadddr nentselLst)) 2)))
   )
   (progn
     (setvar 'cmdecho 0)
     (command "_.-refedit" (list (last (cadddr nentselLst)) (cadr nentselLst)))
     (repeat nestLevel (command "_next"))
     (command "_ok" "_all" "_yes")
     (setvar 'cmdecho 1)
   )
 )
 (princ)
)

 

Error when running this LISP on AutoCAD 2014

Command: test

Select object:

*Invalid selection*

Expects a single object.

Cannot invoke (command) from *error* without prior call to (*push-error-using-command*).

Converting (command) calls to (command-s) is recommended.

Select reference: *Cancel*

Command: *Cancel*

Link to comment
Share on other sites

I don't have AutoCAD available to me, but have you tried what AutoCAD is telling you in the error message? Try changing the command to command-s in your code and see if that helps.

 

BKT

Link to comment
Share on other sites

Hi BKT

 

Change the LISP as suggested. But no go. Not sure if its still due to BricsCAD incompatibility or the code is not right, though the writer said it worked in BricsCAD

 

(defun c:test ( / nentselLst nestLevel)
 (if
   (and
     (setq nentselLst (nentsel))
     (= 4 (length nentselLst))
     (<= 0 (setq nestLevel (- (length (cadddr nentselLst)) 2)))
   )
   (progn
     (setvar 'cmdecho 0)
     (command-s "_.-refedit" (list (last (cadddr nentselLst)) (cadr nentselLst)))
     (repeat nestLevel (command-s "_next"))
     (command-s "_ok" "_all" "_yes")
     (setvar 'cmdecho 1)
   )
 )
 (princ)
)

 

 

After I click the entity, it was suppose to bring me to a block in-place mode of a block level but nothing happend

Command: test

Select object:

Select reference: *Cancel*

Cannot invoke (command) from *error* without prior call to (*push-error-using-command*).

Converting (command) calls to (command-s) is recommended.

Command:

Command: *Cancel*

Link to comment
Share on other sites

Ah, OK. The suggestion about command-s was strictly based on the error message you got but doesn't look like that's the problem. As Roy mentions, the command calls seem to be the issue, but I'm also running BricsCAD, so hopefully someone else will be along soon with a fix for you.

 

BKT

Link to comment
Share on other sites

Ah, OK. The suggestion about command-s was strictly based on the error message you got but doesn't look like that's the problem. As Roy mentions, the command calls seem to be the issue, but I'm also running BricsCAD, so hopefully someone else will be along soon with a fix for you.

 

BKT

 

 

Many thanks for your help BKT

Link to comment
Share on other sites

Run it line by line should find which line is the problem start with (setq nentselLst (nentsel)) then if nothing appears do !nentsellst if its Nil then its a problem just keep going copy and paste each line to the commnad line. Stop and check answer if nothing appears have the text screen open ie F2 use !andvariablename, you can also check a part of a longer netsed lisp (cadddr nentselLst)

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...