How do I replace geometry in 2D cad in model space

How do I replace geometry in 2D cad in model space

J.Sullivan
Explorer Explorer
1,222 Views
5 Replies
Message 1 of 6

How do I replace geometry in 2D cad in model space

J.Sullivan
Explorer
Explorer

I am looking for a way to select similar geometry and replace it with something else. So if I have 12 circles in various locations in model space and I want to replace them with let's say a square. Can anyone assist, is it possible?

0 Likes
1,223 Views
5 Replies
Replies (5)
Message 2 of 6

Patchy
Mentor
Mentor

It's possible if you use autolisp. Put a point in center of the circle then replace that point with a square,

then select similar of the circle or qselect and delete them.

0 Likes
Message 3 of 6

J.Sullivan
Explorer
Explorer
can you explain in more detail I am forwarding this to a coworker
0 Likes
Message 4 of 6

Patchy
Mentor
Mentor

If you don't have too many circle, then use insert a block of square at the center of the circle using osnap.

if you have thousands of them then you need to use autolisp.

https://www.cadtutor.net/forum/topic/23034-replace-circle-by-block/

 

0 Likes
Message 5 of 6

J.Sullivan
Explorer
Explorer
there are quite a few I will try AutoLISP, ty
0 Likes
Message 6 of 6

Kent1Cooper
Consultant
Consultant

@J.Sullivan wrote:

.... if I have 12 circles in various locations in model space and I want to replace them with let's say a square. ....


It depends on what you mean by that, in detail.  If you want to replace each selected Circle with a square as an orthogonal Polyline closed rectangle with its edge length the same as the Circle's diameter, this seems to do that:

 

(defun C:C2S ; = Circle(s) {to} Square(s)
  (/ ss n cir cdata ctr rad)
  (if (not (setq ss (ssget "_I" '((0 . "CIRCLE"))))); use pre-selection if present
    (setq ss (ssget '((0 . "CIRCLE")))); if not, ask User
  ); if
  (if ss
    (repeat (setq n (sslength ss)) ; then
      (setq
        cir (ssname ss (setq n (1- n)))
        cdata (entget cir)
        ctr (cdr (assoc 10 cdata))
        rad (cdr (assoc 40 cdata))
      ); setq
      (command "_.rectang"
        "_non" (mapcar '- ctr (list rad rad))
        "_non" (mapcar '+ ctr (list rad rad))
        "_.matchprop" cir (entlast) "" ; for Layer, linetype, etc.
      ); command
      (entdel cir)
    ); repeat
  ); if
  (princ)
)

 

If you have a pre-selection including any Circle(s), it does those; if not, it asks you to select, and accepts only Circles in the selection.

 

But maybe you want to replace all Circles, regardless of size, with the same size square.  Or with squares of the same areas as the Circles they replace.  Or maybe the square is a Block.  Or maybe you want to replace all selected Circles collectively with one square somehow [doesn't seem likely, but the wording would support that], in which case what would determine its size and location?  Or maybe you don't want the squares orthogonally oriented.  Or maybe you want the squares on the current Layer, regardless of the Circles' Layer(s).  Or maybe....

 

Kent Cooper, AIA
0 Likes