Hi guys,
I've seen variations of pline join, but I need one that join lines/plines/arcs only if they are on the same layer. Thanks in advance. If you want to use this one by Lee Mac as an example and just add the entities on the same layer portion, I'd much appreciate it. 🙂
(defun c:pj ( / pe ss )
(setq pe (getvar 'PEDITACCEPT))
(setvar 'PEDITACCEPT 1)
(if (setq ss (ssget "_:L" '((0 . "ARC,LINE,LWPOLYLINE"))))
(command "_.pedit" "_M" ss "" "_J" "" "")
)
(setvar 'PEDITACCEPT pe)
(princ)
)
Solved! Go to Solution.
Solved by Lee_Mac. Go to Solution.
Something like this, perhaps
(defun c:pj ( / pe s ss ) (setq pe (getvar 'PEDITACCEPT)) (setvar 'PEDITACCEPT 1) (princ "\nPick one object to join: ") (if (and (setq s (ssget "_+.:E:S:L" '((0 . "ARC,LINE,LWPOLYLINE")))) (princ "\nSelect the remaining objects to join: ") (setq ss (ssget (list '(0 . "ARC,LINE,LWPOLYLINE") (assoc 8 (entget (ssname s 0)))))) ) (command "_.pedit" "_M" ss "" "_J" "" "") ) (setvar 'PEDITACCEPT pe) (princ) )
HTH
Henrique
Henrique beat me to it.. here's an alternate..
(defun c:pj ( / pe ss n indss cssname sslist) (setq pe (getvar 'PEDITACCEPT) n 1);setq (setvar 'PEDITACCEPT 1) (if (setq ss (ssget "_:L" '((0 . "ARC,LINE,LWPOLYLINE")))) (progn (while (> (sslength ss) 0) (setq clay (cdr (assoc 8 (entget (ssname ss 0))))) (setq cssname (strcat "ss-" clay)) (if (not (eval (read cssname))) (set (read cssname) (ssadd)) );if (ssadd (ssname ss 0) (eval (read cssname))) (ssdel (ssname ss 0) ss) (if (not (member cssname sslist)) (setq sslist (cons cssname sslist)) );if );while (foreach indss sslist (command "_.pedit" "_M" (eval (read indss)) "" "_J" "" "") (set (read indss) nil) );foreach );progn ) (setvar 'PEDITACCEPT pe) (princ) )
Another perhaps:
(defun c:pjl ( / ent idx itm lay lst sel val var ) (setq var '(peditaccept cmdecho) val (mapcar 'getvar var) ) (mapcar '(lambda ( a b c ) (if a (setvar b c))) val var '(1 0)) (if (setq sel (ssget "_:L" '((0 . "ARC,LINE,LWPOLYLINE")))) (progn (repeat (setq idx (sslength sel)) (setq ent (ssname sel (setq idx (1- idx))) lay (cdr (assoc 8 (entget ent))) ) (if (setq itm (assoc lay lst)) (setq lst (subst (vl-list* lay ent (cdr itm)) itm lst)) (setq lst (cons (list lay ent) lst)) ) ) (foreach grp lst (apply 'command (append '("_.pedit" "_m") (cdr grp) '("" "_j" "" ""))) ) ) ) (mapcar '(lambda ( a b ) (if b (setvar a b))) var val) (princ) )
Thanks for getting back to me so quickly guys. First of all, Henrique - your routine requires me to choose one entity and one layer at a time. But I appreciate the effort. Shneuph's routine does address what I need, and that is to work with all entities on all layers, joining only lines that are on the same layer - so perfect. Lee's routine does what it's supposed to (and as always - look great), however, I could use a typical feed back that tells you how many lines were added resulting in however polylines or whether it added 0 polylines because it was done - the way the original routine displayed. All in all, great job everyone! I love all your efforts! 🙂
Feedback on Lee's routine: I tried it on busy drawing and got an alert that keeps popping up even though I clicked yes (5-6 times) until I clicked 'no' on the drawing order, before it will start executing the routine. This was a busy drawing, so not sure what the difference is..Lee? Thanks.
Lee-
I like the way you save variables and thier values to lists:
(setq var '(peditaccept cmdecho) val (mapcar 'getvar var))
and then reset them at the end:
(mapcar '(lambda ( a b ) (if b (setvar a b))) var val)
but does the routine ever change these vars?
EDIT:
oh I see...
(mapcar '(lambda ( a b c ) (if a (setvar b c))) val var '(1 0))
got it.
@kameron1967 wrote:
... Henrique - your routine requires me to choose one entity and one layer at a time. ...
Sorry Kameron,
I understood (diagonal reading) that your goal was to pedit in one layer only...
@Lee_Mac and @Shneuph nice codes.
Henrique
Lee's routine does what it's supposed to (and as always - look great), however, I could use a typical feed back that tells you how many lines were added resulting in however polylines or whether it added 0 polylines because it was done - the way the original routine displayed.
Thank you kameron -
I suppressed the command echo for the PEDIT command by setting the CMDECHO system variable to zero in the program - you can enable this command-line output by changing this '(1 0) to '(1 1).
Feedback on Lee's routine: I tried it on busy drawing and got an alert that keeps popping up even though I clicked yes (5-6 times) until I clicked 'no' on the drawing order, before it will start executing the routine. This was a busy drawing, so not sure what the difference is..Lee? Thanks.
The alert requesting whether to disregard draw-order for processor-intensive operations is standard AutoCAD behaviour when the number of entities exceeds a certain limit - you are receiving this alert multiple times because my program is calling the PEDIT command multiple times (once for each layer).
You can disable the alert by setting the DRAWORDERCTL system variable to 0.
Lee-
I like the way you save variables and thier values to lists:
(setq var '(peditaccept cmdecho) val (mapcar 'getvar var))
and then reset them at the end:
(mapcar '(lambda ( a b ) (if b (setvar a b))) var val)
but does the routine ever change these vars?
EDIT:
oh I see...
(mapcar '(lambda ( a b c ) (if a (setvar b c))) val var '(1 0))
got it.
Thank you both for the compliments!
Thanks for your work.
In my nooby understanding the I am trying to tackle is slightly different to your solution provided, in the sense that entities may consist of arcs, lines etc and do not snap to adjacent endpoints. I have tried in vain:
(apply 'command (append '("_.pedit" "_m") (cdr grp) '("" "_j" "0.05" "")))
Could you kindly pinpoint me into the direction how to alter your initial solution in order to snap endpoints before/while joining?
Kind regards
Sebastian
The 1st suggestion is a defun F0 which is for fillet with a zero radius. Auto load it on start up.
(defun c:f0 () (setvar 'filletrad 0.0)(command "fillet"))
For multiple press enter or space bar will pop it up again.
Gap is it a pline or lines ? Makes a difference for the selection method.
Internal corner need some rules like pick 1st controls the square off start point. Yes No ?
@Peter_MElad wrote:
for the left shape is there any way to do it
Same question as in the longer paragraph >here<.
In addition, what if the two white pieces are not orthogonal? Should the connector be horizontal in any case [or vertical if that's closer], or perpendicular to them? What if they're not parallel? Etc., etc., etc.
only parallel connect as you made to achieve (be as far as possible from the lines) ........ if not parallel connect with two points only. and finally close polyline (close Area)
I don't have the ability to make lisp
Can't find what you're looking for? Ask the community or share your knowledge.