Join Plines lisp needs a little help...

Discussion in 'AutoCAD' started by calpolyarc, Aug 13, 2004.

  1. calpolyarc

    calpolyarc Guest

    Ok, I'm proud of myself for getting at least this far, I've got a lisp that will join two seperate plines into one pline. What would be better though is if I could include a conditional statement where if the plines were just lines it would still work. Can somebody please help!

    (defun C:plinejoin ()
    (setq obs (ssget))
    (command "_pedit" "m" obs "" "j" "" "" "")
    (princ)
    )

    Here is another routine that does the same thing:
    (command "_pedit" "m" (ssget) "" "j" "" "" "")
    (princ)
    )

    Just thought of this... what if some of the lines are plines and some are not? Thanks for any help!!
     
    calpolyarc, Aug 13, 2004
    #1
  2. calpolyarc

    Walt Engle Guest

    So why not use pljoin - a lsp routine that is already available?
     
    Walt Engle, Aug 13, 2004
    #2
  3. calpolyarc

    John Uhden Guest

    Heads up, Jürg.
    (if (AND (/= (getvar "PEDITACCEPT") 1)(member (cdr (assoc 0 (entget FstEnt)))
    '("LINE" "ARC")))
    ....
     
    John Uhden, Aug 14, 2004
    #3
  4. calpolyarc

    Jürg Menzi Guest

    Hi John
    Well, agree since A2k4 - my piece of code is pre A2k...

    Cheers
     
    Jürg Menzi, Aug 14, 2004
    #4
  5. calpolyarc

    calpolyarc Guest

    Thanks guys,
    am I supposed to subtitute one of Jurg's lines with John's line?
     
    calpolyarc, Aug 14, 2004
    #5
  6. calpolyarc

    John Uhden Guest

    That's okay. As Jürg well knows, the addition won't hurt pre-R16 as (getvar
    "peditaccept") would simply return nil.
     
    John Uhden, Aug 15, 2004
    #6
  7. This is my version (credits?):

    Code:
    ; #PlineJoinPrec = global
    ;
    (defun C:ALE_PlJoin (/ SelSet FltLst OldLPr)
    ;(setvar "CMDECHO" 0) ; I have always = 0
    (princ "\nSelect lines, arcs or polylines to join:  ")
    (setq OldLPr (getvar "LUPREC"))  (setvar "LUPREC" 8)
    (setq
    FltLst
    '((0 . "LWPOLYLINE,POLYLINE,LINE,ARC"))
    #PlineJoinPrec
    (ureal 5 "" "Precision distance" (cond ( #PlineJoinPrec ) ( 0.00001 )))
    )
    (setvar "LUPREC" OldLPr)
    (cond
    ( (not (setq SelSet (cond ((ssget "_I" FltLst)) ((ssget FltLst)))))
    (prompt "\nNo arc or polyline selected.  ")
    )
    ( (ssget "_P" '((0 . "LINE,ARC")))
    (command "_.PEDIT" "_M" SelSet "" "_Y" "_J" "_J" "_E" #PlineJoinPrec
    "")
    (princ (strcat
    "\n" (itoa (sslength SelSet))
    " lines, arcs or polylines are joined.  "
    )       )
    )
    ( T
    (command "_.PEDIT" "_M" SelSet "" "_J" "_J" "_E" #PlineJoinPrec "")
    (princ "\n_ ")
    (princ (strcat "\n " (itoa (sslength SelSet)) " polylines are joined.
    "))
    )
    )
    (princ)
    )
    ;*
    ;* UREAL  Funzione di interfaccia utente per numeri reali.
    ;* BIT (0 per nessuno) e KWD key word ("" per nessuna) sono gli stessi di
    ;* INITGET.
    ;* MSG e' la stringa di prompt, alla quale e' aggiunto numero reale di
    default
    ;* come <DEF> (nil per nessuno), e un : sara' aggiunto.
    ;*
    (defun ureal (bit kwd msg def / inp)
    (if def
    (setq
    msg (strcat "\n" msg " <" (ALE_RTOS_DZ8 def) ">: ")
    bit (* 2 (fix (/ bit 2)))
    )
    (setq msg (strcat "\n" msg ": "))
    )
    (initget bit kwd)
    (setq inp (getreal msg))
    (if inp inp def)
    );defun UREAL
    ;
    (defun ALE_RTOS_DZ8 (real_val / old_dimzin new_val)
    (setq old_dimzin (getvar "DIMZIN"))
    (setvar "DIMZIN" 8)
    (setq new_val (rtos real_val 2))
    (setvar "DIMZIN" old_dimzin)
    new_val
    )
    
    --

    Marc'Antonio Alessi
    http://xoomer.virgilio.it/alessi
    (strcat "NOT a " (substr (ver) 8 4) " guru.")

    --
     
    Marc'Antonio Alessi, Aug 16, 2004
    #7
  8. calpolyarc

    mark Guest

     
    mark, Aug 16, 2004
    #8
  9. calpolyarc

    BTO Guest

    try with 20000 entities ;) and compare

    Bruno Toniutti
     
    BTO, Aug 20, 2004
    #9
  10. calpolyarc

    BTO Guest

    hi,
    in this case too (peditaccept = 1), pedit reacts differently with a line (or
    arc) or à *polyline.
    Only *polyline keeps their entity name. That can cause problems

    Bruno Toniutti.
     
    BTO, Aug 20, 2004
    #10
  11. calpolyarc

    John Uhden Guest

    That's why it's up to you to set it the way you want, and why the program must
    be written to obey your <anyone's> setting.
     
    John Uhden, Aug 21, 2004
    #11
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.