Display full version of the post: Drawing in relation to 0,0

aarevalo0827
20.07.2017, 21:29
So, we have over 5,000 blocks. These blocks all have different insertion points. What we are trying to do is find where the actual lines, arcs and circles within the drawing are located in relation to 0,0. I know we can do the list command and select the icons and it will give me a center point. I was wondering if there was a way to do it via a lisp command to make it faster. The reason for this is programming. We have a program that will pull these icons in and scale them. We just need to ensure they are placed correctly.

Kent Cooper
21.07.2017, 03:33

I'm having a hard time understanding exactly what you're asking.  5,000 Block definitions as files outside any working drawing, or 5,000 Block insertions within a drawing?  By "the actual lines, arcs and circles" do you mean those that make up the Blocks, or those that are not parts of Blocks, but that Blocks will be "pull[ed] in" and placed in relation to, somehow?  Are those 5,000 Blocks the same things as the "icons" you refer to, or are those something else?  Is the "center point" of an icon [if that's a Block] always its insertion point?Probably what you are asking can be done -- I just don't quite get what that is, yet.  A sample drawing with notations, or even an image of some kind, would go a long way.

aarevalo0827
21.07.2017, 14:16
Sorry for the confusion. The 5000 blocks are individual drawings/icons that are brought or inserted into other AutoCAD files. These 5000 blocks are made up of a group of lines, arcs and circles. Let's say one of the blocks is a stop sign. Instead of the center of the stop sign being the insertion point, it's insertion point is 0,0. The groupings of the stop sign (octogon and text) are located 20,50 (center of the stop sign). I want to know if there is a way for AutoCAD to tell me that the center of the stop sign is 20,50. I know that if I open the file and use the list command and select the groupings of the stop sign it will display the center location - 20,50. Is there a faster way of doing it for all of these drawings/icons? I hope I clarified my situation better. Thanks,

Kent Cooper
21.07.2017, 16:57

I don't know of a way to do that without Inserting one into a drawing, but once you've Inserted one, you can.  It involves getting the Block definition as an object with something like [if your Stop Sign is called "StopSign"]: (setq ent (tblobjname "block" "StopSign")) and then stepping through the things that make it up, which are the next entity, and the next, etc.: (setq ent (entnext ent)) At each step, you can get entity data about the piece you're up to, and handle it any way you like.  The key is that those entities that make up the Block are all defined in terms of locational information in relation to the Block's defined insertion point.  So, if the word "STOP" in your Stop Sign is middle-justified at the center of the sign, and the Block's insertion point is 0,0, you could step through and check each entity for whether it's Text [on the assumption that there won't be any other Text object(s) in a Stop Sign Block], and if it is, get its insertion point, which in your example will be that 20,50 location, and stop looking further.  Similarly, if something is round, and doesn't have any Circles in it other than its outline, you could look at the pieces until you find a Circle, and get its center. In Blocks that don't have some specific entity from which the middle location can be pulled like that, you could step through things and get their bounding boxes, keeping tabs on the lower left and upper right corner of each and saving the extremes, then find the midpoint between the outermost extents of all the objects.  [That does have the possibility of incorrect results in some circumstances, since some objects' bounding boxes can at least sometimes extend beyond their actual graphic extent -- Splines and Mtext are examples, and there might be others.]