Code Red > .NET

Renaming a single instance of a block .. is it possible?

(1/5) > >>

Keith™:
I was going to write a dissertation on why this is necessary, but it was getting too long ... so here is the abbreviated version.

I am programmatically copying a layout to a new layout, including all geometry that is on the source layout. I want to rename the block references on the new layout because their definition will be modified programmatically and I don't want to affect the source blocks.

To complicate matters, each block may have between 2 and 67 attributes at various scales, locations and rotations within the source block. These will not be changing.

Consider this scenario:
Insert block "a" on a layout named "Current" then rename block "a" to "a-Current-n", where n is an index number;
Copy "Current" layout and rename it to "Future";
Rename all block references on "Future" layout to "a-Future-n" where n is the index number;

"a" will remain the same, n will remain the same, the only thing that changes is "Current" changes to "Future".

While I sit here and type this, I am considering if I can just clone the block defs and rename them, then rename the references to match.

Code not required, I'll address that later, a methodology is what I am looking for at this point ...

Atook:
Still trying to sort out what you're trying to do.

Will the geometry of the block be changing, or just  attribute values?

If the geometry is changing, it seems like you'll need a unique block for every layout. You'd need to modify the geometry and give it a unique name then insert it on that layout. I like your naming idea, then you can parse for it later if  you need to access programmatically .

There is however, a good chance that I'm misunderstanding your post completely.  :brow:

Keith™:
I think you have the basic idea .. the geometry will be modified, similar to a dynamic block.

The crux of this project is that there are only 25 +/- blocks that can be configured in tens of thousands of ways to create a drawing. As the attributes change and are updated to various values, the blocks automatically reconfigure based on predefined parameters. Sort of like a dynamic block with parametric constraints that are tied to attribute values.

The user will select data points that are imported. Initially, there are no blocks in the drawing, but once a dataset has been imported, the user can then use that base model to generate other layouts and update the blocks on that particular layout with new data without changing the initial one.

So basically, the code create a block programmatically and gives it a unique name. It then inserts other blocks into it to create the geometry based on attribute values. If that block is copied, it needs to be renamed because two instances of the same block will cause data calculations to be incorrect.

Atook:

--- Quote from: Keith™ on June 05, 2017, 10:18:31 PM ---... If that block is copied, it needs to be renamed because two instances of the same block will cause data calculations to be incorrect.

--- End quote ---

This could be a sticking point. Would it be possible that a user copy this block while your software isn't running? If so, you'll have two instances of the same block and all the tomfoolery that goes along with it.

If not, you've laid out the problem pretty well. It's almost time to write some code for it. :)

Keith™:
The software will be loaded automatically when AutoCAD opens. Of course no amount of code can control what people do to break drawings, but if they are given the tools to do it correctly to begin with, the chances of breaking the drawing is minimized somewhat.

Navigation

[0] Message Index

[#] Next page

Go to full version