Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Creating a lisp to align geometry within a block.

10 REPLIES 10
Reply
Message 1 of 11
shaunfarrell5867
2033 Views, 10 Replies

Creating a lisp to align geometry within a block.

Hi All

What I am trying to do is figure out the steps to "reset" geometry within blocks. (Assuming rectilinear).

That is to say find the min X value and Y Value and align that with the 0,0 of the block. To be able to do this on a drawing full of blocks. Essentially fixing poorly defined blocks whose origins are miles/km's away!

Any ideas?

Thanks in advance.

Shaun

 

10 REPLIES 10
Message 2 of 11


@shaunfarrell5867 wrote:

....What I am trying to do is figure out the steps to "reset" geometry within blocks. (Assuming rectilinear).

That is to say find the min X value and Y Value and align that with the 0,0 of the block. To be able to do this on a drawing full of blocks. Essentially fixing poorly defined blocks whose origins are miles/km's away!

....


If all such Block insertions are at scale factors of 1 and the same rotation [big if, huh?], I can imagine a way to do it [which I have, in fact, done manually a few times under those circumstances, but not with a routine]:

 

Select a Block insertion.

Save its Block name and [old] insertion point.

Get and save the desired [new] insertion base point relative to the Block's content.

Copy the Block in place, and Explode the copy.

Define the Block again, using the same name, the Exploded pieces [Previous selection after Exploding], and the new insertion point, answering Yes to the question of whether you want to redefine it, and deleting the pieces in the process.

Find all insertions of that Block, and Move them from the old insertion point to the new one.
 

But if some already-existing insertions are scaled differently, or rotated, they won't be moved appropriately.  Maybe you could go through the set and Move each one individually, making compensation for those differences -- that could be some tricky code, but it's probably doable.

 

Another possibility would be to place a Point or something at the desired new insertion point, Move the Exploded pieces from there to the old insertion point, and redefine the Block using the Exploded pieces and that Point.  That would at least give you a Point that you could move each Block's insertion point to, regardless of scales and rotation, but you'd have to do them individually.  Then once they're all repositioned, you could redefine the Block to remove that Point.

Kent Cooper, AIA
Message 3 of 11
Lee_Mac
in reply to: shaunfarrell5867

You could use my Change Block Insertion program to change the base point of your blocks without changing their position in the drawing (CBIR).

 

You would only need to select one Insert for each block you want to change, and the change will be reflected across all other insertions of the block.

 

Lee

 

Message 4 of 11
Lee_Mac
in reply to: Kent1Cooper


@Kent1Cooper wrote:
Select a Block insertion.

Save its Block name and [old] insertion point.

Get and save the desired [new] insertion base point relative to the Block's content.

Copy the Block in place, and Explode the copy.

Define the Block again, using the same name, the Exploded pieces [Previous selection after Exploding], and the new insertion point, answering Yes to the question of whether you want to redefine it, and deleting the pieces in the process.

Find all insertions of that Block, and Move them from the old insertion point to the new one.
 

But if some already-existing insertions are scaled differently, or rotated, they won't be moved appropriately.


Kent,

 

I think Exploding is out of the question since all attribute values would be lost, along with any dynamic block functionality.

Message 5 of 11
Anonymous
in reply to: Lee_Mac

Lee, Kent is talking about exploding an additional inserted block and not one that is all ready in the drawing.  I have done this on occasion to fix problems with blocks and such.

Message 6 of 11
Lee_Mac
in reply to: Anonymous


@Anonymous wrote:

Lee, Kent is talking about exploding an additional inserted block and not one that is all ready in the drawing.  I have done this on occasion to fix problems with blocks and such.


But as soon as you explode/redefine it, you will lose any Dynamic Block functionality.

Message 7 of 11
Anonymous
in reply to: Lee_Mac

I don't use Dynamic blocks, have seen to many issues when trying to export down to lower versions of software, just like Annotative text.  Yes, they are nice, but when I have to go back and fix or redo stuff to export down, it defeats the purpose of them.  And I have to export down a lot these days.  I know it shouldn't be my problem if someone doesn't upgrade their software but when you have spineless Engineers and Project Managers that don't want to argue with a sub-contracter who still is using R14 or another version and there this is a deadline to get a task completed.  I have always been to downgrade my drawings to get the problem solved to meet said deadline.

Message 8 of 11
Lee_Mac
in reply to: Anonymous


@Anonymous wrote:

I don't use Dynamic blocks.


You don't, but the OP might.

Message 9 of 11
Anonymous
in reply to: Lee_Mac

True, but usually they state if it is a dynamic block.  The more info they provide up front the better help they will get.  Have a good one, have enjoyed the back and forth banter.

Message 10 of 11

I have to admit I was just keeping things easy. The essence of this was to be able to fix/create block library containers. Where there is only once instance of the block, no rotation but geometry has been made either miles away from zero or in some "odd spot". At the moment its open one in block editor, zoom extents, construction lines from XY, move to origin and close block editor. I wanted to throw it out there to see if there is a more "programmatical" method. Even if this only takes a minute or two per block, it soon extrapolates out. As one poster mentioned, this is looking at simple R14 style blocks without adding complexity. It will also only work for blocks where bottom left makes sense, lets not even start on the centroid question 🙂

Message 11 of 11
Anonymous
in reply to: shaunfarrell5867

Shaun,

As they say be careful what you ask for.  Lee's program is pretty good, I would give it a try.  I hate it when people don't give good thought on creating a block in their current drawing with a good insertion point. I myself have tackled such a task in the past and it was no joy.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost