Joining Lines
Joining Lines
(OP)
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??
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS Come Join Us!Are you an
Engineering professional? Join Eng-Tips Forums!
*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail. Posting GuidelinesJobs |
|
RE: Joining Lines
(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)))
)
RE: Joining Lines
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
RE: Joining Lines
use „heilen.lsp“ (To cure) from www.defun.de -> Hilfe-> download-> Prog 2
You can join lines/lines, polylines/lines and pl/pl if they in straight line.
Lothar
RE: Joining Lines
Flores
RE: Joining Lines
RE: Joining Lines
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
RE: Joining Lines
RE: Joining Lines
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?
RE: Joining Lines
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]
RE: Joining Lines
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?
RE: Joining Lines
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.
RE: Joining Lines
I'm learning alot from your posts.
RE: Joining Lines
Can anyone translate 'heilen.lsp' to English?? I need this same routine, but I need it to keep Polyline widths.
-Chane