Copy circle to endpoints of all lines selected

Discussion in 'AutoCAD' started by Steve, May 12, 2004.

  1. Steve

    Steve Guest

    I hope someone already has a lisp for this they would like to share. I want
    to copy an object (i.e. circle or block) from a point on that object to the
    endpoints of 1000's of selected lines. Is this possible? or do I have to
    set endpoint snap on and do it manually.

    Thanks,

    steve
     
    Steve, May 12, 2004
    #1
  2. Steve

    btlsp Guest

    Loop through end points, test for duplication, draw circle.
     
    btlsp, May 12, 2004
    #2
  3. Steve

    ECCAD Guest

    Try this:
    ;; Copy selected object to endpoints of LINES..
    ;;
    ;; Define DXF function
    ;;
    (defun dxf (code elist)
    (cdr (assoc code elist))
    ); end function dxf
    ;;
    (defun copy_to_ends () ; Copy object to end-points of lines..
    (prompt "\nPick Object to Copy to EndPoints:")
    (setq obj (ssget))
    (if obj
    (progn
    (command "_limits" "off"); in case..
    (setq IP (cdr (assoc 10 (entget (ssname obj 0)))))
    (prompt "\nSelect Lines:")
    (setq ss (ssget))
    (if ss
    (progn
    (setq n (sslength ss))
    (if (> n 0)
    (progn
    (setq C 0 E 1); C = entity selecter, starts at 0, goes 1,2,3..
    (repeat n
    (setq D (ssname ss C)); get entity name from 'A', if no name, D is nil.
    (if (/= D nil); found something ?
    (progn
    (setq chk (entget D))
    (if (= "LINE" (cdr (assoc 0 chk))); case of LINES
    (progn
    (setq ep1 (cdr (assoc 10 chk))); End Point 1
    (setq ep2 (cdr (assoc 11 chk))); End Point 2
    (if (and (/= ep1 nil)(/= ep2 nil))
    (progn
    (command "_copy" obj "" IP ep1)
    (command "_copy" obj "" IP ep2)
    ); end progn
    ); end if
    ); end progn
    ); end if
    ); end progn
    ); end if
    (setq C (+ C 1))
    ); end repeat
    ); end progn
    ); end if
    ); end progn
    ); end if
    ); end progn
    ); end if
    (command "_limits" "on")
    (princ)
    ); end function
    (copy_to_ends)
    (princ)
     
    ECCAD, May 12, 2004
    #3
  4. Steve

    TCEBob Guest

    Perhaps this will help:

    (defun c:c2l( / sset item spt n lgth nextline)
    (prompt "\nSelect the target lines: ")
    (cond
    ((not(setq sset(ssget '((0 . "LINE"))))))
    ((not(setq item (entsel "\nSelect the object to copy: "))))
    ((not(setq spt (getpoint "\nSpecify base point: "))))
    (T
    (setq lgth (sslength sset))
    (setq n 0)
    (while (< n lgth)
    (setq nextline(entget(ssname sset n)))
    (command "copy" item "" spt (cdr(assoc 10 nextline))
    "copy" item "" spt (cdr(assoc 11 nextline))
    )
    (setq n(1+ n))
    ) ;while
    ) ;T
    ) ;cond
    (princ))


    rs
     
    TCEBob, May 12, 2004
    #4
  5. Steve

    JRWalker Guest

    Hi,
    I whipped this up real quick, it should do what you want (doesn't have a lot
    of error checks)

    JRWalker

    (defun CopyToEndPts ()
    (setq COPY_ITEM (ssget))
    (setvar "OSMODE" 39) ;get endpoint, intersect, mid, and center
    (setq BASE_PT (getpoint "\nSelect Base Point"))
    (prompt "\nSelect Lines to Copy To..")
    (setq LINE_SS (ssget))
    (progn
    (setq CNT 0)
    (while (< CNT (sslength LINE_SS))
    (setq ED (entget (ssname LINE_SS CNT)))
    (setq EN (cdr (assoc 0 ED)))
    (if (= EN "LINE")
    (progn
    (setq
    PT0 (cdr (assoc 10 ED))
    PT1 (cdr (assoc 11 ED))
    ) ;setq
    (command "_.copy" COPY_ITEM "" BASE_PT PT0)
    (command "_.copy" COPY_ITEM "" BASE_PT PT1)
    ) ;progn
    ) ;if
    (setq CNT (1+ CNT))
    ) ;while
    ) ;progn
    )
     
    JRWalker, May 13, 2004
    #5
  6. Steve

    Steve Guest

    Thank you to all for the awesome code, I got it to work!!

    S
     
    Steve, May 13, 2004
    #6
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.