3dwannab Posted March 30, 2022 Posted March 30, 2022 (edited) On my work PC the code below fails but on another it doesn't. PICKFIRST is set to 1 on both so I'm stumped as to why this this. I'm not at the work PC now to get the exact problem but suffice to say it doesn't work when I have the objects preselected and it asks me to pick the objects. Would there be some other system variable that's set which puts a spanner in the works? (defun c:C0 ( / *error* len ss1 var_cmdecho var_osmode ) (setq *error* SS:error) (SS:startundo) (setq var_cmdecho (getvar "cmdecho")) (setq var_osmode (getvar "osmode")) (setvar 'cmdecho 0) (setvar 'osmode 0) (progn (setq ss1 (last (ssgetfirst))) (if (not ss1) (setq ss1 (ssget)) ) (if ss1 (progn (command "_.COPYBASE" "0,0" ss1 "") (princ (strcat "\n\t\t<<< " (itoa (setq len (sslength ss1))) (if (> len 1) " items" " item") " copied @ 0,0***")) (setq ss1 nil) ) (princ "\n: -------------------------\n\t\t*** User Cancelled Command ***\n") ) ) (*error* nil) (princ) ) (defun SS:startundo () (setq acDoc (vla-get-ActiveDocument (vlax-get-acad-object))) (or (vla-EndUndoMark acDoc) (vla-StartUndoMark acDoc)) ) (defun SS:error (errmsg) (and acDoc (vla-EndUndoMark acDoc)) (and errmsg (not (wcmatch (strcase errmsg) "*CANCEL*,*EXIT*")) (princ (strcat "\n<< Error: " errmsg " >>\n")) ) (setvar 'cmdecho var_cmdecho) (setvar 'osmode var_osmode) ) Edited March 30, 2022 by 3dwannab Quote
Jonathan Handojo Posted March 30, 2022 Posted March 30, 2022 There's really no reason to use ssgetfirst. If your PICKFIRST variable is set to 1, then using ssget will automatically picks up whatever selection is previously selected before you invoke your C0 command. So you can just go: (if (setq ss1 (ssget)) (progn (command "_.COPYBASE" "0,0" ss1 "") ;; ..... ) ) FWIW, if it's only to copy object at a basepoint of 0, I think it's a lot easier if you just make a macro instead of LISP. I do this as well. Quote
3dwannab Posted March 30, 2022 Author Posted March 30, 2022 Thanks. I've a whole bunch of scripts that I wrote way back when and the ssgetfirst was shooved in there without much knowing. I just really curios why one machine is behaving different to another and would like to know what's causing it. It only recently happened on my work machine and these LISP routines have been working for years. Quote
BIGAL Posted March 31, 2022 Posted March 31, 2022 Have a look at my post about comparing logfiles https://www.cadtutor.net/forum/topic/74699-my-pickbox-becomes-a-ghost-or-phantom/ 1 Quote
3dwannab Posted March 31, 2022 Author Posted March 31, 2022 (edited) Thanks. I'll take a look at that. Might take a bit of hunting down but it would be nice to know what's the root cause of this is! Edited March 31, 2022 by 3dwannab Quote
tombu Posted March 31, 2022 Posted March 31, 2022 My "Copy with 0,0 as Base Point" macro Command Name Copy with 0,0 as Base Point Description Duplicates objects with 0,0 as the base point Command Display Name COPYBASE 0,0 Macro $M=$(if,$(eq,$(substr,$(getvar,cmdnames),1,8),GRIP),_copybase,^C^C_copybase) 0,0 Works the same selecting before or after. 1 Quote
Recommended Posts
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.