200元求一段修改插入基点的ARX代码
要求修改一个包含属性定义的图块的基点,只需贴出关键代码即可。 这么久了还需要吗,我可以帮你写,QQ974636923 static void fjbylongArxProject1test(void){
// Add your code for command fjbylongArxProject1.test here
//更改属性块插入点示例
//运行命令test→选中属性块→将块的基点改为p1(0.0 0.0 0.0),
//所有属性的基点(如果不是所有属性仅需加一条tag判断)改为p2(1.0 1.0 1.0)---根据需要自行调整
ads_name ename;ads_point pt;
//强制要求选择一个对象,按ESC退出
int sta=ads_entsel(_T("\n请选择属性块:"),ename,pt);
while (sta!=RTNORM)
{
if (sta==RTCAN)
return;
sta=ads_entsel(_T("\n请选择属性块:"),ename,pt);
}
AcDbObjectId id1,id2;
acdbGetObjectId(id1,ename);
AcDbEntity *pEnt;
acdbOpenAcDbEntity(pEnt,id1,AcDb::kForWrite,false);
AcDbBlockReference *pBlkRef=AcDbBlockReference::cast(pEnt);
if (pBlkRef==NULL)
{
acedPrompt(L"\n所选图形不是块参照");
return;
}
id2=pBlkRef->blockTableRecord();
AcDbBlockTableRecord *pBlkTblRcd;
acdbOpenObject(pBlkTblRcd,id2,AcDb::kForWrite);
AcGePoint3d p1(0.0,0.0,0.0),p2(30.0,30.0,0.0);
pBlkTblRcd->setOrigin(p1);
ACHAR *pName;
pBlkTblRcd->getName(pName);
if (pBlkTblRcd->hasAttributeDefinitions())
{
AcDbBlockTableRecordIterator *pItr;
pBlkTblRcd->newIterator(pItr);
AcDbEntity *pEnt2;
for (pItr->start(); !pItr->done(); pItr->step())
{
pItr->getEntity(pEnt2, AcDb::kForWrite);
// 检查是否是属性定义
AcDbAttributeDefinition *pAttDef;
pAttDef = AcDbAttributeDefinition::cast(pEnt2);//pAttDef不用关闭
if (pAttDef != NULL)
{
pAttDef->setPosition(p2);
pAttDef->close();
}
pEnt2->close();//pEnt2定义在for外面,关闭在for内
}
delete pItr;
}
pEnt->close();
pBlkRef->close();
pBlkTblRcd->close();
acedCommand(RTSTR,_T("ATTSYNC"),RTSTR,_T("N"),RTSTR,pName,0);//同步属性块
acedSSFree(ename);
}
页:
[1]