Command: CB
Copies objects to clipboard with basepoint 0,0,0
Command: PB
Pastes objects from clipboard with basepoint 0,0,0
Code:
;;; ================================================
;;; COPY_BASE0_v2_01.LSP
;;;
;;; Written by Andrzej Kalinowski, www.autolisps.blogspot.com
;;; v1.00 - 10.08.2016 - first release
;;; v2.00 - 17.12.2021 - added turning off osmode and aecbosmode
;;; v2.01 - 23.07.2022 - updated GET_AECBOSMODE definition, fixed bug with 3D SNAPS
;;; Command: CB - copy with basepoint 0,0,0
;;; Command: PB - paste with basepoint 0,0,0
(defun c:CB (/ sset1 )
(setq sset1 (ssget) )
(CB_PB_COMMON_SETVAR)
(command "_copybase" (list 0.0 0.0 0.0) sset1 "")
(CB_PB_COMMON_RESTORE)
);defun
(defun c:PB (/ )
(CB_PB_COMMON_SETVAR)
(command "_pasteclip" (list 0.0 0.0 0.0) )
(CB_PB_COMMON_RESTORE)
);defun
(defun CB_PB_COMMON_SETVAR ( / )
(setq doc1 (vla-get-activedocument (vlax-get-acad-object)))
(vla-startundomark doc1)
(setq
old_osmode (getvar "OSMODE")
old_aecbosmode (GET_AECBOSMODE);in case in particular autocad version "aecbosmode" command is unknown function returns -1
old_cmdecho (getvar "CMDECHO")
);setq
(if (getcname "3dosmode") (setq old_3Dosmode (getvar "3DOSMODE") ) )
(repeat 3 (terpri))
(setvar "CMDECHO" 0)
(setvar "OSMODE" 0)
(if (getcname "3DOSMODE") (setvar "3DOSMODE" 0) )
(if old_aecbosmode (command "aecbosmode" 0) );if
);defun
(defun CB_PB_COMMON_RESTORE ( / )
(setvar "OSMODE" old_osmode)
(if old_aecbosmode (command "aecbosmode" old_aecbosmode) )
(if (getcname "3DOSMODE") (setvar "3DOSMODE" old_3Dosmode) )
(setvar "CMDECHO" old_cmdecho)
(vla-endundomark doc1)
(setq old_aecbosmode nil old_osmode nil old_3Dosmode nil doc1 nil old_cmdecho nil)
(repeat 3 (princ "\n."))
(princ)
);defun
;;; =================================================
;;; GET_AECBOSMODE_v3_00.LSP
;;; Function gets AECBOSMODE value
;;; Program checks if this variable exists - in this way the main routine will not be limmited to work only in Autocad MEP, where this variable is native
;;; =================================================
(vl-load-com)
(defun GET_AECBOSMODE ( / AecbOM old_cmdecho998)
(if (getcname "AECBOSMODE")
(progn
(setq old_cmdecho998 (getvar "CMDECHO"))
(setvar "CMDECHO" 1);necessary to read last prompt with the urrent AECBOSMODE
(command "AECBOSMODE" )
(command);breaks command
(setq AecbOM (getvar "lastprompt") ) ; returns fe. "Enter new value for AECBOSMODE <1023>:"
(setvar "CMDECHO" old_cmdecho998);restoring cmdecho
(atoi (substr AecbOM (+ (vl-string-search "<" AecbOM) 2) (- (vl-string-search ">" AecbOM) (vl-string-search "<" AecbOM) 1) ) )
);progn
);if
);defun
;;; =================================================
1023>
v1.00 - 10.08.2016 - first release
v2.00 - 17.12.2021 - added turning off osmode and aecbosmode
v2.01 - 23.07.2022 - updated GET_AECBOSMODE definition, fixed bug with 3D SNAPS
Compatibility:
-All Autocad versionss
Download file: COPY_BASE0_v2_01.fas
No comments:
Post a Comment