|
///设置块参照的自定义属性
bool SetCustomParam(const AcDbObjectId& idBlkRef,const std::map<CString, CString>& mapParam)
{
AcDbDynBlockReferencePropertyArray DynBlkRefPropArray; //动态块参照属性数组
AcDbDynBlockReference DynBlkRef(idBlkRef); //动态块参照对象
DynBlkRef.getBlockProperties(DynBlkRefPropArray);
AcDbDynBlockReferenceProperty DynBlockReferenceProp; //动态块参照属性
std::map<CString, CString>::const_iterator iter;
for (iter = mapParam.begin(); iter != mapParam.end(); ++iter)
{
CString strKey = iter->first;
CString strValue = iter->second;
for (int i = 0; i < DynBlkRefPropArray.length(); i++)
{
DynBlockReferenceProp = DynBlkRefPropArray.at(i);
bool bShow = DynBlockReferenceProp.show(); //是否在面板中显示
if (false == bShow && DynBlockReferenceProp.readOnly() == true)
continue;
CString strName = DynBlockReferenceProp.propertyName().kwszPtr(); //属性名
if (strName != strKey)
continue;
auto type = DynBlockReferenceProp.propertyType(); //属性类型
if (DwgDataType::kDwgText == type)
{
AcDbEvalVariant value(strValue);
DynBlockReferenceProp.setValue(value);
}
else if (DwgDataType::kDwgReal == type)
{
AcDbEvalVariant value(_wtof(strValue));
DynBlockReferenceProp.setValue(value);
}
}
}
return true;
} |
|