polylines

Discussion in 'AutoCAD' started by card, Aug 23, 2004.

  1. card

    card Guest

    I've got a polyline with 7 elements (lines and arcs). I want copy one of those elements and insert to another place in drawing.
    I don't want to explode polyline.

    can make this with lisp?

    any help will be greatfull
    ca_rd
     
    card, Aug 23, 2004
    #1
  2. Your polyline is not really made up of lines and arcs, but vertices and bulges. It will be much simpler for you to copy+explode the polyline into arcs and lines than to calculate geometry from the polylines vertices + bulge data.

    Peter
     
    petersciganek, Aug 23, 2004
    #2
  3. card

    BillZ Guest

    This will work with heavy polylines.

    ;08-23-04
    ;Bill Zondlo
    ;program to pick Heavy polyline segment
    ;and copy segment to destination point
    ;
    ;
    ;
    ;---------;
    (defun c:Copy_pline_segment (/ *acad* *acaddoc* *mspace* blg1 Cop_1 en1 enpt loc nxt_vt)
    ;-------------------;
    (vl-load-com)
    (setq e 1) ;select first entity.
    (while e
    (setq en1 (car (nentsel "\nSelect segment of pline:"))
    )
    (cond ((null en1)
    (prompt "\nTry again.") ;loops for null pick.
    )
    ((= (cdr (assoc 0 (entget en1))) "VERTEX") ;a must.
    (setq e nil
    loc (cdr (assoc 10 (entget en1)))
    blg1 (cdr (assoc 42 (entget en1)))
    nxt_vt (entnext en1)
    enpt (cdr (assoc 10 (entget nxt_vt)))
    *acad* (vlax-get-acad-object)
    *acaddoc* (vla-get-activedocument *acad*)
    *mspace* (vla-get-modelspace *acaddoc*)
    )
    ) ;end list
    (t (redraw))
    ) ;end cond.
    ) ;end while.
    ;------------------;
    (setq Cop_1 (vlax-invoke *mspace* 'AddPolyline (apply 'append (list loc enpt))) ;Add polyline.
    )
    (vla-SetBulge Cop_1 0 blg1)
    (command "_.move" (entlast) "" loc pause)
    (princ)
    ) ;end defun


    Bill
     
    BillZ, Aug 23, 2004
    #3
  4. card

    Jürg Menzi Guest

    Hi card

    Try this (works with all kind of polylines):
    Code:
    (defun C:CopyPlineSeg ( / CpyEnt CpyObj CpySet CurObj CurEnt ObjLst OldCmd
    PicPnt *error*)
    (setq OldCmd (getvar "CMDECHO")
    CurEnt (MeSelPline "\nSelect Polyline segment: " T nil)
    )
    (defun *error* (Msg)
    (setvar "CMDECHO" OldCmd)
    (if Msg (princ Msg))
    (princ)
    )
    (if CurEnt
    (progn
    (setq CurObj (vlax-ename->vla-object (car CurEnt))
    PicPnt (vlax-curve-getClosestPointTo CurObj (cadr CurEnt))
    ObjLst (vlax-invoke CurObj 'Explode)
    )
    (vla-put-Visible CurObj :vlax-false)
    (mapcar 'vla-Update ObjLst)
    (if (setq CpyEnt (nentselp PicPnt))
    (progn
    (setq CpyObj (vlax-ename->vla-object (car CpyEnt)))
    (vla-put-Visible CurObj :vlax-true)
    (foreach Obj ObjLst
    (if (not (equal Obj CpyObj)) (vla-delete Obj))
    )
    (setvar "CMDECHO" 0)
    (vl-cmdf "_.MOVE" (car CpyEnt) "")
    (setvar "CMDECHO" 1)
    (vl-cmdf (vlax-get CpyObj 'Startpoint) pause)
    )
    )
    )
    )
    (*Error* nil)
    )
    
    (defun MeSelPline (Pmt 3dp Cls / CurEnt EntFlg EntLst EntNme ExLoop)
    (while (not ExLoop)
    (initget " ")
    (setq CurEnt (entsel Pmt))
    (cond
    ((= CurEnt "") (setq ExLoop T CurEnt nil))
    (CurEnt
    (setq EntLst (entget (car CurEnt))
    EntNme (cdr (assoc  0 EntLst))
    EntFlg (cdr (assoc 70 EntLst))
    )
    (cond
    ((or
    (not (member EntNme '("LWPOLYLINE" "POLYLINE")))
    (and (not 3dp) (= (logand EntFlg  8)  8))
    (= (logand EntFlg 16) 16)
    (= (logand EntFlg 64) 64)
    )
    (princ "selected entity is not a Polyline. ")
    )
    ((and Cls (/= (logand EntFlg 1) 1))
    (princ "selected Polyline is not closed. ")
    )
    ((setq ExLoop T))
    )
    )
    ((princ "1 selected, 0 found"))
    )
    )
    CurEnt
    )
    Cheers
     
    Jürg Menzi, Aug 23, 2004
    #4
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.