See the top rated post in this thread. Click here

Page 1 of 2 12 LastLast
Results 1 to 10 of 14

Thread: Autocad LISP -- copy (multiple times) between two points -- LISP

  1. #1
    Member
    Join Date
    2010-08
    Posts
    9
    Login to Give a bone
    0

    Default Autocad LISP -- copy (multiple times) between two points -- LISP

    Dear all CAD user....

    I do have one wish / question -- does anybody has written LISP for Autocad to do >>

    -- Copy selected Elements / or Block and place it between two selected (clicked) points multiple times ....

    Example >> on attached picture >>>

    So copied lements / Block will be placed 4 times between (for example -- will be great if user can type how many copies will be created ) ... selected TWO points ( p1,, and p2 - must be clicked by user ...

    Thanks a lot for any advice

    Adamcopy.pdf

  2. #2
    Administrator Opie's Avatar
    Join Date
    2002-01
    Location
    jUSt Here (a lot)
    Posts
    9,096
    Login to Give a bone
    0

    Default Re: Autocad LISP -- copy (multiple times) between two points -- LISP

    For a work-around until such a routine is created, you could use the divide command in association with a line, arc, polyline to space blocks equally along the object.
    If you have a technical question, please find the appropriate forum and ask it there.
    You will get a quicker response from your fellow AUGI members than if you sent it to me via a PM or email.
    jUSt

  3. #3
    All AUGI, all the time
    Join Date
    2010-06
    Posts
    962
    Login to Give a bone
    0

    Default Re: Autocad LISP -- copy (multiple times) between two points -- LISP

    What about the base point for the selected elements ? would it be picked by a user ?

  4. #4
    Member
    Join Date
    2010-08
    Posts
    9
    Login to Give a bone
    0

    Default Re: Autocad LISP -- copy (multiple times) between two points -- LISP

    Thanks for advice.
    But the line from sketch is only help line for sketch,, in autocad drawing is many times situation where the line is not exist. Yes I can create it, but its a lot of work... afterwards deleting it. Thats why I looking for this list routine

    thx
    adam

  5. #5
    Member
    Join Date
    2010-08
    Posts
    9
    Login to Give a bone
    0

    Default Re: Autocad LISP -- copy (multiple times) between two points -- LISP

    Base point can be picked by user,, as is on standard copy command

  6. #6
    All AUGI, all the time
    Join Date
    2010-06
    Posts
    962
    Login to Give a bone
    1

    Default Re: Autocad LISP -- copy (multiple times) between two points -- LISP

    This one ... ?

    Code:
    (defun c:Test (/ ss p p1 p2 pt n l d c lst)
      (if (and (setq ss (ssget "_:L"))
               (setq p (getpoint "\n Specify Base point of objects :"))
               (setq p1 (getpoint "\n Specify first point :"))
               (setq p2 (getpoint "\n Next point :" p1))
               (setq n (getint "\n Number of copies :"))
          )
        (progn
          (setq l (distance p1 p2)
                d (/ l n)
                c (getvar 'CMDECHO)
          )
          (setvar 'CMDECHO 0)
          (repeat (1- n)
            (command "_.copy"
                     ss
                     ""
                     "_none"
                     p
                     "_none"
                     (setq pt (polar p1 (angle p1 p2) d))
            )
            (setq p1 pt)
          )
          (setvar 'CMDECHO c)
        )
      )
      (princ)
    )

  7. #7
    Member
    Join Date
    2010-08
    Posts
    9
    Login to Give a bone
    0

    Default Re: Autocad LISP -- copy (multiple times) between two points -- LISP

    Thanks a lot, does work great ... exactly as I need ...
    Just one thing I will mention ...
    instead of >> Number of Copies >> better co call it >> Number or EQ spaces ..... because actually the Numbers of copies is always one less then input number ( But this I can change myself in your Lisp code )

    THANKS A LOT

    ps ... could you add a new code .... witch will do the same , but will create copy on First and Second point as well ( at the beginning and the end )

    ADAM

  8. #8
    Member
    Join Date
    2010-08
    Posts
    9
    Login to Give a bone
    0

    Thumbs up Re: Autocad LISP -- copy (multiple times) between two points -- LISP

    BIG thanks to >> mr. Tharwat for the LISP ...

    I did some change into lisp .. but only to Command name to start it ...

    Lisp start after command >>
    CM2P
    or
    CopyMultipleArrayBetween2point

    and attaching an Lisp FILE for others ....

    CopyMultipleArrayBetween2point.lsp


    regards Adam

  9. #9
    All AUGI, all the time
    Join Date
    2010-06
    Posts
    962
    Login to Give a bone
    1

    Default Re: Autocad LISP -- copy (multiple times) between two points -- LISP

    You're welcome Adam , I am happy that my code worked for you as you wanted .

    So try this modified one as you have requested .

    Code:
    (defun c:CM2P nil (c:CopyMultipleArrayBetween2point))
    (defun c:CopyMultipleArrayBetween2point
           (/ *error* ss p p1 p2 pt n l d c lst)
      ;; Author : Tharwat ~ 15. Jan. 2014	;;
      (defun *error* (pm)
        (if c
          (setvar 'CMDECHO c)
        )
        (princ "\n *Cancel*")
      )
      (if (and (setq ss (ssget "_:L"))
               (setq p (getpoint "\n Specify Base point of objects :"))
               (setq p1 (getpoint "\n Specify first point :"))
               (setq p2 (getpoint "\n Next point :" p1))
               (setq n (getint "\n Number of EQ spaces :"))
          )
        (progn
          (setq l (distance p1 p2)
                d (/ l n)
                c (getvar 'CMDECHO)
          )
          (setvar 'CMDECHO 0)
          (foreach x (list p1 p2)
            (command "_.copy" ss "" "_none" p "_none" x)
          )
          (repeat (1- n)
            (command "_.copy"
                     ss
                     ""
                     "_none"
                     p
                     "_none"
                     (setq pt (polar p1 (angle p1 p2) d))
            )
            (setq p1 pt)
          )
          (setvar 'CMDECHO c)
        )
      )
      (princ)
    )

  10. #10
    I could stop if I wanted to CadDog's Avatar
    Join Date
    2005-06
    Location
    So Ca
    Posts
    439
    Login to Give a bone
    1

    Default Re: Autocad LISP -- copy (multiple times) between two points -- LISP

    Don't forget that you can also do this with divide command...

    On the command line type: "div"

    --Select object to divide: ( work with arc, plines, etc.)

    --Enter the number of segments or [Block] "B"
    "(this uses the block insertion point) "type block name")"

    --Enter name of block to insert: "XX"

    --Align block with object? [Yes/No] <Y>: "your call here"

    --Enter the number of segments: "amount of blocks you like to use" then enter...

    I hope this helps

Page 1 of 2 12 LastLast

Similar Threads

  1. Copy in lisp and multiple
    By Jimbob in forum AutoLISP
    Replies: 4
    Last Post: 2012-05-22, 07:30 PM
  2. Midway between 2 points (multiple times in a row)
    By sprinkler.usa394840 in forum AutoCAD General
    Replies: 4
    Last Post: 2011-03-10, 08:14 PM
  3. copy rotate object multiple times
    By gary.betts in forum AutoCAD Mechanical - Wish List
    Replies: 5
    Last Post: 2009-03-09, 12:36 PM
  4. Replies: 4
    Last Post: 2005-11-15, 09:33 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •