cadfan Posted January 19, 2015 Posted January 19, 2015 I want select circle diameter of (2.5, 3.3 ,4.2 ,5.0 ,6.8 ,8.5 ,10.5 ,12.0 ,14.0 ,15.5, 17.5 ) ,but only select circle diameter of 5 why? (defun c:tt (/ ss dcl fn id klst) (defun _make (e / r pcen dis lst str xk mr cel p1 p2 p3 p4 cir ln1 ln2) (setq lst '((2.5 "M3" 0.06 1.5) (3.3 "M4" 0.08 1.5) (4.2 "M5" 0.1 2.5) (5.0 "M6" 0.12 3.0) (6.8 "M8" 0.16 4.0) (8.5 "M10" 0.2 5.0) (10.5 "M12" 0.24 6.0) (12.0 "M14" 0.28 7.0) (14.0 "M16" 0.32 8.0) (15.5 "M18" 0.36 9.0) (17.5 "M20" 0.4 10.0) ) ) (setq r (vlax-get e 'radius) pcen (vlax-get e 'center) ) (mapcar 'set '(str xk mr) (cdr (assoc r lst))) (setq cel (if (eq (setq lt (vlax-get e "linetype")) "ByLayer" ) (vlax-get (vla-item (fy:aclayers) (vlax-get e "layer")) "linetype" ) lt ) ) (setq dis (* r 1.1) p1 (polar pcen 0. dis) p2 (polar pcen _pi2 dis) p3 (polar pcen pi dis) p4 (polar pcen (- _pi2) dis) ) (if (member "isBlock" slst) (setq space (vla-add (fy:acblocks) (vlax-3d-point pcen) "*U")) (setq space (fy:acms)) ) (setq cir (vlax-invoke space 'addcircle pcen r) arc (vlax-invoke space 'addarc pcen mr 4.71239 3.14159) ln1 (vlax-invoke space 'addline p1 p3) ln2 (vlax-invoke space 'addline p2 p4) ) (mapcar '(lambda (x) (vlax-put (car x) 'layer "screw") (vlax-put (car x) 'color (cadr x)) (vlax-put (car x) "linetype" (caddr x)) (vlax-put (car x) "linetypescale" xk) ) (list (list cir 33 cel) (list arc 3 cel) (list ln1 1 "center") (list ln2 1 "center") ) ) (if (member "isText" slst) (progn (setq txt (vlax-invoke space 'AddText str pcen (* mr 0.4))) (vla-put-alignment txt acAlignmentTopCenter) (vla-put-textalignmentpoint txt (vlax-3d-point (polar pcen (- _pi2) (* mr 0.17))) ) ) ) (if (member "isBlock" slst) (vlax-invoke (fy:acspace) 'insertblock pcen (vla-get-name space) 1. 1. 1. 0. ) ) ) (if (not slst) (setq slst '("isErased" "isText" "isBlock")) ) (setq dcl '("screw:dialog{" "label = \"Parameter settings\";" " :toggle{ key = \"isErased\"; label = \"Delete original circle\";}" " :toggle { key = \"isText\"; label = \"Generate text\";}" " :toggle { key = \"isBlock\"; label = \"Generate block\";}" " ok_cancel;" "}" ) klst '("isErased" "isText" "isBlock") fn (xd::dcl:make dcl) id (xd::dcl:load fn "screw") ) (xd::Dcl:toggleaction klst 'slst nil ) (fy:begin) (if (and (= (xd::dcl:start id fn) 1 ) (setq ss (ssget '((0 . "circle") (-4 . "<or") (40 . 2.5) (40 . 3.3) (40 . 4.2) (40 . 5.0) (40 . 6. (40 . 8.5) (40 . 10.5) (40 . 12.0) (40 . 14.0) (40 . 15.5) (40 . 17.5) (-4 . "or>") ) ) ) ) (progn (if (not (tblsearch "style" "txt")) (command ".style" "txt" "txt.shx,gbcbig.shx" 0.0 1.0 0.0 "n" "n" "n" ) ) (if (not (tblsearch "ltype" "hidden")) (vla-load (fy:acltypes) "hidden" "acadiso.lin") ) (if (not (tblsearch "ltype" "center")) (vla-load (fy:acltypes) "center" "acadiso.lin") ) (if (not (tblsearch "layer" "screw")) (vla-add (fy:aclayers) "screw") ) (mapcar '(lambda (x) (_make x)) (fy:cset->objs)) (if (member "isErased" slst) (command ".erase" ss "") ) ) ) (princ) ) Quote
Tharwat Posted January 19, 2015 Posted January 19, 2015 I want select circle diameter of (2.5, 3.3 ,4.2 ,5.0 ,6.8 ,8.5 ,10.5 ,12.0 ,14.0 ,15.5, 17.5 ) ,but only select circle diameter of 5 why? Because the DXF 40 is representing radius value and not diameter , and the codes actually selecting the circle with 2.5 radius and not the one with diameter of 5.0 Have a look HERE Quote
cadfan Posted January 19, 2015 Author Posted January 19, 2015 Because the DXF 40 is representing radius value and not diameter , and the codes actually selecting the circle with 2.5 radius and not the one with diameter of 5.0 Have a look HERE Thank you ! Tharwat . you are rigth ! but diameter no DXF , How do I change? Quote
Tharwat Posted January 19, 2015 Posted January 19, 2015 (edited) Thank you ! Tharwat . you are rigth ! but diameter no DXF , How do I change? You're welcome. Divide the value on 2.0 Edited January 19, 2015 by Tharwat Quote
cadfan Posted January 19, 2015 Author Posted January 19, 2015 You're welcome. Multiply the value with 2.0 (setq R (dxf 40 dat) D (* R 2) ) (setq ss (ssget '((0 . "circle") (-4 . " (D . 2.5) (D . 3.3) (D . 4.2) .............. .............. (defun dxf (m dat) (cdr (assoc m dat))) but ,this is err. Mr.Tharwat ,Can you give a sample ? Thanks Quote
Tharwat Posted January 19, 2015 Posted January 19, 2015 I am sorry about my last reply , I should've said Divide and not Multiply . Try this . (ssget (append '((0 . "circle") (-4 . "<or")) (mapcar '(lambda (v) (cons 40 (/ v 2.))) '(2.5 3.3 4.2 5.0 6.8 8.5 10.5 12.0 14.0 15.5 17.5) ) '((-4 . "or>")) ) ) Quote
David Bethel Posted January 19, 2015 Posted January 19, 2015 [b][color=BLACK]([/color][/b]setq ss [b][color=FUCHSIA]([/color][/b]ssget [b][color=NAVY]([/color][/b]list [b][color=MAROON]([/color][/b]cons 0 [color=#2f4f4f]"CIRCLE"[/color][b][color=MAROON])[/color][/b] [b][color=MAROON]([/color][/b]cons -4 [color=#2f4f4f]"<OR"[/color][b][color=MAROON])[/color][/b] [b][color=MAROON]([/color][/b]cons 40 1.25[b][color=MAROON])[/color][/b] [b][color=MAROON]([/color][/b]cons 40 1.65[b][color=MAROON])[/color][/b] [b][color=MAROON]([/color][/b]cons 40 2.10[b][color=MAROON])[/color][/b] [b][color=MAROON]([/color][/b]cons -4 [color=#2f4f4f]"OR>"[/color][b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b][b][color=FUCHSIA])[/color][/b][b][color=BLACK])[/color][/b] Group 40 is the radius, not the diameter Also when the quote symbol is used, it prohibits all evaluation of code. -David Quote
BIGAL Posted January 20, 2015 Posted January 20, 2015 A slight variation (setq rad (vla-get-radius (vlax-ename->vla-object (car (entsel))))) Then lookup your Rad for match Quote
cadfan Posted January 20, 2015 Author Posted January 20, 2015 [b][color=BLACK]([/color][/b]setq ss [b][color=FUCHSIA]([/color][/b]ssget [b][color=NAVY]([/color][/b]list [b][color=MAROON]([/color][/b]cons 0 [color=#2f4f4f]"CIRCLE"[/color][b][color=MAROON])[/color][/b] [b][color=MAROON]([/color][/b]cons -4 [color=#2f4f4f]"<OR"[/color][b][color=MAROON])[/color][/b] [b][color=MAROON]([/color][/b]cons 40 1.25[b][color=MAROON])[/color][/b] [b][color=MAROON]([/color][/b]cons 40 1.65[b][color=MAROON])[/color][/b] [b][color=MAROON]([/color][/b]cons 40 2.10[b][color=MAROON])[/color][/b] [b][color=MAROON]([/color][/b]cons -4 [color=#2f4f4f]"OR>"[/color][b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b][b][color=FUCHSIA])[/color][/b][b][color=BLACK])[/color][/b] Group 40 is the radius, not the diameter Also when the quote symbol is used, it prohibits all evaluation of code. -David yes ,use radius is simple change . but why use "(list (cons " ? can't correspond with this code . (defun _make (e / r pcen dis lst str xk mr cel p1 p2 p3 p4 cir ln1 ln2) (setq lst '((1.25 "M3" 0.06 1.5) (1.65 "M4" 0.08 1.5) (2.10 "M5" 0.1 2.5) (2.50 "M6" 0.12 3.0) (3.40 "M8" 0.16 4.0) (4.25 "M10" 0.2 5.0) (5.25 "M12" 0.24 6.0) (6.00 "M14" 0.28 7.0) (7.00 "M16" 0.32 8.0) (7.75 "M18" 0.36 9.0) (8.75 "M20" 0.4 10.0) ) ) Quote
cadfan Posted January 20, 2015 Author Posted January 20, 2015 I am sorry about my last reply , I should've said Divide and not Multiply . Try this . (ssget (append '((0 . "circle") (-4 . "<or")) (mapcar '(lambda (v) (cons 40 (/ v 2.))) '(2.5 3.3 4.2 5.0 6.8 8.5 10.5 12.0 14.0 15.5 17.5) ) '((-4 . "or>")) ) ) Great ! Tharwat. it's nice. There is also a place must be modified This (defun _make (e / r pcen dis lst str xk mr cel p1 p2 p3 p4 cir ln1 ln2) (setq lst '((2.5 "M3" 0.06 1.5) (3.3 "M4" 0.08 1.5) (4.2 "M5" 0.1 2.5) (5.0 "M6" 0.12 3.0) (6.8 "M8" 0.16 4.0) (8.5 "M10" 0.2 5.0) (10.5 "M12" 0.24 6.0) (12.0 "M14" 0.28 7.0) (14.0 "M16" 0.32 8.0) (15.5 "M18" 0.36 9.0) (17.5 "M20" 0.4 10.0) ) ) change to this: (setq lst '((1.25 "M3" 0.06 1.5) (1.65 "M4" 0.08 1.5) (2.10 "M5" 0.1 2.5) (2.50 "M6" 0.12 3.0) (3.40 "M8" 0.16 4.0) (4.25 "M10" 0.2 5.0) (5.25 "M12" 0.24 6.0) (6.00 "M14" 0.28 7.0) (7.00 "M16" 0.32 8.0) (7.75 "M18" 0.36 9.0) (8.75 "M20" 0.4 10.0) ) ) if I want use DIAMETER too. How do I change? Quote
cadfan Posted January 20, 2015 Author Posted January 20, 2015 A slight variation (setq rad (vla-get-radius (vlax-ename->vla-object (car (entsel))))) Then lookup your Rad for match Thank for your idea. use "Rad " replace DXF 40 ? Quote
Tharwat Posted January 20, 2015 Posted January 20, 2015 Great ! Tharwat. it's nice. There is also a place must be modified If your lst variable is static , you can build the codes like . (setq lst '((2.5 "M3" 0.06 1.5) (3.3 "M4" 0.08 1.5) (4.2 "M5" 0.1 2.5) (5.0 "M6" 0.12 3.0) (6.8 "M8" 0.16 4.0) (8.5 "M10" 0.2 5.0) (10.5 "M12" 0.24 6.0) (12.0 "M14" 0.28 7.0) (14.0 "M16" 0.32 8.0) (15.5 "M18" 0.36 9.0) (17.5 "M20" 0.4 10.0) ) ) (ssget (append '((0 . "circle") (-4 . "<or")) (mapcar '(lambda (v) (cons 40 (/ v 2.))) (mapcar 'car lst) ) '((-4 . "or>")) ) ) Quote
BIGAL Posted January 20, 2015 Posted January 20, 2015 What I was suggesting is a different method and use a cond in lieu of creating LST and set the next 3 variables rad=2.5 "M3" 0.06 1.5 last test is say rad > 0.0 (alert "Size not found") Tharwat has provided as usual a solution that matches your method, often there are many ways to do the same task. Quote
cadfan Posted January 20, 2015 Author Posted January 20, 2015 Thank you ,Mr.Tharwat. I test ,but unsuccessful . It doesn't matter. I use radius. I have two questions. 1. I want change layer of center line, How do I change? (setq cir (vlax-invoke space 'addcircle pcen r) arc (vlax-invoke space 'addarc pcen mr 4.71239 3.14159) [color="#ff00ff"] ln1 (vlax-invoke space 'addline p1 p3) ln2 (vlax-invoke space 'addline p2 p4)[/color] ) (mapcar '(lambda (x) (vlax-put (car x) 'layer "screw") (vlax-put (car x) 'color (cadr x)) (vlax-put (car x) "linetype" (caddr x)) (vlax-put (car x) "linetypescale" xk) ) (list (list cir 33 cel) (list arc 3 cel) [color="#ff00ff"] (list ln1 1 "center") (list ln2 1 "center")[/color] ) ) 2 . Wait a moment Quote
Tharwat Posted January 20, 2015 Posted January 20, 2015 Thank you ,Mr.Tharwat.I test ,but unsuccessful . It doesn't matter. I use radius. No, what I have posted earlier should work and I don't know how you run the codes . 1. I want change layer of center line, How do I change? (setq cir (vlax-invoke space 'addcircle pcen r) arc (vlax-invoke space 'addarc pcen mr 4.71239 3.14159) [color="#ff00ff"] ln1 (vlax-invoke space 'addline p1 p3) ln2 (vlax-invoke space 'addline p2 p4)[/color] ) I guess you have two lines , so how could be center line ? Quote
cadfan Posted January 20, 2015 Author Posted January 20, 2015 I guess you have two lines , so how could be center line ? Yes, I mean this two lines is center line. Hello Mr.Tharwat Question 2. If I select the circle linetype is "Continuous", SO change the circle Lineweight to 0.35 (setq [color="red"]cir (vlax-invoke space 'addcircle pcen r)[/color] arc (vlax-invoke space 'addarc pcen mr 4.71239 3.14159) ln1 (vlax-invoke space 'addline p1 p3) ln2 (vlax-invoke space 'addline p2 p4) ) (mapcar '(lambda (x) (vlax-put (car x) 'layer "screw") (vlax-put (car x) 'color (cadr x)) (vlax-put (car x) "linetype" (caddr x)) (vlax-put (car x) "linetypescale" xk) ) (list[color="red"] (list cir 33 cel)[/color] (list arc 3 cel) (list ln1 1 "center") (list ln2 1 "center") ) ) Quote
Tharwat Posted January 20, 2015 Posted January 20, 2015 (edited) Maybe ... try it. (mapcar '(lambda (x) (vlax-put (car x) 'layer "screw") (vlax-put (car x) 'color (cadr x)) (vlax-put (car x) "linetype" (caddr x)) (vlax-put (car x) "linetypescale" xk) (if (and (eq (vla-get-objectname (car x)) "AcDbCircle") (eq (vla-get-linetype (car x)) "Continuous") ) (vla-put-lineweight (car x) acLnWt035) ) ) (..................... Edited January 20, 2015 by Tharwat Quote
cadfan Posted January 20, 2015 Author Posted January 20, 2015 Maybe ... try it. Mr.Tharwat. You are too professional.very well. In addition, How to change the layer ? I want change the layer of centre line to "centreline",change the layer of text to "annotation" Quote
Tharwat Posted January 20, 2015 Posted January 20, 2015 There was a simple typo and I did correct it , have a look again to my last reply . Mr.Tharwat. You are too professional.very well. Thank you If you use the entmake function with their Entities DXF codes HERE , that would be much more better and faster in your case to obtain all kinds of properties . Quote
cadfan Posted January 20, 2015 Author Posted January 20, 2015 There was a simple typo and I did correct it , have a look again to my last reply . Thank you If you use the entmake function with their Entities DXF codes HERE , that would be much more better and faster in your case to obtain all kinds of properties . Thank you ,Mr.Tharwat. I know entmake, (entmake (list (cons 0 "LINE") (cons 8 "screw");;layer (CONS 62 1);; colour (cons 6 "CENTER");;linetype (cons 48 xk) ;;linescale (cons 10 pt2);; frist point (cons 11 pt4);;second point ) ) (entmake (list (cons 0 "TEXT") (cons 8 "screw") (CONS 62 6) (cons 10 textpt) (cons 40 texth) (cons 1 text) (cons 7 "TXT") (cons 41 1) (cons 51 0.0) (cons 71 0) (cons 72 0) (cons 73 0) (list 210 0.0 0.0 1.0) ) ) But ,I don't know ,how change layer of the line for this lisp: (mapcar '(lambda (x) (vlax-put (car x) 'layer "screw") (vlax-put (car x) 'color (cadr x)) (vlax-put (car x) "linetype" (caddr x)) (vlax-put (car x) "linetypescale" xk) (if (and (eq (vla-get-objectname (car x)) "AcDbCircle") (eq (vla-get-linetype (car x)) "Continuous") ) (vla-put-lineweight cir acLnWt035) ) ) (list (list cir 33 cel) (list arc 3 cel) [color="#ff00ff"] (list ln1 1 "center") (list ln2 1 "center")[/color] ) ) and how change the layer of text ? (if (member "isText" slst) (progn (setq txt (vlax-invoke space 'AddText str pcen (* mr 0.4))) (vla-put-alignment txt acAlignmentTopCenter) (vla-put-textalignmentpoint txt (vlax-3d-point (polar pcen (- _pi2) (* mr 0.17))) ) ) ) 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.