Bentley Communities
Bentley Communities
  • Site
  • User
  • Site
  • Search
  • User
  • Welcome
  • Products
  • Support
  • About
  • More
  • Cancel
中国BDN社区
  • Welcome to Bentley Communities
  • Bentley's Communities
  • 中国BDN社区
  • More
  • Cancel
中国BDN社区
中国BDN社区-威客 显示元素的描述(Display Element's Description)
    • Sign in
    中国BDN社区 requires membership for participation - click to join
    • 中国BDN社区-威客
    • C#、C/C++相关的编程知识汇总
    • +iTwin.js编程
    • +MicroStation CONNECT版SDK的新变化
    • -MicroStation编程技巧
      • C#中调用ECNameValidation.EncodeToValidName
      • ms中make编译过程梳理
      • 如果在.r资源文件中设置可贴边的(Dockable)对话框?
      • 显示元素的描述(Display Element's Description)
      • 调用BuildAgenda时如何获取参考模型中的元素
    • +Mircrostation Python 开发
    • +OpenRoads中国版平台开发指南
    • +ORD SDK二次开发编程
    • +一步步学习ABD-CE开发
    • +一步步学习MicroStation CE Addin开发
    • 一步步学习MicroStation CE MDL开发
    • +一步步学习ProjectWise编程
    • 中国优先社区二次开发精华帖汇总
    • +学习Microstation交互式工具开发
    • +用户分享的文章
    • +过期帖,留存仅供参考

     
     Questions about this article, topic, or product? Click here. 

    显示元素的描述(Display Element's Description)

    我们在编程过程中能容易地得到元素的ElementID和Type,但这个Type是一个数字,仅从该数字很难知道它到底是个什么类型的元素,还需要通过手工查SDK中的头文件来确定。那能否在编程中直接以文字来显示这个元素的类型呢?答案是肯定的。

    如下代码查看当前DGN中的数据字典部分,列出数据字典中控制元素的名称、类型及其元素ID。该代码在MicroStation CONNECT版EAP3上调试通过,如果您的开发环境仍在MicroStation V8i下,本代码虽不能直接使用,但也应该具有借鉴意义。

    void fileAnalyze(WCharCP unparsed)
        {
        DgnFileP pDgnFile = ISessionMgr::GetManager().GetActiveDgnFile();
        DgnModelR dictionaryModel = pDgnFile->GetDictionaryModel();
        WString myString, elDescr;
        PersistentElementRefList *pElemRefList = dictionaryModel.GetControlElementsP();
        for (PersistentElementRefP const& elemRef : *pElemRefList)
            {
            ElementHandle eh(elemRef);
            eh.GetHandler().GetDescription(eh, elDescr, 100);
            myString.Sprintf(L"ElemType = %s(%d), ElementId=%d", 
                elDescr.GetWCharCP(), elemRef->GetElementType(), elemRef->GetElementId());
            mdlDialog_dmsgsPrint(myString.GetWCharCP());
            }
        }

    运行结果如下:

    核心函数就是ElementHandle.GetHandler().GetDescription()。

    • Share
    • History
    • More
    • Cancel
    • Yongan.Fu Created by Bentley Colleague Yongan.Fu
    • When: Fri, Jun 19 2015 5:54 AM
    • Yongan.Fu Last revision by Bentley Colleague Yongan.Fu
    • When: Tue, Oct 23 2018 5:04 AM
    • Revisions: 7
    • Comments: 1
    Recommended
    Related
    Communities
    • Home
    • Getting Started
    • Community Central
    • Products
    • Support
    • Secure File Upload
    • Feedback
    Support and Services
    • Home
    • Product Support
    • Downloads
    • Subscription Services Portal
    Training and Learning
    • Home
    • About Bentley Institute
    • My Learning History
    • Reference Books
    Social Media
    •    LinkedIn
    •    Facebook
    •    Twitter
    •    YouTube
    •    RSS Feed
    •    Email

    © 2021 Bentley Systems, Incorporated  |  Contact Us  |  Privacy |  Terms of Use  |  Cookies