关于拖动块的问题()
我做了一个带属性定义的块表记录,和引用该块定义的块参照当我使用AcEdJig拖动该块参照的时候会发现,在拖动的过程中,会出现在块中属性定义的tag中的字符串 和块的图形一起出现.也随着块中的图形一起动
其实属性定义的tag值,应该只是该属性的一个标识,但是为什么在块定义中的这个标识,会在拖动的过程中出现啊?
比如:块中有个属性定义,该属性定义的tag = "标识",这样在拖动这个块 的引用的同时,这个"标识"的字符也会随着图形一起动,其实应该不会出现这个字符串 啊
这个问题郁闷我好几天了,请哪为朋友指点一下 好么?
这么长时间也没有人能解决这个问题么?看来只好使用一个变通的方法了,
pAttDef->setHeight(0.00001)把高度值设置为最小,这样就看不见了;不过我还是不甘心,要是哪位兄弟知道该怎么解决这个问题,请赐教!
其实这个问题就是:在拖动一个块引用的过程中,怎样才能不显示"该块引用的那个块"中的属性定义的Tag字符串 属性和属性定义的问题:
class bjt:
public AcEdJig
{
AcGePoint3d mTo;
AcDbBlockReference* br;
public:
AcDbObjectId append()
{
AcDbBlockTableRecord *btr;
acdbOpenObject(btr,br->blockTableRecord(),kForRead);
if(btr->hasAttributeDefinitions())
{
AcDbBlockTableRecordIterator *it;
btr->newIterator(it);
for(;!it->done();it->step())
{
AcDbEntity *pEnt;
it->getEntity(pEnt, AcDb::kForRead);
// Make sure the entity is an attribute definition
// and not a constant.
//
AcDbAttributeDefinition *pAttdef = AcDbAttributeDefinition::cast(pEnt);
if (pAttdef != NULL && !pAttdef->isConstant())
{
// We have a non-constant attribute definition,
// so build an attribute entity.
//
AcDbAttribute *pAtt = new AcDbAttribute();
pAtt->setPropertiesFrom(pAttdef);
pAtt->setInvisible(pAttdef->isInvisible());
// Translate the attribute by block reference.
// To be really correct, the entire block
// reference transform should be applied here.
//
AcGePoint3d basePoint = pAttdef->position();
basePoint += br->position().asVector();
pAtt->setPosition(basePoint);
pAtt->setHeight(pAttdef->height());
pAtt->setRotation(pAttdef->rotation());
pAtt->setTag(pAttdef->tag());
pAtt->setFieldLength(25);
char *pStr = pAttdef->tag();
pAtt->setTag(pStr);
free(pStr);
pAtt->setFieldLength(pAttdef->fieldLength());
pAtt->setTextString("Assigned Attribute Value");
br->appendAttribute(pAtt);
pAtt->close();
}
pEnt->close();
}
delete it;
}
btr->close();
return AcEdJig::append();
}
//////////////////////////////////////////////////////////////////////////
virtual DragStatus sampler()
{
DragStatus stat;
setUserInputControls((UserInputControls)
(AcEdJig::kAccept3dCoordinates
| AcEdJig::kNoNegativeResponseAccepted
| AcEdJig::kNoZeroResponseAccepted));
static AcGePoint3d axisPointTemp;
stat = acquirePoint(mTo);
if (axisPointTemp != mTo)
axisPointTemp = mTo;
else if (stat == AcEdJig::kNormal)
return AcEdJig::kNoChange;
return stat;
}
//////////////////////////////////////////////////////////////////////////
virtual Adesk::Booleanupdate()
{
br->setPosition(mTo);
return Adesk::kTrue;
}
//////////////////////////////////////////////////////////////////////////
virtual AcDbEntity* entity() const
{
return br;
}
//////////////////////////////////////////////////////////////////////////
void start()
{
br=0;
AcDbBlockTable *bt;
acdbHostApplicationServices()->workingDatabase()->getBlockTable(bt,kForRead);
AcDbObjectId bid;
try
{
char text;
if(RTNORM!=acedGetString(1,"input name",text))throw(0);
if (bt->getAt(text,bid)!=eOk)throw(0);
}
catch(...)
{
bt->close();
return;
}
bt->close();
br=new AcDbBlockReference(AcGePoint3d::kOrigin,bid);
setDispPrompt("Jig a Block");
drag();
append();
}
};
另:
static void BlockJigTestnewJ(void)
{
// Add your code for command BlockJigTest.newJ here
bjt b;
b.start();
}
大侠们能否上传一个先动态创建块,在插入块参考时有橡皮条效果的例题??
QQ:78250323
EMAILYHNJUCT@163.COM
使用jig好象也可以,我没有尝试过,你先研究研究,我也给你看看
使用jig拖动距离看看是不是能实现,我也是感觉而已
我做过无属性的拖动块,但我认为对属性的定义应在drag();之后append();之前定义则属性在拖动中不可见,除非属性模式是固定,建议为预置。
页:
[1]