LoveArx 发表于 2016-8-14 08:30:02

图块位置不变的情况下重设块的插入点

Resetting the origins of block table records in a drawing

Issue
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 *****

819534890 发表于 2016-8-15 09:20:20

学习学习学习

qq1254582201 发表于 2016-8-23 11:17:56

看看怎么样,貌似不错的样子啊

qq1254582201 发表于 2016-8-23 11:20:10

不太懂arc,完全蒙了不明觉厉的感觉

牢固 发表于 2016-9-1 11:07:57

回复学习

lijun126136 发表于 2016-9-3 11:02:05

很好,谢谢分享

ARX2014 发表于 2016-9-4 14:57:40

我也来学习学习

zjy2999 发表于 2017-1-26 11:05:49

学习!!!!!!!!!!!!!

lennie 发表于 2017-2-10 10:18:31

btrbtrbtrbtr

lionguns 发表于 2017-2-21 17:19:44

学习!!!!!!!!!!!!!!!!!!!!!

1425361224 发表于 2017-2-27 15:39:38

我来学习学习是怎么回事?

开水瓶游泳 发表于 2017-3-22 10:35:20

RE: 图块位置不变的情况下重设块的插入点 [修改]







edata 发表于 2017-3-31 22:55:29

啥也不说了,感谢楼主分享哇!

QiaoCheng 发表于 2017-5-19 10:51:16

谢谢分享,回复学习

ssyfeng 发表于 2017-5-20 00:06:52

我写的块会变位置
页: [1] 2 3
查看完整版本: 图块位置不变的情况下重设块的插入点