Ashishs Posted July 16, 2018 Posted July 16, 2018 Hi, I have several drawings with thousands of individual circles (not blocks) of same radius. All of them I am supposed to change to the equilateral triangle of base & sides length = 10mm. Is it possible to write a program to do this automatically? Thanks in advance. Quote
MastroLube Posted July 16, 2018 Posted July 16, 2018 Hi there, I'm not good as other guys but this is a simple task in my opinion I'll do it in this way: 1. SSGET every circle and extract center point http://www.lee-mac.com/ssget.html http://www.lee-mac.com/selsetprocessing.html 2. delete all of them and with a while insert a block with that insert point for every center point http://www.lee-mac.com/selsetprocessing.html Quote
Ashishs Posted July 16, 2018 Author Posted July 16, 2018 Thanks MastroLube. Can someone write all code together. I am not very familiar with lisp programming. Hi there, I'm not good as other guys but this is a simple task in my opinion I'll do it in this way: 1. SSGET every circle and extract center point http://www.lee-mac.com/ssget.html http://www.lee-mac.com/selsetprocessing.html 2. delete all of them and with a while insert a block with that insert point for every center point http://www.lee-mac.com/selsetprocessing.html Quote
MastroLube Posted July 16, 2018 Posted July 16, 2018 can you send the example dwg please with even that triangle you want to put inside? Quote
Lee Mac Posted July 16, 2018 Posted July 16, 2018 Try the following: ([color=BLUE]defun[/color] c:cir2tri ( [color=BLUE]/[/color] e i l p s v x z ) ([color=BLUE]initget[/color] 6) ([color=BLUE]setq[/color] l ([color=BLUE]cond[/color] (([color=BLUE]getdist[/color] [color=MAROON]"\nSpecify triangle side length <10>: "[/color])) (10.0)) l ([color=BLUE]list[/color] ([color=BLUE]list[/color] 0.0 ([color=BLUE]/[/color] l ([color=BLUE]sqrt[/color] 3))) ([color=BLUE]list[/color] ([color=BLUE]/[/color] l 2.0) ([color=BLUE]/[/color] l ([color=BLUE]sqrt[/color] 3) -2.0)) ([color=BLUE]list[/color] ([color=BLUE]/[/color] l -2.0) ([color=BLUE]/[/color] l ([color=BLUE]sqrt[/color] 3) -2.0))) ) ([color=BLUE]if[/color] ([color=BLUE]setq[/color] s ([color=BLUE]ssget[/color] [color=MAROON]"_:L"[/color] '((0 . [color=MAROON]"CIRCLE"[/color])))) ([color=BLUE]repeat[/color] ([color=BLUE]setq[/color] i ([color=BLUE]sslength[/color] s)) ([color=BLUE]setq[/color] i ([color=BLUE]1-[/color] i) e ([color=BLUE]ssname[/color] s i) x ([color=BLUE]entget[/color] e) p ([color=BLUE]cdr[/color] ([color=BLUE]assoc[/color] 010 x)) z ([color=BLUE]cdr[/color] ([color=BLUE]assoc[/color] 210 x)) ) ([color=BLUE]if[/color] ([color=BLUE]entmake[/color] ([color=BLUE]append[/color] '( (000 . [color=MAROON]"LWPOLYLINE"[/color]) (100 . [color=MAROON]"AcDbEntity"[/color]) (100 . [color=MAROON]"AcDbPolyline"[/color]) (090 . 3) (070 . 1) ) (LM:defaultprops x) ([color=BLUE]list[/color] ([color=BLUE]cons[/color] 038 ([color=BLUE]caddr[/color] p))) ([color=BLUE]mapcar[/color] '([color=BLUE]lambda[/color] ( v ) ([color=BLUE]cons[/color] 10 ([color=BLUE]mapcar[/color] '[color=BLUE]+[/color] p ([color=BLUE]trans[/color] v 1 z [color=BLUE]t[/color])))) l) ([color=BLUE]list[/color] ([color=BLUE]cons[/color] 210 z)) ) ) ([color=BLUE]entdel[/color] e) ) ) ) ([color=BLUE]princ[/color]) ) [color=GREEN];; Default Properties - Lee Mac[/color] [color=GREEN];; Returns a list of DXF properties for the supplied DXF data,[/color] [color=GREEN];; substituting default values for absent DXF groups[/color] ([color=BLUE]defun[/color] LM:defaultprops ( enx ) ([color=BLUE]mapcar[/color] '([color=BLUE]lambda[/color] ( x ) ([color=BLUE]cond[/color] (([color=BLUE]assoc[/color] ([color=BLUE]car[/color] x) enx)) ( x ))) '( (006 . [color=MAROON]"BYLAYER"[/color]) (008 . [color=MAROON]"0"[/color]) (039 . 0.0) (048 . 1.0) (062 . 256) (370 . -1) ) ) ) ([color=BLUE]princ[/color]) The above should match all properties of the source object and construct the equilateral triangle with rotation relative to the current UCS. Quote
Ashishs Posted July 19, 2018 Author Posted July 19, 2018 Thanks a lot Lee Mac. This was exactly what I was looking for. Is it possible to select circles of specific radius, because I have circles of mixed radius in my drawings. I am attaching a drawing which has circles of various radius in attached example- Download link - https://we.tl/qlOgeBhgQE Quote
BIGAL Posted July 19, 2018 Posted July 19, 2018 If you pick circle for radius, then subtle change to lee's code. (setq rad (cdr (assoc 40 (entget (car (entsel "Pick circle" )))))) (setq l (* (/ rad (sin (/ pi 6.0))) (sin (* pi (/ 2.0 3.0)))) ; all this is in radians l (list (list 0.0 (/ l (sqrt 3))) (list (/ l 2.0) (/ l (sqrt 3) -2.0)) (list (/ l -2.0) (/ l (sqrt 3) -2.0))) ) (if (setq s (ssget "_:L" (list (cons 0 "CIRCLE")(cons 40 rad)))) I am sure there is some exact length formula will look up my survey book. A/sin A = B/sin B where B = rad fixed above Quote
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.