Ogopogo Posted September 28, 2023 Author Share Posted September 28, 2023 Hi Fuccaro, No worries as you must be busy with other requests. Your lisp works great, very much appreciated. I do have another quest, base on the same block and line. Is it possible, to click two end points and insert the length in the block? I do apologizes, I should have asked this also at the beginning. Quote Link to comment Share on other sites More sharing options...
fuccaro Posted September 28, 2023 Share Posted September 28, 2023 That should not cause too many headaches: (defun c:pp1( / bent sel enttype attr dist) (setq bent (car (entsel "select block"))) (cond ((= (cdr (assoc 2 (entget bent))) "Wall-Tag-FW") (while (/= (cdr (assoc 2 (entget bent))) "LENGTH-FT") (setq bent (entnext bent))) (initget "Clicks") (setq sel (entsel "\nSelect (p)line or [Clicks]") enttype (if (listp sel) (cdr (assoc 0 (setq line (entget (car sel))))))) (cond ((= enttype "LINE") (setq dist (distance (cdr (assoc 10 line)) (cdr (assoc 11 line))))) ((= enttype "LWPOLYLINE") (setq dist (extract sel))) ((= sel "Clicks") (setq dist (distance (setq p1 (getpoint "\n1st point")) (getpoint p1 " 2nd point")))) ) (setq attr (entget bent) attr (subst (cons 1 (rtos dist)) (assoc 1 attr) attr) attr (entmod attr))) (T (princ "Wrong block!!!" )) ) (princ) ) (defun extract(sel / p0 p1 p2 el found dist) (setq p0 (osnap (cadr sel) "_nea") el (entget (car sel)) el (if (= 1 (cdr (assoc 70 el))) (append el (list (assoc 10 el))) el) p1 nil p2 nil i -1 found nil) (while (and (not found) (< (setq i (1+ i)) (length el))) (cond ((= (car (nth i el)) 10) (setq p1 p2 p2 (cdr (nth i el))))) (setq found (and p1 (equal (setq dist (distance p1 p2)) (+ (distance p1 p0)(distance p0 p2)) 1e-5))) ) (if found dist nil) ) When the program prompts you to select the (p)line to get the length from, press C -meaning you wish to enter the length by clicks- and... there you are! Use the Osnap to click End points, or Mid points or just click around in the model space at your heart's desire. Quote Link to comment Share on other sites More sharing options...
Ogopogo Posted September 29, 2023 Author Share Posted September 29, 2023 Hi Fuccaro, Thank you so much for creating these codes for me, it works marvellously. Having all my requests all in one file. Thank you for your time and your knowledge. 1 Quote Link to comment Share on other sites More sharing options...
fuccaro Posted September 29, 2023 Share Posted September 29, 2023 Glad to help, Ogopogo! That's why we are here: to share ideas and to help each others. Have a nice day! 1 Quote Link to comment Share on other sites More sharing options...
Ogopogo Posted October 4, 2023 Author Share Posted October 4, 2023 Hi Fuccaro, I have another request but for a circle. When you click on the inner circle it will insert the inside diameter and inside circumference both in feet-decimal into the "Wall-Rnd-Arc-Tag" block. Same for the outer circle, outside diameter and outside circumference in feet-decimal. I have attached a Jpeg and Autocad files. For the line / Pline request, it possible to insert the line length as a Feet-decimal? Thank you. 2 Circles.dwg Quote Link to comment Share on other sites More sharing options...
fuccaro Posted October 4, 2023 Share Posted October 4, 2023 I am familiar with metric units only. The lengths should be returned according to your local settings. So, how do you see now the text in the block attribute? it should be possible to make some calculations... I think Quote Link to comment Share on other sites More sharing options...
Ogopogo Posted October 5, 2023 Author Share Posted October 5, 2023 Hi Fuccaro, You can ignore my request regarding feet-decimal. I look forward for your lisp codes. Thank you. Quote Link to comment Share on other sites More sharing options...
fuccaro Posted October 5, 2023 Share Posted October 5, 2023 My try: (defun c:pp() (princ "\nCircles: ") (setq c2 (ssget)) (setq r (mapcar '(lambda(x) (* 2 (cdr (assoc 40 (entget (ssname c2 x)))))) '(0 1))) (setq b (car (entsel "\nSelect block"))) (while b (setq blist (entget b)) (setq name (cdr (assoc 2 blist))) (cond ((= name "I.D.-FT") (putAttr blist (apply 'min r))) ((= name "I.C.-FT") (putAttr blist (* pi (apply 'min r)))) ((= name "O.D.-FT") (putAttr blist (apply 'max r))) ((= name "O.C.-FT") (putAttr blist (* pi (apply 'max r)))) ) (setq b (entnext b)) ) ) (defun putAttr(att val) (entmod (subst (cons 1 (rtos val))(assoc 1 att) att)) ) Quote Link to comment Share on other sites More sharing options...
BIGAL Posted October 6, 2023 Share Posted October 6, 2023 fuccaro I work metric but its easy for feet and inches etc depending on the second value is what is displayed in feet and inches eg 4 2. 1 Quote Link to comment Share on other sites More sharing options...
Ogopogo Posted October 6, 2023 Author Share Posted October 6, 2023 Hi Fuccaro, You're amazing! It works! Thank you very much for helping me on my request. Fuccaro & Bigal Regarding the Feet-Decimal, I have attached 2 screens shots. The first screenshot is setting up the units in Primary and Alternate Units. In the Primary Unit: selected "Decimal", selected "0.000", selected "Period", typed in "apostrophe ( ' )" in the suffix and enter "1/12" in the scale factor. In the Alternate Unit: selected "Architectural", precision "1/32" and multiplier "12". The second screenshot shows both primary and alternate dimension. The first dimension is the "Feet-Decimal", the one I was asking about and wondering it is possible insert into the block. Quote Link to comment Share on other sites More sharing options...
fuccaro Posted October 6, 2023 Share Posted October 6, 2023 Returning to the last lisp: there is no input check. It works fine if it is used right. At the first prompt select *exactly* two circles and at the second prompt give a block that has the desired attributes. It will put the desired texts in the block attributes . To change the units and/or the format - that will be your pleasure. Quote Link to comment Share on other sites More sharing options...
Ogopogo Posted October 6, 2023 Author Share Posted October 6, 2023 Thank you Fuccaro! I will change the units to what I want to indicate on the block. Quote Link to comment Share on other sites More sharing options...
fuccaro Posted October 6, 2023 Share Posted October 6, 2023 On 9/29/2023 at 7:35 AM, fuccaro said: Glad to help, Ogopogo! ... Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.