Author Topic: as used command & command-s  (Read 12503 times)

0 Members and 1 Guest are viewing this topic.

TopoWAR

  • Newt
  • Posts: 135
as used command & command-s
« 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
Thanks for help

Tharwat

  • Swamp Rat
  • Posts: 707
  • Hypersensitive
Re: as used command & command-s
« Reply #1 on: August 12, 2014, 03:01:00 AM »
Use the vl function instead vl-cmdf .

ronjonp

  • Needs a day job
  • Posts: 7526
Re: as used command & command-s
« Reply #2 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")

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

ribarm

  • Gator
  • Posts: 3225
  • Marko Ribar, architect
Re: as used command & command-s
« Reply #3 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.
« Last Edit: August 12, 2014, 09:52:13 AM by ribarm »
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube

TopoWAR

  • Newt
  • Posts: 135
Re: as used command & command-s
« Reply #4 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 ????
« Last Edit: August 12, 2014, 11:31:13 AM by TopoWAR »
Thanks for help

ronjonp

  • Needs a day job
  • Posts: 7526
Re: as used command & command-s
« Reply #5 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
« Last Edit: August 12, 2014, 12:14:35 PM by ronjonp »

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

TopoWAR

  • Newt
  • Posts: 135
Re: as used command & command-s
« Reply #6 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!
« Last Edit: August 12, 2014, 01:20:32 PM by TopoWAR »
Thanks for help

ronjonp

  • Needs a day job
  • Posts: 7526
Re: as used command & command-s
« Reply #7 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.

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

TopoWAR

  • Newt
  • Posts: 135
Re: as used command & command-s
« Reply #8 on: August 12, 2014, 02:52:24 PM »
ronjonp , my friend thank you very much :-)
Thanks for help

ronjonp

  • Needs a day job
  • Posts: 7526
Re: as used command & command-s
« Reply #9 on: August 12, 2014, 03:01:06 PM »
Glad to help  :)

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

dgorsman

  • Water Moccasin
  • Posts: 2437
Re: as used command & command-s
« Reply #10 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.
If you are going to fly by the seat of your pants, expect friction burns.

try {GreatPower;}
   catch (notResponsible)
      {NextTime(PlanAhead);}
   finally
      {MasterBasics;}

cmwade77

  • Swamp Rat
  • Posts: 1443
Re: as used command & command-s
« Reply #11 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.

ronjonp

  • Needs a day job
  • Posts: 7526
Re: as used command & command-s
« Reply #12 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 ;)

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

velasquez

  • Newt
  • Posts: 195
Re: as used command & command-s
« Reply #13 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

ChrisCarlson

  • Guest
Re: as used command & command-s
« Reply #14 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"

Lee Mac

  • Seagull
  • Posts: 12906
  • London, England
Re: as used command & command-s
« Reply #15 on: November 05, 2014, 12:14:33 PM »
I have no idea what the difference between "circle " "_circle" and "._circle"

See here & here.

velasquez

  • Newt
  • Posts: 195
Re: as used command & command-s
« Reply #16 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)"


RC

  • Guest
Re: as used command & command-s
« Reply #17 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.