Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations IDS on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Joining Lines 3

Status
Not open for further replies.

CadDraftee

Mechanical
Sep 16, 2003
48
Ok - We can break lines and put gaps in them but can we join them back together as one line - not using plines just normal basic acad lines??
 
Replies continue below

Recommended for you

I got this lsp file from someone at work.


(defun C:LH ()
(setq N 0
S (ssget)
E1 (entget (ssname S 0)))
(if (= "LINE" (cdr (assoc 0 E1)))
(progn
(setq G1 (cdr (assoc -1 E1))
P11 (cdr (assoc 10 E1))
P12 (cdr (assoc 11 E1)))
(setq N (+ 1 N))))
(setq E2 (entget (ssname S 1)))
(if (= "LINE" (cdr (assoc 0 E2)))
(progn
(setq G2 (cdr (assoc -1 E2))
P21 (cdr (assoc 10 E2))
P22 (cdr (assoc 11 E2)))
(setq N (+ 1 N))))
(if (> (distance P11 P21)(distance P11 P22))
(setq PR1 P21)
(setq PR1 P22))
(if (> (distance P21 P11)(distance P21 P12))
(setq PR2 P11)
(setq PR2 P12))
(if (= N 2)
(progn
(entdel G1)
(setq E2 (subst (cons 10 PR1)(cons 10 P21) E2))
(setq E2 (subst (cons 11 PR2)(cons 11 P22) E2))
(entmod E2)))
)


[gorgeous]
 
Dear CadDraftee,
The following simple code will create a new line on two broken lines. Keep in mind, the sequence of selecting two lines is important and also you should select only line objects.

(defun c:ll(/ e1 e2 e)
(setq e1 (entget (car (entsel "First line: "))))
(setq e2 (entget (car (entsel "Second line: "))))
(setq e (list '(0 . "line") (assoc 10 e1) (assoc 11 e2)))
(entmake e)
(princ)
)


:)
Farzad
 
Hi,

use „heilen.lsp“ (To cure) from -> Hilfe-> download-> Prog 2
You can join lines/lines, polylines/lines and pl/pl if they in straight line.

Lothar
 
That was a great link Exxit. There are several variations of the join/heal routine for joining colinear lines, but that is the first time I have used one that joins a line to a polyline.

Flores
 
Thnaks heapd everyone - last one was brilliant has anyone got and english version of it?
 
This is a little off topic, but:

Here is a LISP routine that makes a bunch of lines into a polyline. The lines have to be drawn end-to-end. Works with arcs, etc.

(DEFUN C:pJ () (COMMAND "PEDIT" PAUSE "Y" "J" "BOX" PAUSE PAUSE "" "X") (PRINC)) ; Make a line a polyline & join selected lines

Pick one line of the group, then use a crossing box to pick anything you want joined to it.

Here's another that does the same thing but then closes the polyline. Like, you draw 3 sides of a box and then use this to make them a polyline and by closing it, the last side is drawn for you.

(DEFUN C:pJC () (COMMAND "PEDIT" PAUSE "Y" "J" "BOX" PAUSE PAUSE "" "C" "X") (PRINC)) ; Make a line a polyline, join selected lines, close it
 
IFRs
I tried you PJ.lsp, but something is missing.
When I try to use it, acad puses right after I enter PJ without giving me the option to pick the first line, and then I get

*Invalid selection*
Expects a point or Window/Last/Crossing/BOX/ALL/Fence/WPolygon/CPolygon/Multiple
; error: Function cancelled


any idea?

[gorgeous]
 
anka -

This is because your CMDECHO is set to 0 instesd of 1. My routine is badly written in that the prompts don't show up unless the CMDECHO is set to 1. You can either:

Change the CMDECHO by typing CMDECHO and them 1 or

Know that PJ wants a single line to be picked and theb a crossing box window. Just pick a line. Don't wait for a prompt. It should be a line, not a polyline. Then click the mouse two more times to pick lots of lines using a crossing box.

PJ
[pick a line]
[use a crossing box to pick a bunch of lines]
 
Thank you IFRs, now it works fine.
I was using that chain of commands before, but now, when it is a single command, it is much quicker.
Hopefully I can now start writing my own lisps after seeing your short example.

Does changing the CMDECHO variable to 1 affect other acad functions? would I be seeing other changes in daily work?

[gorgeous]
 
Changing CMDECHO will affect all other lisp programs. Good programs are written to save the state of all system variables it changes and return them to their previous states when they end (including osnaps, etc). I apologize for writing and distributing poor code and making improper suggestions.

Here is a better lisp routine:

(DEFUN C:pJ (/ ce) ; Make a line a polyline & join selected lines
(setq ce (getvar "CMDECHO"))
(setvar "CMDECHO" 0)
(COMMAND "PEDIT" PAUSE "Y" "J" "BOX" PAUSE PAUSE "" "X")
(setvar "CMDECHO" ce)
(PRINC)
)

Note: the (/ ce) defines the variable ce as a "local" one that will not remain in memory when the program terminates. This is also a good idea. If you need to define and change a variable that the next program needs or you want to determine the valur of at the command line, don't include it inside the parenthisis, and it will be a "global" one. For example, if you did not put ce inside, you could type !ce on the command line and see the value stored. This is a good idea when you are debugging a lisp routine and want to test a variable's value.
 
Thank you again IFRs

I'm learning alot from your posts.

[gorgeous]
 
Thanks Exxit!

Can anyone translate 'heilen.lsp' to English?? I need this same routine, but I need it to keep Polyline widths.


-Chane
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor