wimal Posted May 14, 2018 Share Posted May 14, 2018 (setq xss2 (ssget"C"pt1 pt2 '((0 . "INSERT") ))) In my blocks there is a circle.How can I find out the radius of that Quote Link to comment Share on other sites More sharing options...
dlanorh Posted May 14, 2018 Share Posted May 14, 2018 (edited) (setq xss2 (ssget"C"pt1 pt2 '((0 . "INSERT") ))) In my blocks there is a circle.How can I find out the radius of that Are you going to select a lot of blocks or just one? If it is just one block you can use (setq circle_rad (vla-get-radius (vlax-ename->vla-object (car (nentsel "\nSelect Circle in Block : "))))) Edited May 14, 2018 by dlanorh Quote Link to comment Share on other sites More sharing options...
BIGAL Posted May 15, 2018 Share Posted May 15, 2018 If you dont nentsel a circle or arc then circle_rad will return nil so you may want to wrap it in a check for radius property. This example is check block for attributes (if (and (vlax-property-available-p ent "hasattributes") (vla-get-hasattributes ent) (setq atts (vlax-invoke ent "getattributes")) ) [/code] Quote Link to comment Share on other sites More sharing options...
dlanorh Posted May 15, 2018 Share Posted May 15, 2018 If you dont nentsel a circle or arc then circle_rad will return nil so you may want to wrap it in a check for radius property. This example is check block for attributes (if (and (vlax-property-available-p ent "hasattributes") (vla-get-hasattributes ent) (setq atts (vlax-invoke ent "getattributes")) ) [/code] Good point Quote Link to comment Share on other sites More sharing options...
dlanorh Posted May 15, 2018 Share Posted May 15, 2018 This will return the radius of a circle within a block or a circle within a nested block (not tested past 1 nested block) (vl-load-com) (defun c:crad ( / ent circle_rad) (setq ent (car (nentsel "\nSelect Circle in Block : "))) (if (= (cdr (assoc 0 (entget ent))) "CIRCLE") (setq circle_rad (vla-get-radius (vlax-ename->vla-object ent))) (alert "Not a Circle") ) ) Quote Link to comment Share on other sites More sharing options...
Tharwat Posted May 15, 2018 Share Posted May 15, 2018 (defun c:test (/ ent get) (if (setq ent (car (nentsel "\nSelect Circle in Block : "))) (if (= (cdr (assoc 0 (setq get (entget ent)))) "CIRCLE") (princ (rtos (cdr (assoc 40 get)) 2)) (alert "Not a Circle") ) ) (princ) ) Quote Link to comment Share on other sites More sharing options...
dlanorh Posted May 16, 2018 Share Posted May 16, 2018 (defun c:test (/ ent get) (if (setq ent (car (nentsel "\nSelect Circle in Block : "))) (if (= (cdr (assoc 0 (setq get (entget ent)))) "CIRCLE") (princ (rtos (cdr (assoc 40 get)) 2)) (alert "Not a Circle") ) ) (princ) ) doh! Quote Link to comment Share on other sites More sharing options...
wimal Posted May 16, 2018 Author Share Posted May 16, 2018 Thanks everybody It was a great help. Quote Link to comment Share on other sites More sharing options...
Tharwat Posted May 16, 2018 Share Posted May 16, 2018 doh! Just let me what are you thinking of ? Quote Link to comment Share on other sites More sharing options...
wimal Posted May 17, 2018 Author Share Posted May 17, 2018 (setq xss2 (ssget"C"pt1 pt2 '((0 . "INSERT") ))) I mean there are blocks in my selection set. So I cant directly pick on circle to get the diameter. Please help me to do that. Quote Link to comment Share on other sites More sharing options...
Tharwat Posted May 17, 2018 Share Posted May 17, 2018 (setq xss2 (ssget"C"pt1 pt2 '((0 . "INSERT") ))) I mean there are blocks in my selection set. So I cant directly pick on circle to get the diameter. Please help me to do that. Hi, This should print the radius of circles found in the selected blocks: (if xss2 (repeat (setq i (sslength xss2)) (setq obj (tblobjname "BLOCK" (cdr (assoc 2 (entget (ssname xss2 (setq i (1- i)))))))) (while (setq obj (entnext obj)) (and (= (cdr (assoc 0 (setq get (entget obj)))) "CIRCLE") (print (cdr (assoc 40 get)))) ) ) ) Quote Link to comment Share on other sites More sharing options...
dlanorh Posted May 17, 2018 Share Posted May 17, 2018 (edited) Hi, This should print the radius of circles found in the selected blocks: (if xss2 (repeat (setq i (sslength xss2)) (setq obj (tblobjname "BLOCK" (cdr (assoc 2 (entget (ssname xss2 (setq i (1- i)))))))) (while (setq obj (entnext obj)) (and (= (cdr (assoc 0 (setq get (entget obj)))) "CIRCLE") (print (cdr (assoc 40 get)))) ) ) ) If the block is scaled then you need to check if the block is uniformly scaled and if it is, multiple the radius from the block def by the xscalefactor to get the true radius:working: Edited May 17, 2018 by dlanorh update Quote Link to comment Share on other sites More sharing options...
Tharwat Posted May 17, 2018 Share Posted May 17, 2018 If the block is scaled then you need to check if the block is uniformly scaled and if it is, multiple the radius from the block def by the xscalefactor to get the true radius:working: Right on. But it seems is that the OP deleted one of their replies that they mentioned they wanted to get the radius to re-scale the blocks back to scale. Quote Link to comment Share on other sites More sharing options...
dlanorh Posted May 17, 2018 Share Posted May 17, 2018 Right on. But it seems is that the OP deleted one of their replies that they mentioned they wanted to get the radius to re-scale the blocks back to scale. No wonder i'm confused Quote Link to comment Share on other sites More sharing options...
wimal Posted May 18, 2018 Author Share Posted May 18, 2018 (edited) Both of you are correct.We need to resize the block with reference to the circle inside the block. Our blocks are always scaled uniformly. So the above code is fulfill our requirements. Thanks for your valuable time and codes. Edited May 18, 2018 by wimal Quote Link to comment Share on other sites More sharing options...
dlanorh Posted May 18, 2018 Share Posted May 18, 2018 Both of you are correct.We need to resize the block with reference to the circle inside the block. Our blocks are allays scaled uniformly. So the above code is fulfill our requirements. Thanks for your valuable time and codes. If you need to check the blocks scale using lisp, check the scale factor (= (cdr (assoc 41 (entget ent))) 1) ; for "insert" entity (= (vla-get-xscalefactor blk_obj) 1); for blk object Quote Link to comment Share on other sites More sharing options...
wimal Posted May 18, 2018 Author Share Posted May 18, 2018 If you need to check the blocks scale using lisp, check the scale factor (= (cdr (assoc 41 (entget ent))) 1) ; for "insert" entity (= (vla-get-xscalefactor blk_obj) 1); for blk object ;;;............FIND DETAILS OF CIRCLE INSIDE A BLOCK......................... (setq xss2 nil) (setq pt1 (getpoint"\n Select objects by window ")) (setq pt2 (getcorner pt1"\n 2nd corner")) (setq xss2 (ssget"C"pt1 pt2 '((0 . "INSERT") ))) (if xss2 (repeat (setq i (sslength xss2)) (setq e(entget (ssname xss2 (setq i (1- i))))) (setq xscale (cdr(assoc 41 e))) (setq obj (tblobjname "BLOCK" (cdr (assoc 2 e)))) (while (setq obj (entnext obj)) (and (= (cdr (assoc 0 (setq get (entget obj)))) "CIRCLE") (setq radius (cdr (assoc 40 get))) );and );while );repeat );if (setq actu_radius (* radius xscale)); present radious of circle ;;;............................................................................. Quote Link to comment Share on other sites More sharing options...
Tharwat Posted May 18, 2018 Share Posted May 18, 2018 Select similar blocks then from the properties palette you can change the three scales X,Y,Z to 1.0 and that's the shortest way. Quote Link to comment Share on other sites More sharing options...
wimal Posted May 19, 2018 Author Share Posted May 19, 2018 Select similar blocks then from the properties palette you can change the three scales X,Y,Z to 1.0 and that's the shortest way. Good idea. thanks a lot. Quote Link to comment Share on other sites More sharing options...
wimal Posted May 25, 2018 Author Share Posted May 25, 2018 ;;;............FIND DETAILS OF CIRCLE INSIDE A BLOCK......................... (setq xss2 nil) (setq pt1 (getpoint"\n Select objects by window ")) (setq pt2 (getcorner pt1"\n 2nd corner")) (setq xss2 (ssget"C"pt1 pt2 '((0 . "INSERT") ))) (if xss2 (repeat (setq i (sslength xss2)) (setq e(entget (ssname xss2 (setq i (1- i))))) (setq xscale (cdr(assoc 41 e))) (setq obj (tblobjname "BLOCK" (cdr (assoc 2 e)))) (while (setq obj (entnext obj)) (and (= (cdr (assoc 0 (setq get (entget obj)))) "CIRCLE") (setq radius (cdr (assoc 40 get))) [color="red"](setq center (cdr (assoc 10 get)))[/color] );and );while );repeat );if (setq actu_radius (* radius xscale)); present radious of circle ;;;............................................................................. How can I get the present location of the circle. 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.