Jump to content

Circle inside the Block


wimal

Recommended Posts

(setq xss2 (ssget"C"pt1 pt2  '((0 . "INSERT") )))

In my blocks there is a circle.How can I find out the radius of that

Link to comment
Share on other sites

  • Replies 20
  • Created
  • Last Reply

Top Posters In This Topic

  • wimal

    7

  • dlanorh

    7

  • Tharwat

    5

  • BIGAL

    1

(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 by dlanorh
Link to comment
Share on other sites

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]

Link to comment
Share on other sites

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 :ouch::oops:

Link to comment
Share on other sites

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")
 )
)

Link to comment
Share on other sites

(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)
)

Link to comment
Share on other sites

(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! :facepalm:

Link to comment
Share on other sites

(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.

Link to comment
Share on other sites

(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))))
     )
   )
 )

Link to comment
Share on other sites

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 by dlanorh
update
Link to comment
Share on other sites

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. :thumbsup:

 

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. ;)

Link to comment
Share on other sites

Right on. :thumbsup:

 

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 :? :itsover:

Link to comment
Share on other sites

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 by wimal
Link to comment
Share on other sites

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 

Link to comment
Share on other sites

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
;;;.............................................................................

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

;;;............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.

Link to comment
Share on other sites

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...