Insert a new block based on the size of an old block (width and length)

Insert a new block based on the size of an old block (width and length)

Anonymous
Not applicable
1,320 Views
11 Replies
Message 1 of 12

Insert a new block based on the size of an old block (width and length)

Anonymous
Not applicable

 

Hi All

Is there better way to replace rectangle shape blocks based on old block’s size (width and length)

I’m working on files exported from 3rd party CAD file.

 

All blocks in each layer have same block name but the size is different because of scale difference. ( They are supposed to be different blocks)

For example, in a layer “TableT”, there are several rectangle shape blocks with different size but name of all blocks is “SK1”

 

I need to replace the old blocks with new blocks which is correct size and have scale of X=1,Y=1,Z=1.

The name of new block is based on its layer name and block size (width and length; shorter length is width and longer length is length)

For example, if actual size(dimension) of an old block named “SK1” in “TableT” layer is 20X40 then I need to replace the old block with a block named “TableT2040” which is size of 20X40 with scale of 1,1,1.

 

The block naming convetion could be different as long as it indicate the layer and size.

 

Current work flow is that I put dimensions on all old blocks then I chose new blocks from block library and replace each block. Another words,,,, 100% manual…

 

Are there any tools or approach for better workflow?

 

Thank for reading this.

Sincerely,

 

 

 

 

 

 

0 Likes
Accepted solutions (1)
1,321 Views
11 Replies
Replies (11)
Message 2 of 12

kerry_w_brown
Advisor
Advisor

I can't imagine there will be a tool to do this .. it is rather specialised.

 

I'll assume you are not asking someone to write this for you ... that would be a bit cheeky.

 

 

This is how I'd build a basic test version :

 

Build a data list to define the existing blocks. ( appears to be only 7 )

A simple cons'd list defining blockName and Original sizes would do.

 

Select the existing Block

Read the X, Y, Z Scale

Read the Rotation

Read the InsertPoint

Read the Layer

Read the blockName

 

Determine the actual replacementSize from the Original sizes in the data list and from the current X, X, Z scale.

Determine the replacement blockName

 

If the block exists

Insert the Replacement block on the correct Layer at the correct  rotation.

 

Delete the original block , or change it's layer for deletion later after a QA check.

 

If the new block does not exist either build it on the fly

or advise the user of the sizes and name required.

 

Regards,

 

 

 


// Called Kerry or kdub in my other life.

Everything will work just as you expect it to, unless your expectations are incorrect. ~ kdub
Sometimes the question is more important than the answer. ~ kdub

NZST UTC+12 : class keyThumper<T> : Lazy<T>;      another  Swamper
0 Likes
Message 3 of 12

3wood
Advisor
Advisor

Use steps below to cut the time to less than half you spent.

1. Select an old block and right-click, use "Select similar" from short-cut menu to select all these blocks. For example SK6.

2. Use QSELECT to define Scale X, for example =2.0, (not 2), and Opt "Include in new selection set".

3. Use MBLOCKREPLACE to replace these blocks.

4. Repeat steps above to replace all blocks.

You can not replace negative-scaled blocks with positive-scaled blocks at the same time.

 

0 Likes
Message 4 of 12

stevor
Collaborator
Collaborator

This is called 'shape recognition,'  'geometry recognition',

and few other things.

Since Autocad is vector based,

and autolisp is the easiest to learn,

this is the way to go;

if no simple, and safe, solutions appear.

 

I did not find any code for an  exact fit,

but the pieces are out there.

A start is at

http://lee-mac.com/changeblockinsertion.html

 

Another way: a work around might be to scale the

Inserts by Block name, or, to redefine the Blocks.

S
0 Likes
Message 5 of 12

Anonymous
Not applicable

First all, thank for the wonderful feedbacks.

It helped me to view my problem from anther view point.

 

About using scale, I used to try to select blocks by scales then replaced blocks but there are too many variation to choose from.

 

How about change name of each blocks to its XY scale (scale Z is always 1)

For example,

  • If a block name SK1 has scale of 1,1.25,1 and another block named SK1 has scale of 2,1.25,1 then change first block name to SK11,1.25 and another to SK12,1.25

If each blocks could get some ID, then I can change the block names with batch to collect size name, then I could replace with correct blocks.

(I can't use block replacement by name as most of blocks have same names)

 

Is it possible?

Thank you.   

0 Likes
Message 6 of 12

kerry_w_brown
Advisor
Advisor

 

Have another look at the proposal I made. 

You only have 7 original blocks. 

 

It's really not that complicated to develop a programmatic solution.

If you map it out on a piece of paper you'll see. 

 

How many of these conversions do you need to do for each project ?

How often will you need to convert a project ?

 

 


// Called Kerry or kdub in my other life.

Everything will work just as you expect it to, unless your expectations are incorrect. ~ kdub
Sometimes the question is more important than the answer. ~ kdub

NZST UTC+12 : class keyThumper<T> : Lazy<T>;      another  Swamper
0 Likes
Message 7 of 12

Anonymous
Not applicable

Hello KerryBrown

 

I could write a simple lisp which calls or combines CAD commends but not beyond.

I don’t want to be rude to ask full description of possible solutions in the forum either.

If I could get a better idea or possible leads (keyword) to find another way, it would be great.

 

Yes, I read your proposal and yet it is logically right, I just can’t implement.

So, changing each block name to its scale would be the next best approach or request I could think of.

 

For project, there could be about 7~15 different blocks and the library could be between 100~300. (I will create a block library of 1000 since I don’t know exact size of each blocks would be. I need to make as many blocks as possible for different variations) 

 

The convert project wouldn’t be happening very open, but when it happens, replacing the blocks are requirements. 

 

By the way, I realize there is no need to read the layer information as the block name is different by layers.

 

Once again, thank you for your time.

 

Sincerely.

0 Likes
Message 8 of 12

kerry_w_brown
Advisor
Advisor
Accepted solution

 

Is this what you had in mind ??

 

http://www.theswamp.org/index.php?topic=50602.msg557525#msg557525


// Called Kerry or kdub in my other life.

Everything will work just as you expect it to, unless your expectations are incorrect. ~ kdub
Sometimes the question is more important than the answer. ~ kdub

NZST UTC+12 : class keyThumper<T> : Lazy<T>;      another  Swamper
Message 9 of 12

Anonymous
Not applicable

Hello KerryBrown,

 

I told you that i don't want to be, but you just made me cheeky.....

 

 

It works great! and the code is easy to understand as well.

 

( I realize one of the old block with scale 1,1,1, size is wrong because of this code)

 

I understand that it works at single block at this point, it still would save me hell of time!!!!!.

 

(Now, i need to create a block library with thousands of blocks for bluet poof  --;)

 

 

Once again thanks for the time and thought into my problems.

 

 

Have a wonderful day and happy and happy holiday~~~~

 

 

0 Likes
Message 10 of 12

kerry_w_brown
Advisor
Advisor

@Anonymous wrote:

 

 

 

(Now, i need to create a block library with thousands of blocks for bluet poof  --;)

 

 


This may help with identifying the required blocks.

 

Stage 2 :
Determine the unique blocks required.

http://www.theswamp.org/index.php?topic=50602.msg557563#msg557563

 


// Called Kerry or kdub in my other life.

Everything will work just as you expect it to, unless your expectations are incorrect. ~ kdub
Sometimes the question is more important than the answer. ~ kdub

NZST UTC+12 : class keyThumper<T> : Lazy<T>;      another  Swamper
0 Likes
Message 11 of 12

Anonymous
Not applicable
Hello KerryBrown,
Don't try to be Santa, i wasn't that good this year ^^;
Maybe i wish for multiple selection, but once again, i wasn't that good this year ^^;

Have a wonderful weekend ~~~
0 Likes
Message 12 of 12

kerry_w_brown
Advisor
Advisor

 

 

Stage 3 :
Build designated blocks required.

Proof of concept.

http://www.theswamp.org/index.php?topic=50602.msg557587#msg557587

MakeNewBlocks snip_20151212155752.png


// Called Kerry or kdub in my other life.

Everything will work just as you expect it to, unless your expectations are incorrect. ~ kdub
Sometimes the question is more important than the answer. ~ kdub

NZST UTC+12 : class keyThumper<T> : Lazy<T>;      another  Swamper
0 Likes