Author Topic: Copy+Pan  (Read 1475 times)

0 Members and 1 Guest are viewing this topic.

amc.dicsac

  • Newt
  • Posts: 109
  • Autocad 2008
Copy+Pan
« on: April 22, 2016, 01:54:10 PM »
Hello, I HAVE A COPY TO LISP selected objects to a given distance, LISP THIS IS ADDED THE COMMAND PAN him, the distance is saved in a variable (USERS) THE PROBLEM IS THAT CAN NOT BE SO MULTIPLE COPY. (The variable distance is separated from lisp test1 as there are other lisp that depend on this variable is therefore not incorporated eh).


Lisp variable test1
Code: [Select]
(defun c:DE (/ CAD us1)
(setvar "cmdecho" 0)
(setq us1 (getvar "USERS3"))
(setq CAD (GETSTRING "\nDistance specify: "))
(COMMAND "SETVAR""USERS3"CAD)
(setvar "cmdecho" 1)
(princ))


Lisp test1
Code: [Select]
(defun c:test1 (/ di cad cadu)
(setvar "cmdecho" 0)
(setq di (getvar "USERS3"))
(setq cad (strcat "@"di"<270"))
(setq cadu (strcat "@"di"<90"))
(setq ss (ssget "_:L"))
(command "copy" ss "" "0,0,0" cad )
(command "-Pan""0,0,0"cadu)
(setvar "cmdecho" 1)
(princ))
<a href="http:/http://axprogramlisp.blogspot.pe" class="bbc_link" target="_blank">By Alexander Castro</a>

PKENEWELL

  • Bull Frog
  • Posts: 318
Re: Copy+Pan
« Reply #1 on: April 22, 2016, 04:04:00 PM »
OK - Given I don't understand WHY this code is setup the way it is - consider the following:

1) The USERS1-5 system variables are not saved in either the drawing or the registry, so they just disappear if the drawing is closed and reloaded. There would be no difference if you just saved the value in a Global Variable:
Code - Auto/Visual Lisp: [Select]
  1. (setq Global:Cad (Getstring "\nDistance specify: "))
  2. ;; (COMMAND "SETVAR""USERS3"CAD) - uneeded
Code - Auto/Visual Lisp: [Select]
  1. ;; (setq di (getvar "USERS3")) - uneeded
  2. (setq cad (strcat "@" Global:Cad "<270"))

2) If you are storing a distance only, it would be better to use the USERR1-5 system variables, then use RTOS to convert:
Code - Auto/Visual Lisp: [Select]
  1. (setq CAD (Getreal "\nDistance specify: "))
  2. (setvar "USERR3" CAD);;You don't need to use (COMMAND) here, just the (setvar) function
Code - Auto/Visual Lisp: [Select]
  1. (setq di (getvar "USERR3"))
  2. (setq cad (strcat "@"(rtos di) "<270"))

It would help if you better explain the reason behind this code. What are you trying to accomplish? Why are you using a different command to set the distance, then retrieving it for another command? Are there multiple commands that use the same value? Are you trying to speed things up by using a separate command to specific a common distance, then quickly use that distance for moves?

With a better understanding, perhaps I can give you a better solution that is a bit more elegant.

EDIT: Sorry - I understand that you are using the distance variable in more than one program after re-reading your post. However - I cannot understand what you mean by "THE PROBLEM IS THAT CAN NOT BE SO MULTIPLE COPY". Could you please explain further? Thanks.

EDIT 2: OK - I think I understand. your immediate answer is simple - just add an empty string at the end of the following:
Code - Auto/Visual Lisp: [Select]
  1. (command "copy" ss "" "0,0,0" cad  "");;Add the "" to end the command
« Last Edit: April 22, 2016, 05:24:39 PM by PKENEWELL »
"When you are asked if you can do a job, tell 'em, 'Certainly I can!' Then get busy and find out how to do it." - Theodore Roosevelt

amc.dicsac

  • Newt
  • Posts: 109
  • Autocad 2008
Re: Copy+Pan
« Reply #2 on: April 22, 2016, 05:31:49 PM »
The problem lies in the following: run the lisp select objects and copy distance, then when I want to continue copying have run the lisp and reselect the objects and so, what I want is to make a loop to continue copiandoy moving with bread now if I understand.  :blink:
<a href="http:/http://axprogramlisp.blogspot.pe" class="bbc_link" target="_blank">By Alexander Castro</a>

PKENEWELL

  • Bull Frog
  • Posts: 318
Re: Copy+Pan
« Reply #3 on: April 22, 2016, 06:06:16 PM »
The problem lies in the following: run the lisp select objects and copy distance, then when I want to continue copying have run the lisp and reselect the objects and so, what I want is to make a loop to continue copiandoy moving with bread now if I understand.  :blink:

If you mean you wish to: Copy > Pan > Copy > Pan... without pausing to enter a new distance, I think your attempting to start something that would cause an infinite loop. You have to incorporate a stop with a prompt to "Continue?". You would also need to collect the new copies into a new selection set and start moving from a new location (such as using (getvar "lastpoint")), or accumulate the distance. Also - You are panning up 90 degrees, while you coping horizontally? Does that mean you need the next copy to start above the previous one? Sorry - I am not sure I understand what you are trying to do still.

Can you provide a drawing that shows the Before and After Steps to show what you need to accomplish?
"When you are asked if you can do a job, tell 'em, 'Certainly I can!' Then get busy and find out how to do it." - Theodore Roosevelt