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社区-威客 mdlText_xxx被TextBlock取代
    • Sign in
    • 中国BDN社区-威客
    • +iTwin.js编程
    • -MicroStation CONNECT版SDK的新变化
      • mdlKISolid_xxx被mdlSolid_xxx取代
      • mdlParams_get/setActive被ActiveParams取代
      • mdlRefFile_getParameters被取代
      • mdlSystem_extExpandCfgVarNoFmt()的替代方案
      • mdlText_xxx被TextBlock取代
      • mdlXXX_setFunction被XXXCallback类取代
      • MSCE开发中请尽量避免使用文件位置(FilePos)
      • 从ISolidKernelEntity直接取得BODY_TAG
    • +MicroStation编程技巧
    • +OpenRoads中国版平台开发指南
    • +ORD SDK二次开发编程
    • +一步步学习ABD-CE开发
    • +一步步学习MicroStation CE Addin开发
    • 一步步学习MicroStation CE MDL开发
    • +一步步学习ProjectWise编程
    • 中国优先社区二次开发精华帖汇总
    • +学习Microstation交互式工具开发
    • +过期帖,留存仅供参考
    • +非Bentley社区分享的文章
    • C#、C/C++相关的编程知识汇总

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

    mdlText_xxx被TextBlock取代

    MSCE SDK中取消了原来V8i下的文字操作来C函数mdlText_xxx,您需要重新学习类TextBlock,它能同时表达文字元素(TextElement)和文字节点元素(TextNodeElement)。

    如下代码是一个典型的通过TextBlock创建一个MSCE下的文字的实例:

    /*--------------------------------------------------------
    | createText
    +-------------------------------------------------------*/
    TextFieldPtr createField(DgnModelR model)
        {
        // "DgnElementSchema" and "ArcElement" are found from ...\MicroStation\ECSchemas\Dgn\DgnElementSchema.01.00.ecschema.xml
        DgnFileP   pDgnFile = ISessionMgr::GetActiveDgnFile();
        //SchemaInfo schemaInfo(ECN::SchemaKey(L"DgnElementSchema", 1, 0), *pDgnFile);
    	SchemaInfo schemaInfo(ECN::SchemaKey(L"DgnCustomItemTypes_Architectural", 1, 0), *pDgnFile);
    	DgnECManagerR ecMan = DgnECManager::GetManager();
    	ECN::ECSchemaPtr pSchema = ecMan.LocateSchemaInDgnFile(schemaInfo, ECN::SchemaMatchType::SCHEMAMATCHTYPE_LatestCompatible);
        if (pSchema == NULL)
    	{
    		mdlDialog_dmsgsPrint(L"Can't find identified schema");
    		return NULL;
    	}
        //ECN::ECClassCR   ecClass = *pSchema->GetClassCP(L"ArcElement");
    	//ECN::ECClassCR   ecClass = *pSchema->GetClassCP(L"LineElement");
    	ECN::ECClassCR   ecClass = *pSchema->GetClassCP(L"Doors");
        
    	ElementId  elemId = 49064L;  // An arc element id
        ElementHandle elem(elemId, &model);
        if (!elem.IsValid())
            return NULL;
        DgnElementECInstancePtr pElemInst = ecMan.FindInstanceOnElement(elem, ecClass);
    
    	//return TextField::CreateForElement(*pElemInst, L"Length", nullptr, model);
        //return TextField::CreateForElement(*pElemInst, L"TotalLength", nullptr, model);
    	return TextField::CreateForElement(*pElemInst, L"Type", nullptr, model);
        }
    
    void createText(WCharCP  unparsed)
        {
        DgnModelP       pActiveModel = ISessionMgr::GetActiveDgnModelP();
        TextBlockPropertiesPtr  pTBProp = TextBlockProperties::Create(*pActiveModel);
        pTBProp->SetIsViewIndependent(true);
        ParagraphPropertiesPtr  pParaProp = ParagraphProperties::Create(*pActiveModel);
        //DgnTextStylePtr         pTextStyle = DgnTextStyle::GetActive();
    	DgnTextStylePtr         pTextStyle = DgnTextStyle::GetByName(L"5mm", StyleIteratorMode::ActiveFileAndLibraries);
        RunPropertiesPtr        pRunProp = RunProperties::Create(*pTextStyle, *pActiveModel);
    	//DPoint2d fontSize = DPoint2d::From(2000, 1000);
    	//pRunProp->SetFontSize(fontSize);
        TextBlockPtr pTextBlock = TextBlock::Create(*pTBProp, *pParaProp, *pRunProp, *pActiveModel);
        pTextBlock->AppendText(L"This is a ViewIndependent text");
    
        //TextFieldPtr pField = createField(*pActiveModel);
        //if (pField != NULL)
        //    pTextBlock->AppendField(*pField);
    
    	//pTextBlock->AppendParagraphBreak();
    	//pTextBlock->AppendText(L"Second Line");
    
        EditElementHandle  eeh;
        if (TEXTBLOCK_TO_ELEMENT_RESULT_Success ==
            TextHandlerBase::CreateElement(eeh, nullptr, *pTextBlock))
            {
    		ElementPropertiesSetterPtr setter = ElementPropertiesSetter::Create();
    		setter->SetColor(3); // 3 -- Red
    		setter->Apply(eeh);
    
            eeh.AddToModel();
            }
        }

    其中注释掉的一些行也都具有特定含义,取消注释能使程序功能更强大,比如,创建带有文字域(TextField)的文字、多行文字等。

    • Share
    • History
    • More
    • Cancel
    • Yongan.Fu Created by Bentley Colleague Yongan.Fu
    • When: Mon, Sep 23 2019 2:12 AM
    • Revisions: 1
    • Comments: 0
    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

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