Jump to content
Nobull84

Accumulative copy lisp

Recommended Posts

Nobull84

Newbie to forum but not to CAD. I need a copy lisp that will add the entered dimension accumulatively.

 

Example: Command; copy, pick object(s), pick base point, enter displacement, "10 foot", first click copies in a direction at ten foot, then twenty, thirty, forty, etc....

 

I would like to be able to do this without having to snap to the last copied object (as the standard copy command would be used for). The type of work I do, the drawings can be very busy and snaps can move too easily. The other reason is for speed.

 

Hopefully I have been clear in what I need. Thanks for the help with this one and thank you for the help I've already taken from this website.

 

-Nobull

Share this post


Link to post
Share on other sites
ReMark

What you just described sounds like the ARRAY command. In your example it is one row and "X" columns.

Share this post


Link to post
Share on other sites
Nobull84

Yes, a quicker version of -array is what I'm after. Instead of asking for number of columns (or rows) you can just click for another object and add them individually at whatever dimension entered infinitely until the command is killed. thanks again, -Nobull

Share this post


Link to post
Share on other sites
Tuns

Array is faster IMO. It would take less time to enter a couple of settings and just stretch the array to whatever length you need it to be.

Share this post


Link to post
Share on other sites
Nobull84

This would work great if I could enter the dimension. Only option with this is to click the measurement with snap. And the ability to just click per each copy I would like instead of entering the amount.... If someone could tweak this would be great. Thank you to ReMark for getting this down the right path.

(defun c:CM (/ *error* ss p1 p2 d a)
 ;; Copy Multiple Times
 ;; Alan J. Thompson, 03.30.10 / 12.22.10 / 2013.07.05

 (defun *error* (msg)
   (and *AcadDoc* (vla-endundomark *AcadDoc*))
   (if (and msg (not (wcmatch (strcase msg) "*BREAK*,*CANCEL*,*QUIT*,")))
     (progn (vl-bt) (princ (strcat "\nError: " msg)))
   )
 )

 (vla-startundomark
   (cond (*AcadDoc*)
         ((setq *AcadDoc* (vla-get-activedocument (vlax-get-acad-object))))
   )
 )

 (if (and (setq ss (ssget "_:L"))
          (setq p1 (getpoint "\nSpecify base point: "))
          (setq p2 (if acet-ss-drag-move
                     (acet-ss-drag-move ss p1 "\nSpecify next point: " T)
                     (getpoint p1 "\nSpecify next point: ")
                   )
          )
     )
   (progn
     (setq d  0.
           p1 (trans p1 1 0)
           p2 (trans p2 1 0)
           a  (angle p1 p2)
     )

     (initget 6)
     (setq *CM:Num* (cond ((getint (strcat "\nNumber of copies <"
                                           (itoa (cond (*CM:Num*)
                                                       ((setq *CM:Num* 1))
                                                 )
                                           )
                                           ">: "
                                   )
                           )
                          )
                          (*CM:Num*)
                    )
     )
     (repeat *CM:Num*
       (setq d (+ (distance p1 p2) d))
       (vlax-for x (setq ss (vla-get-activeselectionset *AcadDoc*))
         (vlax-invoke (vla-copy x) 'Move p1 (polar p1 a d))
       )
     )
     (vla-delete ss)
   )
 )
 (*error* nil)
 (princ)
)
(vl-load-com)
(princ)

Edited by SLW210
Added Code Tags

Share this post


Link to post
Share on other sites
Nobull84

And I apologize for not being able to post this in the right format as all the rest of the threads show. I guess the newbie title to the left is appropriate....

Share this post


Link to post
Share on other sites
Tuns

You can enter the dimension. What are you talking about? You can specify the distance between rows and columns. You should also be able to stretch the array to whatever you need without typing in a specific amount. Just do a bit of reading on arrays. It may change your opinion.

Share this post


Link to post
Share on other sites
ReMark

alan's routine does allow you to specify a dimension. Didn't you read the part where I said I tested it?

 

You can conduct your own search using the following:

 

"copy multiple"+"lisp" or "copy"+"multiple"+"lisp"

 

Maybe you'll have better luck finding what you need.

Edited by ReMark

Share this post


Link to post
Share on other sites
Nobull84

basically how the offset command can offset individual times with the multiple option but I want the root command to be copy. The types of objects I want to do this with can not be offset... Hopefully that helps get across what I'm after... Thank you again to all that have responded.

Share this post


Link to post
Share on other sites
ReMark

So don't give you what you asked for rather give you what you need? Gotcha!;)

 

We'll see what we can come up with.

Share this post


Link to post
Share on other sites
Nobull84

Now I believe I found damn near exactly what I'm looking for. The attached code, by Patrick Evangelista, is perfect except one minor change. With this, you can only select one item at a time. Can someone tweak this a little to be able to select multiple objects? Thank you in advance again.

 


;;; CADALYST 09/07  Tip 2236: copy_agn.lsp Continued Copy (c) 
2007 Patrick Evangelista


;;;;;;; copy again...again...again..."
(defun c:CCC ()
 
(setq obj (entsel "\nSelect object to copy: ")
pt1 (getpoint 
"\nPick base point:")
 )
 (initget 62)
 
(setq pt2 (getpoint pt1 "\nNext point:")
kk  'T
 
)
 (command "copy" obj "" pt1 pt2)
 (while 
KK
   (progn (initget "X")
   (setq opt 
(getkword "\nEnter to continue/X to exit: "))
   (cond ((= 
opt nil) (command "copy" (entlast) "" pt1 pt2))
  ((= opt "X") 
(setq kk nil))
   )
   )
 
)
)

Share this post


Link to post
Share on other sites
Nobull84

I really need to take the time to learn how to do this....

Share this post


Link to post
Share on other sites
RobDraw

A non-code way to do this would be to turn on and set SNAP to the required distance.

Share this post


Link to post
Share on other sites
marko_ribar

This functionality of continuous copying is implemented into my mcr.lsp... I strongly suggest that you view and use mcr, as it's much better and faster than EXPRESS MOCORO, and beside all this it also has implemented more options like arrays and so on... It also has powerful undo option after witch you can continue to do new actions like you've accidently mistaken and base point is remebered so no need for any redefinition... Still you can always do and redefinition of sel. set of objects and their base point... So all in all it's very powerful and useful application and can replace your version of CCC.lsp (I use mcr.lsp constantly - it's also precise and didn't find any lack in its usage if in combination with SNAPs)...

 

Check it here...

 

Regards, M.R.

Share this post


Link to post
Share on other sites
Lee Mac

Maybe I have misunderstood your requirements, but could you not simply set COPYMODE=0 and use the standard COPY command?

Share this post


Link to post
Share on other sites
marko_ribar
Maybe I have misunderstood your requirements, but could you not simply set COPYMODE=0 and use the standard COPY command?

 

I think you misunderstood, I think OP wants to set just single copy operation and then hit ENTER or proceed and to repecate last copy operation many times, but all this with sel. set of entities instead of just single entity...

Share this post


Link to post
Share on other sites
Lee Mac

Ok, try this:

(defun c:ccc ( / idx lst pt1 pt2 sel vec )
   (if
       (and
           (setq sel (ssget "_:L"))
           (setq pt1 (getpoint "\nPick base point: "))
           (setq pt2 (getpoint "\nPick copy vector: " pt1))
       )
       (progn
           (repeat (setq idx (sslength sel))
               (setq lst (cons (vlax-ename->vla-object (ssname sel (setq idx (1- idx)))) lst))
           )
           (setq pt2 (trans (mapcar '- pt2 pt1) 1 0 t)
                 vec pt2
           )
           (mycopy lst pt2)
           (while
               (progn
                   (initget "Yes No")
                   (/= "No" (getkword "\nContinue? [Yes/No] <Yes>: "))
               )
               (mycopy lst (setq pt2 (mapcar '+ pt2 vec)))
           )
       )
   )
   (princ)
)

(defun mycopy ( lst vec )
   (foreach obj lst (vlax-invoke (vla-copy obj) 'move '(0.0 0.0 0.0) vec))
)
(vl-load-com) (princ)
Edited by Lee Mac

Share this post


Link to post
Share on other sites

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
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  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...