TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: TJAM51 on December 03, 2004, 07:35:01 AM

Title: PLINE JOIN
Post by: TJAM51 on December 03, 2004, 07:35:01 AM
I am seeking a routine that will join a pline and offer a crossing or pick without having to go throuh all the PEDIT process....thanks
Title: PLINE JOIN
Post by: Keith™ on December 03, 2004, 07:53:27 AM
If you have express tools use pljoin
Title: PLINE JOIN
Post by: CAB on December 03, 2004, 08:05:51 AM
I have this but never tried it.
Code: [Select]
;;  from Marc'Antonio Alessi (nospam_maalessi_at_tin_dot_it)
; #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 (ReaVal / CurDZn OutVal)
  (if (= 8 (setq CurDZn (getvar "DIMZIN")))
    (setq CurDZn nil)
    (setvar "DIMZIN" 8)
  )
  (setq OutVal (rtos ReaVal 2))
  (and CurDZn (setvar "DIMZIN" CurDZn))
  OutVal
)
Title: Re: PLINE JOIN
Post by: SMOKIIBEAR on November 15, 2005, 06:20:04 PM
HOW CAN THIS ROUTINE BE REWRITTEN SO THAT IT IS NOT NECESSARY TO ENTER FUZZ DISTANCE AT THE COMMAND LINE EACH TIME, BUT THE OPTION COULD BE AVAILABLE?
Title: Re: PLINE JOIN
Post by: Mark on November 15, 2005, 06:33:57 PM
If you have a few dollars and don't want to write you own .... GBPoly [ http://www.geometricad.com/ ] You'll find it hard to beat. :-)
Title: Re: PLINE JOIN
Post by: DanB on November 16, 2005, 12:22:57 PM
Here's the one I use...

Code: [Select]
;;
;; 06/22/05
;; Polyline Joins Selected Objects
;;
  (defun c:j (/ ss)
   (prompt "\nSelect Objects to Join... ")
   (setq ss (ssget))
   (command "pedit" "m" ss "" "j" "" "")
   (princ)
  )

Title: Re: PLINE JOIN
Post by: deegeecees on November 16, 2005, 12:46:46 PM
If you have a few dollars and don't want to write you own .... GBPoly [ http://www.geometricad.com/ ] You'll find it hard to beat. :-)


Very good app.
Title: Re: PLINE JOIN
Post by: LE on November 16, 2005, 12:54:13 PM
Yes....

Here is a link to see GBPOLY in action:

http://www.geometricad.com/app.php?id=1&lang=en

There are a lot of open source, samples on how to join plines, lines and arcs, if you are looking for a smart and easy way to generate closed areas, then give GBPOLY a try.
Title: Re: PLINE JOIN
Post by: SMOKIIBEAR on November 16, 2005, 02:44:16 PM
Ahhh...that makes me happy :lmao:

Thanks.  One of these days, I need to starting writing lisp.
Title: Re: PLINE JOIN
Post by: whdjr on November 16, 2005, 03:04:28 PM
How about sooner that later.

Lisp Forum (http://www.theswamp.org/forum/index.php?board=26.0)
Lisp Course Documents (http://www.theswamp.org/forum/index.php?topic=7036.0)
Title: Re: PLINE JOIN
Post by: Swift on November 16, 2005, 03:09:11 PM
How about sooner that later.

Lisp Forum (http://www.theswamp.org/forum/index.php?board=26.0)
Lisp Course Documents (http://www.theswamp.org/forum/index.php?topic=7036.0)

Quote
An Error Has Occurred!
The topic or board you are looking for appears to be either missing or off limits to you
Title: Re: PLINE JOIN
Post by: deegeecees on November 16, 2005, 03:16:46 PM
How about sooner that later.

Lisp Forum (http://www.theswamp.org/forum/index.php?board=26.0)
Lisp Course Documents (http://www.theswamp.org/forum/index.php?topic=7036.0)
Quote
An Error Has Occurred!
The topic or board you are looking for appears to be either missing or off limits to you

Ditto.
Title: Re: PLINE JOIN
Post by: whdjr on November 16, 2005, 03:19:13 PM
I think that was invitation only forum.  You had to sign up for the class.

Maybe Mark can unlock that for everyone?

edit
Sorry 'bout that guys I forgot.
Title: Re: PLINE JOIN
Post by: Keith™ on November 16, 2005, 03:19:24 PM
I get the same thing .... perhaps when Mark was playing around with the board he got it mal-adjusted ...
Title: Re: PLINE JOIN
Post by: jonesy on November 17, 2005, 02:47:22 AM
That was a course that was run by Stig. We had to sign up for the course. I believe its only for the students on Stigs course.
T :-)
Title: Re: PLINE JOIN
Post by: jonesy on November 17, 2005, 02:50:29 AM
However I just remembered about  This (http://klobouk.fsv.cvut.cz/~chour/Lisp/Contents.htm)

I havent tried it myself yet, so I'm not sure about its content.

Happy reading.

T :-)
Title: Re: PLINE JOIN
Post by: CAB on November 17, 2005, 08:23:58 AM
I just got both links but I was signed up. :-)
Or perhaps Mark changed something.
Title: Re: PLINE JOIN
Post by: Andrea on November 17, 2005, 09:46:44 PM
I am seeking a routine that will join a pline and offer a crossing or pick without having to go throuh all the PEDIT process....thanks

some info is missing here...
if you have 2 PLINEs or LINEs...
but in diffrent color and/or linetype....

How can you detect wich you need to joint ??

eg: you have a RED pline and a BLUE LINE...
you need to joint both..

but, need to take the BLUE layer...or color...or linetype...
if after making...you result was RED in wrong layer...
you do not have saved much time... and even worse.

isn't it ?

so that why i think crossing option is not good idea.  :kewl:
Title: Re: PLINE JOIN
Post by: whdjr on November 18, 2005, 08:48:15 AM
The one you pick first should be the dominent line.  If you pick blue then red then the new line will be blue.
Title: Re: PLINE JOIN
Post by: Andrea on November 18, 2005, 01:23:35 PM
Ok, I have wrote this..few year ago..
maybe the syntax is not perfect..but you can verify and modify as your own..

Code: [Select]
;;By Andrea Andreeti ;;
(defun c:joncline ()
  (ljgvar2nil)
  (setq ljg1_sel1 (entsel "Select line 1... "))
  (if (= ljg1_sel1 nil)(exit)
    (progn
  (setq ljg1_sel2 (entget (car ljg1_sel1)))
  (setq ljg_ent (cdr (assoc 0 ljg1_sel2)));;type d'entité
  (if (/= ljg_ent "LINE")(ljg_expline1))
  ))
  (setq ljg1_pt1 (cdr (assoc 11 ljg1_sel2)))
  (setq ljg1_pt2 (cdr (assoc 10 ljg1_sel2)))

 
  (setq ljg2_sel1 (entsel "Select line 2... "))
  (if (= ljg2_sel1 nil)(exit) 
    (progn
  (setq ljg2_sel2 (entget (car ljg2_sel1)))
  (setq ljg_ent (cdr (assoc 0 ljg2_sel2)));;type d'entité
  (if (/= ljg_ent "LINE")(ljg_expline2))
  ))
  (setq ljg2_pt1 (cdr (assoc 11 ljg2_sel2)))
  (setq ljg2_pt2 (cdr (assoc 10 ljg2_sel2)))

 
(setq dist_f1 (distance ljg1_pt1 ljg2_pt1))
(setq dist_f2 (distance ljg1_pt2 ljg2_pt1))
(if (> dist_f1 dist_f2)(setq spoint ljg1_pt2)(setq spoint ljg1_pt1))
 
(setq dist_f3 (distance spoint ljg2_pt2))
(setq dist_f4 (distance spoint ljg2_pt1)) 

(if (< dist_f3 dist_f4)(setq epoint ljg2_pt1)(setq epoint ljg2_pt2)) 

(if (= spoint ljg1_pt2)(setq pvar 10)(setq pvar 11)) 

(vl-cmdf "_erase" ljg2_sel1 "") 
 
(setq ljg1_sel2
  (subst  (cons pvar epoint)
    (assoc 11 ljg1_sel2)       
    ljg1_sel2                 
))
(entmod ljg1_sel2)
  (princ)

(ljgvar2nil) 
)


;; ;;
;; Capture du type d'entité ;;
;; ;;
(defun ljg_type  ()
  (if (or(/= ljg_ent "LINE")(/= ljg_ent "LWPOLYLINE"))
    (alert (strcat "You have selected a " ljg_ent)))
  (setq ljg_ent nil)
  )

 
;; ;;
;; PLINE1 CHECK ;;
;; ;;
(defun ljg_expline1()
(if (= ljg_ent "LWPOLYLINE")
  (progn
    (vl-cmdf "_explode" ljg1_sel1 "")
    (setq ljg1_sel1 (entlast))
    (setq ljg1_sel2 (entget ljg1_sel1))
    )
(ljg_type))
)


;; ;;
;; PLINE2 CHECK ;;
;; ;;
(defun ljg_expline2()
(if (= ljg_ent "LWPOLYLINE")
  (progn
    (vl-cmdf "_explode" ljg2_sel1 "")
    (setq ljg2_sel1 (entlast))
    (setq ljg2_sel2 (entget ljg2_sel1))
    )
(ljg_type))
)

;; ;;
;; remet les variables ŕ NIL ;;
;; ;;
(defun ljgvar2nil()
(setq w nil)
  (setq ljg_ent nil
        ljg1_sel1 nil
ljg1_sel2 nil
ljg1_pt1 nil
ljg1_pt2 nil
ljg2_pt1 nil
ljg2_pt2 nil
dist_f1 nil
dist_f2 nil
dist_f3 nil
dist_f4 nil
spoint nil
epoint nil
pvar nil)
  )