TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: TopoWAR on August 11, 2014, 11:15:55 PM

Title: as used command & command-s
Post by: TopoWAR on August 11, 2014, 11:15:55 PM
hi all, with the advent of autocad 2015 I've had enough problems with the use of: command, I had to apply this code to all routines, the question is: is there another way to avoid the mistakes ?

Code: [Select]
(if command-s (command-s "_layer" "_Thaw" "aaa" "") (command "_layer" "_Thaw" "aaa"""))
appreciate your help
Title: Re: as used command & command-s
Post by: Tharwat on August 12, 2014, 03:01:00 AM
Use the vl function instead vl-cmdf .
Title: Re: as used command & command-s
Post by: ronjonp on August 12, 2014, 08:40:01 AM
Or just move away from command calls:
Code: [Select]
(defun _thaw (name / e o)
  (if (setq e (tblobjname "layer" name))
    (if (minusp (vlax-get (setq o (vlax-ename->vla-object e)) 'freeze))
      (vlax-put o 'freeze 0)
    )
  )
)
;; (_thaw "0")
Title: Re: as used command & command-s
Post by: ribarm on August 12, 2014, 09:43:08 AM
Untested (don't have A2015)... Before you execute routines type : command-switch, and after that type : command-restore...

Code - Auto/Visual Lisp: [Select]
  1. (defun c:command-switch nil
  2.   (if command-s
  3.     (setq com command command command-s)
  4.   )
  5.   (princ)
  6. )
  7.  
  8. (defun c:command-restore nil
  9.   (if (and command-s com)
  10.     (setq command com com nil)
  11.   )
  12.   (princ)
  13. )
  14.  

HTH, if my assumptions are correct...
M.R.
Title: Re: as used command & command-s
Post by: TopoWAR on August 12, 2014, 11:25:13 AM
Use the vl function instead vl-cmdf .
had already tried this function, but still fails in 2015

Or just move away from command calls:
Code: [Select]
(defun _thaw (name / e o)
  (if (setq e (tblobjname "layer" name))
    (if (minusp (vlax-get (setq o (vlax-ename->vla-object e)) 'freeze))
      (vlax-put o 'freeze 0)
    )
  )
)
;; (_thaw "0")
in 15 thousand lines of code that I have, it would be more difficult to suppress the call command, I've used a lot

Untested (don't have A2015)... Before you execute routines type : command-switch, and after that type : command-restore...

Code - Auto/Visual Lisp: [Select]
  1. (defun c:command-switch nil
  2.   (if command-s
  3.     (setq com command command command-s)
  4.   )
  5.   (princ)
  6. )
  7.  
  8. (defun c:command-restore nil
  9.   (if (and command-s com)
  10.     (setq command com com nil)
  11.   )
  12.   (princ)
  13. )
  14.  

HTH, if my assumptions are correct...
M.R.

Correct me if it is true, the function is being protected command, trying to replace it with another function daria error running the code, is this true ????
Title: Re: as used command & command-s
Post by: ronjonp on August 12, 2014, 12:10:41 PM
I understand, but if you're already going through your code and replacing command with command-s .. why not replace it with a commandless function ?


The solution with the least amount of effort would be:
Code: [Select]
(if command-s
    (setq command command-s)
)


If it's prompting about the assignment to protected symbol just turn it off in the vlide.
Tools>>Environment Options>>General Options>> SETQ to protected symbols>> Transparent
Title: Re: as used command & command-s
Post by: TopoWAR on August 12, 2014, 01:17:17 PM
ronjonp ,
is that I have not yet replaced by command-s command, I have to do and wanted to see if there is an easier solution, I very much like your proposal, but to try to replace the function code sticks because I pulled a screen says that the function is being protected command, I do? thanks friend

Quote
Tools>>Environment Options>>General Options>> SETQ to protected symbols>> Transparent
ahh I see, but my question is: to do this on all pc's where the code is run vlx if so would be complicated!
Title: Re: as used command & command-s
Post by: ronjonp on August 12, 2014, 02:34:31 PM
...

Quote
Tools>>Environment Options>>General Options>> SETQ to protected symbols>> Transparent
ahh I see, but my question is: to do this on all pc's where the code is run vlx if so would be complicated!

The file that setting is stored in is located in VLIDE.DSK here:
Code: [Select]
(vl-registry-read (strcat "HKEY_CURRENT_USER\\" (vlax-product-key)) "RoamableRootFolder")Set    (*protect-assign* . 0)
I'd personally take the time to go through the code and fix it though.
Title: Re: as used command & command-s
Post by: TopoWAR on August 12, 2014, 02:52:24 PM
ronjonp , my friend thank you very much :-)
Title: Re: as used command & command-s
Post by: ronjonp on August 12, 2014, 03:01:06 PM
Glad to help  :)
Title: Re: as used command & command-s
Post by: dgorsman on August 12, 2014, 05:11:43 PM
Also a good argument for creating re-useable functions.  Instead of the same thing written out a few thousand times, a function call written once and called where needed.  When these things prop up, its only a matter of opening the one box, changing the contents, and everything outside the box is none the wiser.
Title: Re: as used command & command-s
Post by: cmwade77 on August 12, 2014, 06:59:26 PM
I'm not sure that I understand what the problem is, I have a fair number of routines that use (command and not (command-s and they all work fine in 2015.
Title: Re: as used command & command-s
Post by: ronjonp on August 12, 2014, 09:57:21 PM
Also a good argument for creating re-useable functions.  Instead of the same thing written out a few thousand times, a function call written once and called where needed.  When these things prop up, its only a matter of opening the one box, changing the contents, and everything outside the box is none the wiser.
Agreed ;)
Title: Re: as used command & command-s
Post by: velasquez on November 05, 2014, 11:27:57 AM
I do not understand the problem with command and command-s
I copied the lines below the help of AutoCAD 2015.

"(command-s "._circle" (getpoint "\nSpecify center point: ") "_d" 2.75)"
Turns out the lines of code work fine in AutoCAD 2015 and 2012.
1
Code: [Select]
(command-s "._circle" (getpoint "\nSpecify center point: ") "_d" 2.75)2
Code: [Select]
(command "._circle" (getpoint "\nSpecify center point: ") "_d" 2.75)
Can someone explain me better how to reproduce the error that is as reported.
I better understand all the comments about it.
Thanks
Title: Re: as used command & command-s
Post by: ChrisCarlson on November 05, 2014, 11:41:39 AM
vl-cmdf is probably failing due to vl-load-com not being present. The . and _ also affect the running of a command. I have no idea what the difference between "circle " "_circle" and "._circle"
Title: Re: as used command & command-s
Post by: Lee Mac on November 05, 2014, 12:14:33 PM
I have no idea what the difference between "circle " "_circle" and "._circle"

See here (http://bit.ly/1d2jfB3) & here (http://bit.ly/18cyqA3).
Title: Re: as used command & command-s
Post by: velasquez on November 05, 2014, 12:44:23 PM
I do not understand the problem with command and command-s
I copied the lines below the help of AutoCAD 2015.

"(command-s "._circle" (getpoint "\nSpecify center point: ") "_d" 2.75)"
Turns out the lines of code work fine in AutoCAD 2015 and 2012.
1
Code: [Select]
(command-s "._circle" (getpoint "\nSpecify center point: ") "_d" 2.75)2
Code: [Select]
(command "._circle" (getpoint "\nSpecify center point: ") "_d" 2.75)
Can someone explain me better how to reproduce the error that is as reported.
I better understand all the comments about it.
Thanks

Sorry I forgot to post the text of the AutoCAD 2015 help file.
"The following is an invalid use of prompting for user input with the command-s function.
(command-s "._circle" (getpoint "\nSpecify center point: ") "_d" 2.75)"

Title: Re: as used command & command-s
Post by: RC on November 05, 2014, 04:36:24 PM
I'd personally take the time to go through the code and fix it though.
If it ain't broke, why 'fix' it?
I 'know' AutoCAD, I don't 'know' autolisp (or any of its variants) or C++ or V<whatever>. 
I write what I know in order to make my cad production faster, not to go back and re-write cr4p with every new release.  I see nothing at all 'broken' about using command calls .. until someone mucks with the program to make such legacy calls an issue.