XData
これはCAD
、ユーザー(プログラマー)が利用できる機能的なインターフェイスですCAD
。個人情報をエンティティに書き込んだりバインドしたり、CAD
無視したり管理したりできますが、DXF
ファイルに保存することもできます。同時に、これらの個人情報を読んでプログラミングを容易にすることもできます。
QCAD
dxf
ファイルの読み取りと書き込みに使用されますdxflib
。以下に示すように、dxflib
書き込み拡張属性を使用します。
dw.dxfString(1001,"Point");
dw.dxfString(1002,"{");
dw.dxfString(1000,"代码");
dw.dxfString(1000,"201365845");
dw.dxfString(1002,"}");
ではQCAD
、ソースコード、あなただけの必要なDXF
時に読み取りおよび書き込み拡張属性(カスタム属性)を追加するにはリーディング、ライティング。
属性を書き込む
// dw.dxfString(1001,"Point");
// dw.dxfString(1000,"代码:201365845");
void RDxfExporter::writeCustomProperties(const REntity& p)
{
QMap<QString, QVariantMap>customProperties=p.getCustomProperties();
QString kv;
foreach (QString title, customProperties.keys()) {
QVariantMap properties=customProperties.value(title);
dw->dxfString(1001, (const char*)RDxfExporter::escapeUnicode(title));
foreach (const QString key, properties.keys()) {
QVariant value=properties.value(key);
kv=QString("%1:%2").arg(key,value.toString());
dw->dxfString(1000,(const char*)RDxfExporter::escapeUnicode(kv));
}
}
}
属性を読み込む
void RDxfImporter::importXData(QSharedPointer<REntity> entity)
{
QStringList pJson;
QString str;
QPair<int,QVariant>p;
foreach (const QString group, xData.keys()) {
QList<QPair<int, QVariant>> properties=xData.value(group);
for(int i=0;i<properties.size();++i){
p=properties.at(i);
str=p.second.toString();
if(str.contains(':')){
pJson=str.split(":");
if(pJson.length()>1)
entity->setProperty(RPropertyTypeId(group,pJson[0]),pJson[1]);
}
}
}
}
このようにして、QCAD属性編集パネルでカスタム拡張属性を追加できます。
DXFファイルに保存された属性: