Replacing a Block Reference - Sizing Problem

Replacing a Block Reference - Sizing Problem

Kyudos
Advisor Advisor
519 Views
2 Replies
Message 1 of 3

Replacing a Block Reference - Sizing Problem

Kyudos
Advisor
Advisor

Part of my code constructs a block and replaces any instances of it. Before it does this, it searches for the instances and records where they are and their (actual) size.

 

In order to replace like for like, I create new instances of the symbol, but to get the size correct I need to setScaleFactors on the AcDbBlockReference. But in order to calculate the scale factors I need to know how big the block is originally (i.e., in the AcDbBlockTableRecord). There doesn't seem to be a easy way to get at this info.

 

Do I have to place the block with scales of 1,1,1, find its extents and then rescale? That seems really convoluted for something many people would want to do?

0 Likes
Accepted solutions (1)
520 Views
2 Replies
Replies (2)
Message 2 of 3

tbrammer
Advisor
Advisor

As far as I know creating a 1x1x1 BREF is really the easiest way to determine the extents of a block.

You could also use an AcDbBlockTableRecordIterator to iterate over all block entities and cumulate their extents with getGeomExtents(extents) - but this would be even more complicated.

Also remember that a BREF might have attributes. Do you need to take them into account when you calculate the extent?


Thomas Brammer ● Software Developer ● imos AGLinkedIn
If an answer solves your problem please [ACCEPT SOLUTION]. Otherwise explain why not.

0 Likes
Message 3 of 3

Kyudos
Advisor
Advisor
Accepted solution

I figured everyone who programmatically places blocks must want to do this - so there must be an easier way...there is!

 

 

AcDbExtents totalext;
AcDbBlockTableRecord* pBTR = dynamic_cast<AcDbBlockTableRecord*>(pAcDbObject);

if (pBTR != NULL)
{
    totalext.addBlockExt(pBTR);
    pBTR->close();
}