新建ECShema,ImportSchema调试出错

我新建一个ECSchema,并新建一个ECClass,添加两个属性,然后我用ImportSchema导入到dgn出错,

dgnOpenStatus值是DGNOPEN_STATUS_UnrecognizedFormat,为什么呢,老师们能帮我解答下吗?

代码如下:
 

DgnFilePtr    openForWrite(WString filename, DgnFileOpenMode mode)
{
 DgnDocumentPtr dgnDoc = DgnDocument::CreateForLocalFile(filename.c_str());
 RefCountedPtr<DgnFile> dgnFile = DgnFile::Create(*dgnDoc, mode);
 StatusInt                   openForWriteStatus;
 DgnPlatform::DgnFileStatus  dgnOpenStatus = dgnFile->LoadDgnFile(&openForWriteStatus);
 if (DGNFILE_STATUS_Success != dgnOpenStatus)
  return NULL;
 dgnFile->FillDictionaryModel();
 return dgnFile;
}


void newECClass(WCharCP unused)
{
 WCharCP stringP = L"新建ECClass测试!";
 mdlDialog_openInfoBox(stringP);


 //新建一个ECClass
 DgnFilePtr dgnFile = openForWrite(gOptions.fileName, DgnFileOpenMode::ReadWrite);
 if (dgnFile.IsValid())
 {
  DgnECManagerR dgnECManager = DgnECManager::GetManager();
  ECN::ECSchemaPtr pSchema;
  WCharCP schemaName = L"schema_zqh";
  dgnECManager.CreateSchema(pSchema, schemaName, 1, 0, dgnFile.get());

  ECN::ECSchema *schemaP = pSchema.get();
  WString name = schemaP->GetName();
  ECN::SchemaKey ss = schemaP->GetSchemaKey();
  ECClassP zqhClass;
  WString className = L"zqhClassName";
  schemaP->CreateClass(zqhClass, className);

  //ECProperty  StructECProperty PrimitiveECProperty
  PrimitiveECPropertyP ecpProperty;
  WString priProName = L"priProName";
  StructECPropertyP ecsProperty;
  WString struProName = L"struProName";
  zqhClass->CreatePrimitiveProperty(ecpProperty, priProName);
  zqhClass->CreateStructProperty(ecsProperty, struProName);
  dgnECManager.UpdateSchema(*pSchema, *dgnFile, false);
  dgnECManager.ImportSchema(*pSchema, *dgnFile, false, true);
 }
}

  • 噢 明白了,另外,我还有个问题 我在用ECProperty::SetTypeName时,sdk说明“Sets the ECXML typename for the property. ”,这个ECXML typename 的定义我从哪能找到,谢谢符老师
  •     PrimitiveECPropertyP binaryProperty;
        PrimitiveECPropertyP booleanProperty;
        PrimitiveECPropertyP dateTimeProperty;
        PrimitiveECPropertyP doubleProperty;
        PrimitiveECPropertyP integerProperty;
        PrimitiveECPropertyP longProperty;
        PrimitiveECPropertyP point2DProperty;
        PrimitiveECPropertyP point3DProperty;
        
        class1->CreatePrimitiveProperty(binaryProperty, L"BinaryProp");
        class1->CreatePrimitiveProperty(booleanProperty, L"BooleanProp");
        class1->CreatePrimitiveProperty(dateTimeProperty, L"DateTimeProp");
        class1->CreatePrimitiveProperty(doubleProperty, L"DoubleProp");
        class1->CreatePrimitiveProperty(integerProperty, L"IntProp");
        class1->CreatePrimitiveProperty(longProperty, L"LongProp");
        class1->CreatePrimitiveProperty(point2DProperty, L"Point2DProp");
        class1->CreatePrimitiveProperty(point3DProperty, L"Point3DProp");
    
        binaryProperty->SetTypeName (L"binary");
        booleanProperty->SetTypeName (L"boolean");
        dateTimeProperty->SetTypeName (L"dateTime");
        doubleProperty->SetTypeName (L"double");
        integerProperty->SetTypeName (L"int");
        longProperty->SetTypeName (L"long");
        point2DProperty->SetTypeName (L"point2d");
        point3DProperty->SetTypeName (L"point3d");



  • 应该还有string IGeometry之类的吧 我不太清楚哪些变量可以设置的 好像也没看到说明 是不是基本的数据类型都可以?
  • 付老师 我撤销取消CreateStructProperty后,还是报同样的错呢?您看 是不是我取消错误了