Jump to content

Automating Drawing Concentric Circles


endofeternity

Recommended Posts

SOLVED

 

 

Hey everyone,

 

I have a large .DWG with approximately 400 circles representing wells on it. The end goal is to draw an additional circle around each of these with a larger radius (150). Basically what I'm looking for is a way to automate this such that:

 

For (object 1 to last object) {

[indent]if (object is a circle) draw new circle around it[/indent]

}

 

But I'm completely at a loss as to how I would accomplish that. Is there a command that returns x,y coordinates of things? How could I distinguish the circles from the other lines and things in the drawing? Am I doomed to drawing 400 circles by hand?

 

Thanks for any help you can provide :D

Edited by endofeternity
Link to comment
Share on other sites

(cdr (assoc 10 (entget (car (entsel "\n Select circle: ")))))

 

This will get you X, Y and Z values of center point of selected circle.

To distinguish circles from other objects, use ssget filter >> (ssget '((0 . "circle")))

Link to comment
Share on other sites

Simplest fix ever.... add an additional circle to the block definition.

 

Ah. Well then! Thanks lol. I found the problem - some of the wells are defined as blocks and others are circles. But yeah overall I think I've got it covered now. Thanks guys!

Link to comment
Share on other sites

A bit more

 


(setq x 0)
(setq rad (getreal "\nEnter new radius"))

(setq circlist  (ssget '((0 . "CIRCLE"))))
(setq num (sslength circlist))

(repeat num
(setq cenptxy (assoc 10 (entget (ssname circlist x))))
(setq newcen (list (cadr cenptxy)(caddr cenptxy)(caddr cenptxy)))
(command "circle" newcen rad)
(setq x (+ x 1))
)

(princ)

Link to comment
Share on other sites

Bigal

After a nice coding, you get the circles in a selection set, you found the centerpoints and... you used that COMMAND function that is the worse thing you can write in Lisp. In this way, you should take care about the OSNAP settings too -or at least instruct the user to turn it off manually.

I would use an ENTMAKE to create the new circle.

See, it is so easy to post criticism to others program.

Link to comment
Share on other sites

A couple of things I started with version 1.4 hence command is quick and dirty for something simple and another forum user can understand it, as I wrote it I knew some one would say it should use entmake hey thats 4 lines more code I had to type. Did you find the mistake ? Nearly every lisp I have always has set osnaps current layer etc as first thing and last to reset but that comes with experience. Same as entmakes rather than command.

 

It was done free

 

Did it work yes

 

Was it the best code probably not but by the time we finish discussing I am sure all the circles have been done.

 

Replace (command "circle" newcen rad) with (entmake (list (cons 0 "CIRCLE") (cons '10 newcen) (cons 40 Rad)))

Edited by BIGAL
Link to comment
Share on other sites

Ok, Bigal. If it works, then we get an other happy user -for sure he appreciates your effort.

And about that replacement you mentioned: it is *almost* 5 code lines. :) :)

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