Search the Community
Showing results for tags 'cmdactive'.
-
Auto select previous objects after running a defun of another routine
3dwannab posted a topic in AutoLISP, Visual LISP & DCL
Hi, I was hoping to LOAD a lsp file then call it via (c:runthislispfile) inside another routine to combine them in one. Problem is, they prompt for a selection, so I thought this would work: (command "_P") (while (eq 1 (logand 1 (getvar 'CMDACTIVE))) (command "")) Is this possible? I'm pretty sure it is with the cmdactive trick. See code below and comments where the problem lies: (defun c:---BB (/) (progn (LOAD "3dwannab_ByBlock_Change_Entities") (C:BB))) ; Change all selected entities to ByBlock and layer 0 & more. (defun c:BB ( / ss_1 ) (setq *error* SS:error) (SS:startundo) (setq cmde (getvar "cmdecho")) (setq os (getvar "osmode")) (setq orthom (getvar "orthomode")) (setvar 'cmdecho 0) (setvar 'osmode 83) (setvar 'orthomode 1) (progn (setq ss_1 (last (ssgetfirst))) (if (not ss_1) (setq ss_1 (ssget '((0 . "~HATCH")))) ) (if ss_1 (progn (command "._chprop" "_non" ss_1 "" "_LA" "0" "") (command "._chprop" "_non" ss_1 "" "_LT" "BYBLOCK" "") (command "._chprop" "_non" ss_1 "" "_LTS" "1" "") (command "._chprop" "_non" ss_1 "" "_LW" "BYBLOCK" "") (command "._chprop" "_non" ss_1 "" "_TR" "BYBLOCK" "") (command "._chprop" "_non" ss_1 "" "_C" "BYBLOCK" "") ;; How do I run the command for this lisp then select previous and run it automatically. ;; Below doesn't work. ;; This routine is for rounding off entities to the nearest 0.5mm. (prompt "\nRUN the F5 command also to round off to 0.5mm ?\n") (load "FX_Round_Numbers_0Point5") (progn (c:F5) (command "_P") (while (eq 1 (logand 1 (getvar 'CMDACTIVE))) (command "")) ) ;; How do I run the command for this lisp then select previous and run it automatically. ;; Below doesn't work. ;; This is the PSIMPLE command to fix polylines. Again it prompts for a selection here. (prompt "\nRUN the PSIMPLE command also ?\n") (load "PSimple") (progn (c:PSIMPLEV) (command "_P") (while (eq 1 (logand 1 (getvar 'CMDACTIVE))) (command "")) ) (setq ss_1 nil) ) (princ "\nUser Cancelled Command\n") ) ) (*error* nil) (princ) ) (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 cmde) (setvar 'osmode os) (setvar 'orthomode orthom) ) (defun SS:startundo () (setq acDoc (vla-get-ActiveDocument (vlax-get-acad-object))) (or (vla-EndUndoMark acDoc) (vla-StartUndoMark acDoc)) ) (vl-load-com) (princ (strcat "\n3dwannab_ByBlock_Change_Entities.lsp Loaded\n" "\nInvoke by typing 'BB'\n" ) ) (princ) ;;----------------------------------------------------------------------;; ;; End of File ;; ;;----------------------------------------------------------------------;;