PDA

View Full Version : 2015 copybase not working inside lisp routine



d.channon
2015-03-17, 11:01 PM
I have a lisp routine I have been using for 3 or 4 years now that basically uses the copybase command, but automates setting the ucs to world and the basepoint to 0,0. For some reason 2015 does not like it. If I step through the routine in the command line it works fine, but falls over once put together in one sequence, comes up with a "Copy to clipboard failed." error.

The main command looks like this (command "COPYBASE" "0,0" SLSET "") where SLSET is just a selection set created using SSGET.

If I enter (command "COPYBASE" "0,0" SLSET) on the command line and manually add the final return it works fine.

Any help would be much appreciated.

Tharwat
2015-03-18, 07:46 PM
Hi ,

I have AutoCAD 2015 installed on my system and I just tried that and it did work just fine .
Just a guess here , try to add Underscore with a dot before the command name if you are working with none English version like this "_.copybase"

Good luck .

Tom Beauford
2015-03-18, 07:53 PM
Without being able to see the lisp it's going to be hard to answer how to fix it.
If (command "COPYBASE" "0,0" SLSET) works same as on the command line maybe add (command) after to close it.

BlackBox
2015-03-18, 09:03 PM
Likewise, I've been using these for years, however they have continued to work in 2015 without issue:



;;;--------------------------------------------------------------------;
(defun c:CB (/ basePoint)
(if (setq basePoint (getpoint "\nSpecify base point: "))
(_CopyBase basePoint "\rCOPYBASE: User specified ")
)
)
(defun c:CC () (_CopyBase '(0 0 0) "\rCOPYBASE: (0.0,0.0,0.0) "))
(defun _CopyBase (basePoint msg / *error* ss cmdecho)
(princ msg)

(defun *error* (msg)
(and cmdecho (setvar 'cmdecho cmdecho))
(cond ((not msg)) ; Normal exit
((member msg '("Function cancelled" "quit / exit abort"))) ; <esc> or (quit)
((princ (strcat "\n** Error: " msg " ** "))) ; Fatal error, display it
)
(princ)
)

(if (and (or (setq ss (ssget "_I")) (setq ss (ssget "_:L")))
(setq cmdecho (getvar 'cmdecho))
(setvar 'cmdecho 0)
)
(command "._copybase" basePoint)
)
(*error* nil)
)
;;;--------------------------------------------------------------------;
(defun c:VV () (c:PasteBase))
(defun c:PasteBase (/ *error* cmdecho)
(princ "\rPASTEBASE: (0.0,0.0,0.0) ")

(defun *error* (msg)
(and cmdecho (setvar 'cmdecho cmdecho))
(cond ((not msg)) ; Normal exit
((member msg '("Function cancelled" "quit / exit abort"))) ; <esc> or (quit)
((princ (strcat "\n** Error: " msg " ** "))) ; Fatal error, display it
)
(princ)
)

(if (and (setq cmdecho (getvar 'cmdecho)) (setvar 'cmdecho 0))
(command "._pasteclip" '(0 0 0))
)
(*error* nil)
)



... The only difference really, is that you're supplying the selection set to the COPYBASE Command, when it works with implied selection already.

Cheers

Tom Beauford
2015-03-19, 11:42 AM
I have Drop-downs in the Ribbon for both Copy and Paste that include the additional macros:

Command Name: Copy with 0,0 as Base Point
Description: Duplicates objects with 0,0 as the base point
Macro:
$M=$(if,$(eq,$(substr,$(getvar,cmdnames),1,8),GRIP),_copybase,^C^C_copybase) 0,0
Using the image RCDATA_16_ID

Command Name: Paste as Group
Description: Pastes objects from the Clipboard into the current drawing as a group
Macro:
^C^C_pasteblock;\(setq LstBlk(vla-get-Name (vlax-ename->vla-object (entlast))));_explode;_last;_-group;_create;*;;_previous;;(command "-purge" "B" LstBlk "N") (setq LstBlk nil) (you must add a space after lisp in a macro)
Using the new group image RCDATA_16_NEWGROUP

I like being able to select everything I just inserted with one click. I've got 2012 thru 2015 installed and it works the same on all of them.

d.channon
2015-04-01, 10:40 PM
Thanks for the responses to this. I still have not been able to make this work. The code is below, just basically checks the ucs, if not world sets it to world, then does a copy base of the users selection and sets usc to previous if necessary. I have tried all combinations of ._copybase, _.copybase etc and still no luck. Any advise would be appreciated.



(DEFUN CB(/ UCSTST SLSET)
(SETQ UCSTST nil)
(setq ucstst (car (getvar "ucsxdir")))
(PROMPT "\nSelect Objects To CopyClip : ")
(SETQ SLSET (SSGET))
(if (/= ucstst 1)
(PROGN
(command "ucs" "w")
(command "._copybase" "0,0" SLSET "")
(command "ucs" "P")
)
(command "._copybase" "0,0" SLSET "")
)
)
(CB)