Author Topic: Convert BricsCAD's LISP to run on AutoCAD  (Read 2793 times)

0 Members and 1 Guest are viewing this topic.

ctrlaltdel

  • Guest
Convert BricsCAD's LISP to run on AutoCAD
« on: August 24, 2016, 11:03:35 AM »
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

Code: [Select]
(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
Quote
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*

ChrisCarlson

  • Guest
Re: Convert BricsCAD's LISP to run on AutoCAD
« Reply #1 on: August 24, 2016, 11:34:44 AM »
What happens if you restart AutoCAD and run this for the first time?

ctrlaltdel

  • Guest
Re: Convert BricsCAD's LISP to run on AutoCAD
« Reply #2 on: August 24, 2016, 11:41:09 AM »
What happens if you restart AutoCAD and run this for the first time?

Tested at work & home. Same problem.

ChrisCarlson

  • Guest
Re: Convert BricsCAD's LISP to run on AutoCAD
« Reply #3 on: August 24, 2016, 11:48:24 AM »
I can't test it as I do not deal with references but some trouble shooting

1) Try command-s instead of command

ctrlaltdel

  • Guest
Re: Convert BricsCAD's LISP to run on AutoCAD
« Reply #4 on: August 24, 2016, 11:55:15 AM »
I did that eariler, on someone's advise.

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

Code: [Select]
(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
Quote
Command: test
Select object:                    <<<<<I select entity but nothing happend, instead runs the usual refedit command
Select reference: *Cancel*    <<<<<AT this point if i select anything, it just runs the usual refedit command
Cannot invoke (command) from *error* without prior call to (*push-error-using-command*).
Converting (command) calls to (command-s) is recommended.
Command:
Command: *Cancel*

danallen

  • Guest
Re: Convert BricsCAD's LISP to run on AutoCAD
« Reply #5 on: August 24, 2016, 01:15:45 PM »
Have you tried typing each command in the lisp to see if the sequence of prompts / inputs is correct? example: -refedt (enter something) (enter something) "next", etc?

Also add some temporary princ statements of variables inside the PROGN, example (princ "\nnestlevel")(princ nextlevel), and see if the values match what is needed for prompts? Or - in Acad, use IDE to walk through each line step by step and use watch window to check variables

hmspe

  • Bull Frog
  • Posts: 362
Re: Convert BricsCAD's LISP to run on AutoCAD
« Reply #6 on: August 24, 2016, 06:41:09 PM »
Could you post a block that this is supposed to work with? 

The "*Invalid selection*  Expects a single object." message makes this look like there is an issue with entity selection.
"Science is the belief in the ignorance of experts." - Richard Feynman

ctrlaltdel

  • Guest
Re: Convert BricsCAD's LISP to run on AutoCAD
« Reply #7 on: August 24, 2016, 08:31:40 PM »
Have you tried typing each command in the lisp to see if the sequence of prompts / inputs is correct? example: -refedt (enter something) (enter something) "next", etc?

Also add some temporary princ statements of variables inside the PROGN, example (princ "\nnestlevel")(princ nextlevel), and see if the values match what is needed for prompts? Or - in Acad, use IDE to walk through each line step by step and use watch window to check variables

At the start of the command, after clicking an entity, its should go straight to Block IN-Place/refedit mode of a block level. But the last edited LISP I did, did not do that but instead it immediately proceed to this command
Quote
Select reference:
which leads to a usual refedit command which is not I wanted.

ctrlaltdel

  • Guest
Re: Convert BricsCAD's LISP to run on AutoCAD
« Reply #8 on: August 24, 2016, 08:54:50 PM »
Could you post a block that this is supposed to work with? 

The "*Invalid selection*  Expects a single object." message makes this look like there is an issue with entity selection.

Hi hmspe. You can refer to the link below where i posted a block.

https://www.theswamp.org/index.php?topic=51887.0

ur_naz

  • Newt
  • Posts: 68
  • Made in Ukraine
Re: Convert BricsCAD's LISP to run on AutoCAD
« Reply #9 on: September 11, 2016, 09:46:53 PM »
AutoCAD can't select outside visible drawing area, Bricscad can. That's a difference... It can't be fixed. You must zoom out to select all you need in AutoCAD.

ctrlaltdel

  • Guest
Re: Convert BricsCAD's LISP to run on AutoCAD
« Reply #10 on: September 12, 2016, 12:53:54 AM »
Hi ur_naz. The issue has been resolve in my other thread.