Author Topic: New Command options in old or different versions of CAD  (Read 2517 times)

0 Members and 1 Guest are viewing this topic.

Marc'Antonio Alessi

  • Swamp Rat
  • Posts: 1453
  • Marco
New Command options in old or different versions of CAD
« on: January 26, 2018, 04:05:59 AM »
I need a function to execute a command with options that do not "crash" in old version of AutoCAD/Bricscad. See my previous question on: http://www.theswamp.org/index.php?topic=53877.msg585404#msg585404

Example: (command "_.purge" "_Zero" "_.purge" "_Empty") > _Zero it is not a BricsCAD option and _Empty do not works in very old versions.

Is this a good solution to start?
Code: [Select]
(defun c:test ( / )
  (command "_.purge" "_Zero")
  (if (= 1 (getvar "cmdactive"))
    (progn (command "") (print "Purge Zero failed."))
    (print "Purge Zero ok.")
  )
  (princ)
)

efernal

  • Bull Frog
  • Posts: 206
Re: New Command options in old or different versions of CAD
« Reply #1 on: January 26, 2018, 03:19:55 PM »
(cond ((findfile "acad.exe")
       (cond ((= (getvar "ACADVER") XXXX) (COMMAND ...))
             ((= (getvar "ACADVER") YYYY) (COMMAND ...))
             ETC...
       )
      )
      ((findfile "bricscad.exe") ;; correct if necessary
       (COMMAND ....)
      )
      ((findfile "icad.exe")
       (COMMAND ...)
      )
)
e.fernal

ronjonp

  • Needs a day job
  • Posts: 7529
Re: New Command options in old or different versions of CAD
« Reply #2 on: January 26, 2018, 03:30:03 PM »
Maybe:
Code - Auto/Visual Lisp: [Select]
  1. (vl-catch-all-error-p (vl-catch-all-apply 'vl-cmdf (list "_.purge"  "_Zero")))

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

Marc'Antonio Alessi

  • Swamp Rat
  • Posts: 1453
  • Marco
Re: New Command options in old or different versions of CAD
« Reply #3 on: January 26, 2018, 04:42:25 PM »
@efernal: too complex, too many versions/options...

@ronjonp: tested on BricsCAD V13
: TEST
"Purge Zero failed."


: (vl-catch-all-error-p (vl-catch-all-apply 'vl-cmdf (list "_.purge"  "_Zero")))
nil
Elimina:  baTch/TUtto/Blocchi/stiliQuota/Layer/TIpilinea/MAteriali/stiliML/STilistampa/stiliTEsto/stiliTAbella/stiliVisual/Regapps:
(Elimina = Purge)

> do not get error and the command is active

roy_043

  • Water Moccasin
  • Posts: 1895
  • BricsCAD 18
Re: New Command options in old or different versions of CAD
« Reply #4 on: January 26, 2018, 05:12:15 PM »
Checking if the command is still active may work in the case of the _Purge command. However if a command has a sequences of options this method is useless.

BIGAL

  • Swamp Rat
  • Posts: 1418
  • 40 + years of using Autocad
Re: New Command options in old or different versions of CAD
« Reply #5 on: February 01, 2018, 09:09:59 PM »
We had a suite of lisps and ran them on Intellicad and had that type of problem with say 3 lisps, we basically rewrote them to match Intellicad and saved them elsewhere. We had a installer that copied correct versions etc. We had a couple of others that we just rewrote to match Acad and Icad had some help from another developer.

As already mentioned you could set a variable and check it all the time then use a cond,  but it means some code will have like 3 lines for same function.

Unfortunately it can be a bit of trial and error to find the problem commands.
A man who never made a mistake never made anything

Marc'Antonio Alessi

  • Swamp Rat
  • Posts: 1453
  • Marco
Re: New Command options in old or different versions of CAD
« Reply #6 on: February 02, 2018, 08:41:08 AM »
...
Unfortunately it can be a bit of trial and error to find the problem commands.
I work with Bricscad V12>18 - AutoCAD 2010>2018...

Marc'Antonio Alessi

  • Swamp Rat
  • Posts: 1453
  • Marco
Re: New Command options in old or different versions of CAD
« Reply #7 on: February 05, 2018, 11:59:01 AM »
I have found that the options Zero and Empty are included in the Purge All option... (not REGAPPS).