Jump to content

Accumulative copy lisp


Nobull84

Recommended Posts

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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
Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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
Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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
Link to comment
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
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

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