图块位置不变的情况下重设块的插入点
Resetting the origins of block table records in a drawingIssue
I have a drawing that contains block table records with non-zero origins, i.e.
they are not set to (0, 0, 0). How can I reset these origins without moving the
positions of all the block's sub-entities in the drawing?
Solution
The following code demonstrates how to modify a block table record's
origin and compensate by moving the insertion point of each of the associated
block references.
Please add the function 'testFunc' as a command.
void ResetAllInstances(AcDbBlockTableRecord * pBlockTableRecord, AcGeVector3d &translation)
{
// Note that this function does not implement any error checking.
// We are assuming that pBlockTableREcord was opened for write by the calling function
// Iterate through all block references of this block table record.
AcDbBlockReferenceIdIterator * pIterator;
pBlockTableRecord->newBlockReferenceIdIterator(pIterator);
for (pIterator->start();!pIterator->done();pIterator->step())
{
AcDbBlockReference * pBlockRef;
pIterator->getBlockReference(pBlockRef, AcDb::kForWrite,true);
// Transform the translation vector from block coordinates to world coordinates.
AcGeVector3d realTranslation = (pBlockRef->blockTransform())*translation;
// Translate the block reference to counter the effect of the origin change.
pBlockRef->setPosition(pBlockRef->position()+realTranslation);
pBlockRef->close();
} // Next block reference
delete pIterator;
}
下面是测试命令SGP
**** Hidden Message *****
学习学习学习
看看怎么样,貌似不错的样子啊 不太懂arc,完全蒙了不明觉厉的感觉 回复学习 很好,谢谢分享
我也来学习学习
学习!!!!!!!!!!!!!
btrbtrbtrbtr
学习!!!!!!!!!!!!!!!!!!!!!
我来学习学习是怎么回事?
RE: 图块位置不变的情况下重设块的插入点 [修改]
啥也不说了,感谢楼主分享哇! 谢谢分享,回复学习 我写的块会变位置