- 积分
- 673
- 明经币
- 个
- 注册时间
- 2014-11-18
- 在线时间
- 小时
- 威望
-
- 金钱
- 个
- 贡献
-
- 激情
-
|
本帖最后由 Arthas 于 2014-12-4 16:55 编辑
AcDbDynBlockReferenceProperty:
- ads_name ent;
- ads_point sltpt;
- int ret;
- Acad::ErrorStatus es;
- ret=acedEntSel(_T("\n Selct BlockReference:"), ent,sltpt);
- if (RTNORM!=ret)
- {
- acedAlert(_T("NotSelect"));
- return;
- }
- AcDbObjectId DynBlkId;
- es=acdbGetObjectId(DynBlkId,ent);
- if (Acad::eOk!=es)
- {
- acedAlert(_T("Failed to get entity's ID!"));
- return;
- }
- AcDbDynBlockReference dynblkRef(DynBlkId);
- //////////////////////blkName////////
- AcDbObject* pObj; es = acdbOpenAcDbObject(pObj, DynBlkId , AcDb::kForRead);
- AcDbBlockReference *Reference=AcDbBlockReference::cast(pObj);
- AcDbObjectId refId=Reference->blockTableRecord();
- AcDbBlockTableRecord* pBlkTableRec; es=acdbOpenObject(pBlkTableRec,refId,AcDb::kForRead);
- if(es != Acad::eOk) {acutPrintf(_T("BlockTableRec Open Error?????")); return;}
- const ACHAR* Name; es = pBlkTableRec->getName(Name);
- acutPrintf(_T("Name %s"),Name);
- pObj->close();
-
- ////////////////////////////DynBlkName///////
- AcDbObjectId blockRecordId= dynblkRef.dynamicBlockTableRecord ();
- es = acdbOpenAcDbObject(pObj, blockRecordId , AcDb::kForRead);
- if (es != Acad::eOk) {acutPrintf(_T("dynBlock Table Rec Open Error")); return;}
- AcDbBlockTableRecord* blkTblRec = AcDbBlockTableRecord::cast(pObj);
- ACHAR *effectiveName;
- es=blkTblRec->getName(effectiveName);
- if(es!= Acad::eOk) return;
- acutPrintf(_T("\n Effective Name %s"),effectiveName);
- pObj->close();
- ///////////
- if (!dynblkRef.isDynamicBlock())
- {
- acedAlert(_T("It is not dynamic block reference!"));
- return;
- }
- acutPrintf(_T("\nIt is dynamic block!"));
- AcDbDynBlockReferencePropertyArray propArr;
- dynblkRef.getBlockProperties(propArr);
- acutPrintf(_T("\nThere are %d properities!"),propArr.length());
- for (int i=0;i<propArr.length();++i)
- {
- AcDbDynBlockReferenceProperty prop1=propArr.at(i);
- AcDbEvalVariant evalvar=prop1.value();
- CString strEvalType;
- CString strEval;
- acutPrintf(_T("\n\n Restype %d"),evalvar.restype);
- switch (evalvar.restype)
- {
- case 70:// см. dxfcod (entget)
- strEvalType=_T("int");
- strEval.Format(_T("%d"),evalvar.resval.rint);//
- break;
- case 40 ://
- strEvalType=_T("Double");
- strEval.Format(_T("%g"),evalvar.resval.rreal);
- break;
- case 11 : //
- strEvalType=_T("Point2d");
- strEval.Format(_T("(%.5f,%.5f,0)"),
- evalvar.resval.rpoint[0],
- evalvar.resval.rpoint[1]);
- break;
- case 1 : //
- strEvalType=_T("String");
- strEval.Format(_T("%s"),evalvar.resval.rstring);
- break;
- default : // e.t.c
- strEvalType=_T("unknown");
- }
- acutPrintf(_T("\nproperty : %d"),i+1);
- acutPrintf(_T("\n Name:%s"),prop1.propertyName().constPtr());
- acutPrintf(_T("\n Description : %s"),prop1.description().constPtr());
- acutPrintf(_T("\n Value Type= %s"),strEvalType);
- acutPrintf(_T("\n Value = %s\n"),strEval);
- }
|
|