ObjectARX
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Reply
Message 1 of 8
Anonymous
327 Views, 7 Replies

Xref Help

I need help getting the Xref information. I have looped throught the block
table and found the xref,
but i need to get the x,y,z, rotation & scale of the xref.

I think i need to use AcDbBlockReference, but i don't know how to get from a
BlocktableRecord to the BlockReference.

Can Someone Help??

Lawrence
7 REPLIES 7
Message 2 of 8
Anonymous
in reply to: Anonymous

Lawrence,

First you will need to iterate through BlockTable "MODEL_SPACE" to collect
all the AcDbBlockReference entities placed on the drawing.

For each one, you will need to know what is the BlockTableRecord that
generated it. Use the blockTableRecord() function to get the BTR's ObjectID
and open it.

Once you get the BlockTableRecord use its isFromExternalReference() member
function to find out if it is a XREF.
Also you may need to check its name to find out if it is an specific XREF.
Take a look at AcDbBlockTableRecord documentation.

If it is, get back to the BlockReference and acquire information about it
using:

AcDbBlockReference::blockTableRecord()
AcDbBlockReference::blockTransform()
AcDbBlockReference::geomExtentsBestFit()
AcDbBlockReference::normal()
AcDbBlockReference::position()
AcDbBlockReference::rotation()
AcDbBlockReference::scaleFactors()
AcDbBlockReference::treatAsAcDbBlockRefForExplode()

Hope this help,
Fernando.

"Lawrence" wrote in message
news:7592184BA456FF225095A30F8B1983D1@in.WebX.maYIadrTaRb...
> I need help getting the Xref information. I have looped throught the block
> table and found the xref,
> but i need to get the x,y,z, rotation & scale of the xref.
>
> I think i need to use AcDbBlockReference, but i don't know how to get from
a
> BlocktableRecord to the BlockReference.
>
> Can Someone Help??
>
> Lawrence
>
>
Message 3 of 8
Anonymous
in reply to: Anonymous

You can use the getBlockReferenceIds() member of the
AcDbBlockTableRecord to get the ObjectIDs of all
references to the block, and open them sequentially.

For most other types of entities, you have to manually
search through the MODEL_SPACE or PAPER_SPACE(n) blocks,
but for block references this isn't necessary.


"Lawrence" wrote in message
news:7592184BA456FF225095A30F8B1983D1@in.WebX.maYIadrTaRb...
> I need help getting the Xref information. I have looped throught the block
> table and found the xref,
> but i need to get the x,y,z, rotation & scale of the xref.
>
> I think i need to use AcDbBlockReference, but i don't know how to get from
a
> BlocktableRecord to the BlockReference.
>
> Can Someone Help??
>
> Lawrence
>
>
Message 4 of 8
Anonymous
in reply to: Anonymous

Thanks Tony...I forget that one...

"Tony Tanzillo" wrote in message
news:56847543B594FF3D2CED6AEBFBF542EA@in.WebX.maYIadrTaRb...
> You can use the getBlockReferenceIds() member of the
> AcDbBlockTableRecord to get the ObjectIDs of all
> references to the block, and open them sequentially.
>
> For most other types of entities, you have to manually
> search through the MODEL_SPACE or PAPER_SPACE(n) blocks,
> but for block references this isn't necessary.
>
>
> "Lawrence" wrote in message
> news:7592184BA456FF225095A30F8B1983D1@in.WebX.maYIadrTaRb...
> > I need help getting the Xref information. I have looped throught the
block
> > table and found the xref,
> > but i need to get the x,y,z, rotation & scale of the xref.
> >
> > I think i need to use AcDbBlockReference, but i don't know how to get
from
> a
> > BlocktableRecord to the BlockReference.
> >
> > Can Someone Help??
> >
> > Lawrence
> >
> >
>
>
Message 5 of 8
Anonymous
in reply to: Anonymous

Fernando,
I have iterated through the BlockTable and got the ObjectID, but i
don't understand how to "Open it"
Here is basically what I have now. Can you tell me what you mean by "open
it"

AcDbDatabase *pData = acdbHostApplicationServices()->workingDatabase();

// Create Iterator to search block table for xref objects

AcDbBlockTable* pBlkTbl;

es = pData->getBlockTable(pBlkTbl, AcDb::kForRead);

if (es != Acad::eOk)

{return es;}

AcDbBlockTableIterator *pBlkTblIter = NULL;

es = pBlkTbl->newIterator(pBlkTblIter);

pBlkTbl->close();

if (es != Acad::eOk)

{return es;}

AcDbObjectId *pObj;

AcDbBlockTableRecord* pBlkTblRec;

// Step thru base drawing block table looking for xrefs.

for (; !pBlkTblIter->done(); pBlkTblIter->step())

{


es = pBlkTblIter->getRecord(pBlkTblRec, AcDb::kForRead);

if(pBlkTblRec != NULL)

{

if((pBlkTblRec->isFromExternalReference() == Adesk::kTrue) &&

(isXrefReferenced(pBlkTblRec) == Adesk::kTrue) )

{

pObj = pBlkTblRec->objectId();

// how do i open the Object??/

}

pBlkTblRec->close();

}

}

delete pBlkTblIter;



"Fernando Malard" wrote in message
news:276C7BC320AEF948F8389C15A9A8C8DF@in.WebX.maYIadrTaRb...
> Lawrence,
>
> First you will need to iterate through BlockTable "MODEL_SPACE" to collect
> all the AcDbBlockReference entities placed on the drawing.
>
> For each one, you will need to know what is the BlockTableRecord that
> generated it. Use the blockTableRecord() function to get the BTR's
ObjectID
> and open it.
>
> Once you get the BlockTableRecord use its isFromExternalReference() member
> function to find out if it is a XREF.
> Also you may need to check its name to find out if it is an specific XREF.
> Take a look at AcDbBlockTableRecord documentation.
>
> If it is, get back to the BlockReference and acquire information about it
> using:
>
> AcDbBlockReference::blockTableRecord()
> AcDbBlockReference::blockTransform()
> AcDbBlockReference::geomExtentsBestFit()
> AcDbBlockReference::normal()
> AcDbBlockReference::position()
> AcDbBlockReference::rotation()
> AcDbBlockReference::scaleFactors()
> AcDbBlockReference::treatAsAcDbBlockRefForExplode()
>
> Hope this help,
> Fernando.
>
> "Lawrence" wrote in message
> news:7592184BA456FF225095A30F8B1983D1@in.WebX.maYIadrTaRb...
> > I need help getting the Xref information. I have looped throught the
block
> > table and found the xref,
> > but i need to get the x,y,z, rotation & scale of the xref.
> >
> > I think i need to use AcDbBlockReference, but i don't know how to get
from
> a
> > BlocktableRecord to the BlockReference.
> >
> > Can Someone Help??
> >
> > Lawrence
> >
> >
>
>
Message 6 of 8
Anonymous
in reply to: Anonymous

"Lawrecne" wrote in message
news:58E0AAB476D28BC03918A9F8CD27CBA3@in.WebX.maYIadrTaRb...
>
> pObj = pBlkTblRec->objectId();
>
> // how do i open the Object??/
>
> }

You're going to have to do a bit more studying of
the API. The BlockTableRecord object is open (it's
the variable pBlkTblRec).

The objectId() member is returning the object id
of the open object, which is not of any use to you
here.

You have to call getBlockReferenceIds() to get an
array of ObjectIds of all insertions of the block,
and then you open each of them:


AcDbObjectIdArray ids;

Acad::ErrorStatus es;

es = pBlkTblRec->getBlockReferenceIds(ids, true, true);

if( es != Acad::eOk )
return es;

for(int i = 0; i < ids.length(); i++ )
{
AcDbBlockReference* pBlockRef = NULL;

es = acdbOpenObject(pBlockRef, ids, AcDb::kForRead);

if( es == Acad::eOk && pBlockRef != NULL )
{
AcGePoint3d inspt(pBlockRef->position());
acutPrintf("\n X: %0.2f Y: %0.2f Z: %0.2f",
inspt[0], inspt[1], inspt[2]);

// do other stuff with pBlockRef, then close it

pBlockRef->close();
}
}
Message 7 of 8
Anonymous
in reply to: Anonymous

Tony, Thank You.

This is just what I needed. I am now beginning to understand. I general
find the info I need in the ObjectARX Dev online book, but I find I don't
know how to implement it. The ones with examples are the ones I tend to
understand better. I love examples!!!

My next thing is to figure out which ones are nested xrefs. I know it has to
do with the XrefNode, XrefGraph & acedGetCurDwgXrefGraph() from the dev
book. You wouldn't have a example of this one?

Again Thank you for the help

Lawrence

"Tony Tanzillo" wrote in message
news:7D723A5C3FB23785D70C1017854C41C7@in.WebX.maYIadrTaRb...
> "Lawrecne" wrote in message
> news:58E0AAB476D28BC03918A9F8CD27CBA3@in.WebX.maYIadrTaRb...
> >
> > pObj = pBlkTblRec->objectId();
> >
> > // how do i open the Object??/
> >
> > }
>
> You're going to have to do a bit more studying of
> the API. The BlockTableRecord object is open (it's
> the variable pBlkTblRec).
>
> The objectId() member is returning the object id
> of the open object, which is not of any use to you
> here.
>
> You have to call getBlockReferenceIds() to get an
> array of ObjectIds of all insertions of the block,
> and then you open each of them:
>
>
> AcDbObjectIdArray ids;
>
> Acad::ErrorStatus es;
>
> es = pBlkTblRec->getBlockReferenceIds(ids, true, true);
>
> if( es != Acad::eOk )
> return es;
>
> for(int i = 0; i < ids.length(); i++ )
> {
> AcDbBlockReference* pBlockRef = NULL;
>
> es = acdbOpenObject(pBlockRef, ids, AcDb::kForRead);
>
> if( es == Acad::eOk && pBlockRef != NULL )
> {
> AcGePoint3d inspt(pBlockRef->position());
> acutPrintf("\n X: %0.2f Y: %0.2f Z: %0.2f",
> inspt[0], inspt[1], inspt[2]);
>
> // do other stuff with pBlockRef, then close it
>
> pBlockRef->close();
> }
> }
>
>
>
>
>
>
>
Message 8 of 8
Anonymous
in reply to: Anonymous

Hi,

I was looking for the same info, and had posted a query just 2-3 bak
regarding the same. But nobody answered.. 😞 anyway...
My question is, little head of this,

In a drawing i have 3 Xrefs. Both refer to the same drawing. Meaning 3
instances of the ONE XRef. But all the Inserts are having different
Xformation. Now in such a case how can I deterince which XRef belong to
which AcDbBlockReference ? or vice versa ?

Is there any 1-1 hard and fast relationship between the AcDbXRefGraphNode -
> AcDbBlockReference ??

Please help.

thanks and regards.

Vikram




"Tony Tanzillo" wrote in message
news:7D723A5C3FB23785D70C1017854C41C7@in.WebX.maYIadrTaRb...
> "Lawrecne" wrote in message
> news:58E0AAB476D28BC03918A9F8CD27CBA3@in.WebX.maYIadrTaRb...
> >
> > pObj = pBlkTblRec->objectId();
> >
> > // how do i open the Object??/
> >
> > }
>
> You're going to have to do a bit more studying of
> the API. The BlockTableRecord object is open (it's
> the variable pBlkTblRec).
>
> The objectId() member is returning the object id
> of the open object, which is not of any use to you
> here.
>
> You have to call getBlockReferenceIds() to get an
> array of ObjectIds of all insertions of the block,
> and then you open each of them:
>
>
> AcDbObjectIdArray ids;
>
> Acad::ErrorStatus es;
>
> es = pBlkTblRec->getBlockReferenceIds(ids, true, true);
>
> if( es != Acad::eOk )
> return es;
>
> for(int i = 0; i < ids.length(); i++ )
> {
> AcDbBlockReference* pBlockRef = NULL;
>
> es = acdbOpenObject(pBlockRef, ids, AcDb::kForRead);
>
> if( es == Acad::eOk && pBlockRef != NULL )
> {
> AcGePoint3d inspt(pBlockRef->position());
> acutPrintf("\n X: %0.2f Y: %0.2f Z: %0.2f",
> inspt[0], inspt[1], inspt[2]);
>
> // do other stuff with pBlockRef, then close it
>
> pBlockRef->close();
> }
> }
>
>
>
>
>
>
>

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

Post to forums  

Autodesk Design & Make Report

”Boost