Well, thank you everyone for your advice & tips. I really appreciate it.
I'm sorry to say, I'm a bit lost with the code MP and CAB have posted, but I can chew on it for a while.
Welcome Sepperl and thank you for your advice and comments.
Well, ... I'd have to say I understand Vivek's code the best but I intend to try them all as I can learn from them so thanks again.
I have two routines I'm trying to fix. One is a line join command. I don't know who wrote it, but I'm trying to add the option of joining pline & line, pline & pline, or line & line automatically. So the user will not have to know if the line(s) are pline or not, just simply pick the lines.
;Join.LSP: Joins two broken colinear lines.
;
;__________________________________________________________________________
(defun c:join (/ a b ai va vb dst1 dst2 a1 b1 a2 b2 ent1 ent2
end1 end2 dst3 dst4 oldlst newlst)
(defun mid (w z)
(LIST (/ (+ (CAR w) (CAR z))2) (/ (+ (CADR w) (CADR z))2))
)
(setvar "cmdecho" 0)
(setq a (cadr (entsel "\nSelect two lines to be joined: ")))
(command ".select" a)
(while (= a nil)
(setq a (cadr (entsel "\nPlease Select two lines to be joined: ")))
(command ".select" a)
)
(setq b (cadr (entsel)))
(while (= b nil)
(setq b (cadr (entsel)))
)
(command "")
(setq ai (mid a b))
(setq va (ssget a))
(setq vb (ssget b))
(setq a1 (cdr (assoc 10 (entget (setq ent1 (ssname va 0))))))
(setq b1 (cdr (assoc 11 (entget (ssname va 0)))))
(setq a2 (cdr (assoc 10 (entget (setq ent2 (ssname vb 0))))))
(setq b2 (cdr (assoc 11 (entget (ssname vb 0)))))
(setq dst1 (distance ai a1))
(setq dst2 (distance ai b1))
(if (< dst1 dst2)(setq end1 b1)(setq end1 a1))
(setq dst3 (distance ai a2))
(setq dst4 (distance ai b2))
(if (< dst3 dst4)(setq end2 b2)(setq end2 a2))
(setq oldlst (entget ent1))
(setq newlst (subst (cons 10 end1)(assoc 10 oldlst) oldlst))
(setq newlst (subst (cons 11 end2)(assoc 11 newlst) newlst))
(entdel ent2)
(entdel ent1)
(entmake (cdr newlst))
(princ)
)
So, I'm assuming I'd throw in Vivek's code to something like ...
alright, I've got to go play with this stuff, I'm not as efficient as you guys. It takes me a while to get my two brain cells communicating to get something worked out. :ugly:
I'll be back with a probable solution ... maybe.
Oh yeah, the other routine.
this routine is to fillet reinforcing. The fillets are set, and I actually have the code so you can choose the line, if the line is a pline, it won't select, so you hit enter, then select the pline to fillet.
I need to add some filter in so the user can select either line or pline and it will automatically recognize the entity and run the routine. Much like the line join command posted above.
(defun c:frt (/ defbar_size fillet_rad ssreinf ss1 ss2 ss3)
(setvar "cmdecho" 1)
(if (/= bar_size "")
(setq defbar_size bar_size))
(if (= defbar_size nil)
(setq defbar_size 5.0))
;
(setq bar_size (getreal (strcat "\nEnter Bar size <3 to 18> <#" (rtos defbar_size 2 0) ">: ")))
(or bar_size (setq bar_size defbar_size))
(progn
(cond ( (= bar_size 3)
(setq fillet_rad 1.125))
( (= bar_size 4)
(setq fillet_rad 1.5))
( (= bar_size 5)
(setq fillet_rad 1.875))
( (= bar_size 6)
(setq fillet_rad 2.25))
( (= bar_size 7)
(setq fillet_rad 2.625))
( (= bar_size 8)
(setq fillet_rad 3.0))
( (= bar_size 9)
(setq fillet_rad 4.75))
( (= bar_size 10)
(setq fillet_rad 5.375))
( (and (>= bar_size 11)
(< bar_size 14))
(setq fillet_rad 6.0))
( (and (>= bar_size 14)
(< bar_size 18))
(setq fillet_rad 9.125))
(T;(>= bar_size 18
(setq fillet_rad 12.0))))
(setvar "filletrad" fillet_rad)
(setq ssreinf (ssget '((0 . "LINE"))))
(if (/= ssreinf nil)
(progn
(setq ss1 (ssname ssreinf 0))
(setq ss2 (ssname ssreinf 1))
(command ".fillet" ss1 ss2)
(setq ss3 (ssget "L"))
(command ".pedit" ss1 "j" ss1 ss2 ss3 "" "x")))
(if (= ssreinf nil)
(command ".fillet" pause pause))
(setvar "filletrad" 0.0)
(princ)
)
If you so choose to input some piece of code as to help these routines along, by all means, please do so.
Thanks.