ObjectARX
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

what is good approach to deal with "Base" not at origin for xRefs

2 REPLIES 2
SOLVED
Reply
Message 1 of 3
Anonymous
457 Views, 2 Replies

what is good approach to deal with "Base" not at origin for xRefs

Hi,

 

I am working for AutoCAD based software.

We can show many drawings together in one main drawing. For that we create Block of each drawing and insert that block in the main drawing.

 

For xRefs observed one problem as follows -:

If “base” for any xRef is not at origin (0,0,0) then block of that xRef get misplaced when viewed in the main drawing.

 

We get transforms from each xRef as follows -:

 

blockTable->getAt (pChildXrefGraphNode->name(), blockTableRecord, AcDb::kForRead);

blockTableRecord->getBlockReferenceIds(ids);

for all ids

       AcDbBlockReference* pBlockRef = NULL;

       AcDbObjectId blockRefId = ids[i];

       acdbOpenObject(pBlockRef, blockRefId, AcDb::kForRead);

       xform = pBlockRef->blockTransform();

       // Later, this xform will be used to insert the block in the main drawing…

 

 

While inserting the block we create the block first and then insert its reference as follows

        AcGePoint3d pt = AcGePoint3d::kOrigin;

        *pBlockRef = new AcDbBlockReference (pt,blockId);

 

To fix the position of block (created for xRef), I tried 2 options as follows -:

 

A) If base is 100,100,0 & position is x, y, z then assume base as 0,0,0 and make position as 100 + x, 100 + y, 0 + z.

Then calculate the transform for that xRef block as follows -:

 

blockTable->getAt (pChildXrefGraphNode->name(), blockTableRecord, AcDb::kForRead);

 

AcGePoint3d basePoint1 = blockTableRecord->origin();

AcGeVector3d translation;

translation.set(basePoint1[X], basePoint1[Y], basePoint1[Z]);

 

blockTableRecord->getBlockReferenceIds(ids);

for all ids

       AcDbBlockReference* pBlockRef = NULL;

       AcDbObjectId blockRefId = ids[i];

       acdbOpenObject(pBlockRef, blockRefId, AcDb::kForWrite);

      

      AcGePoint3d positionPoint = pBlockRef->position();

      xform = pBlockRef->blockTransform();

     

      AcGeVector3d realTranslation = (pBlockRef -> blockTransform()) * translation;

      AcGePoint3d newPositionPoint = positionPoint + realTranslation;

      pBlockRef->setPosition(newPositionPoint);

  

      xform = pBlockRef->blockTransform();

      // Later on this xform will be used to insert the block in the main drawing…

 

OR

 

B) While reading xRef data, read the “Base” point as follows -:

           AcGePoint3d originPoint = pBlockRef->position();

Store this “originPoint” as member variable and while displaying that block use it as 1st parameter while creating block reference object as follows -:

           AcGePoint3d pt = m_originPoint;

           *pBlockRef = new AcDbBlockReference (pt,blockId);

 

Both of these solutions worked for me.

But I am not expert in this area and could you please reply which approach should I continue with?

Or

Is there any other simple solution to deal with this “Base” is not at origin issue?

 

Thanks a lot for your time.

 

with regards

ND.

 

2 REPLIES 2
Message 2 of 3
owenwengerd
in reply to: Anonymous

I would prefer A in most situations, but I think either method is perfectly valid.

--
Owen Wengerd
ManuSoft
Message 3 of 3
Anonymous
in reply to: owenwengerd

Hi,

 

Thanks a lot for your feedback..

 

With regards

ND.

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

Post to forums  

Autodesk Design & Make Report

”Boost