Jump to content

PICKFIRST set to 1 but this fails on one machine and not another


Recommended Posts

Posted (edited)

On my work PC the code below fails but on another it doesn't.

 

PICKFIRST is set to 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 by 3dwannab
Posted

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.

Posted

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.

Posted (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 by 3dwannab
Posted

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.

  • Like 1

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...