{"id":16965,"date":"2024-08-10T20:40:37","date_gmt":"2024-08-10T12:40:37","guid":{"rendered":"https:\/\/blog.iyatt.com\/?p=16965"},"modified":"2025-03-23T10:17:42","modified_gmt":"2025-03-23T02:17:42","slug":"objectarx-2025%ef%bc%88c%ef%bc%89%e5%ae%9e%e7%8e%b0%e5%88%9b%e5%bb%ba%e5%8d%95%e8%a1%8c-%e5%a4%9a%e8%a1%8c%e6%96%87%e6%9c%ac","status":"publish","type":"post","link":"https:\/\/blog.iyatt.com\/?p=16965","title":{"rendered":"ObjectARX 2025\uff08C++\uff09\u521b\u5efa\u5355\u884c\u6587\u5b57 AcDbText \u548c \u591a\u884c\u6587\u5b57 AcDbMText"},"content":{"rendered":"<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_82_2 ez-toc-wrap-center counter-hierarchy ez-toc-counter ez-toc-light-blue ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title ez-toc-toggle\" style=\"cursor:pointer\">\u76ee\u5f55<\/p>\n<span class=\"ez-toc-title-toggle\"><a href=\"#\" class=\"ez-toc-pull-right ez-toc-btn ez-toc-btn-xs ez-toc-btn-default ez-toc-toggle\" aria-label=\"Toggle Table of Content\"><span class=\"ez-toc-js-icon-con\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #999;color:#999\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #999;color:#999\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/span><\/a><\/span><\/div>\n<nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-1'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/blog.iyatt.com\/?p=16965\/#%E7%8E%AF%E5%A2%83\" >\u73af\u5883<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-1'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/blog.iyatt.com\/?p=16965\/#%E5%AE%9E%E7%8E%B0\" >\u5b9e\u73b0<\/a><\/li><\/ul><\/nav><\/div>\n<h1><span class=\"ez-toc-section\" id=\"%E7%8E%AF%E5%A2%83\"><\/span>\u73af\u5883<span class=\"ez-toc-section-end\"><\/span><\/h1>\n<p>AutoCAD \u673a\u68b0\u7248 2025<br \/>\nObjectARX 2025<br \/>\nVS 2022<\/p>\n<p>\u73af\u5883\u914d\u7f6e\u53c2\u8003\uff1a<a href=\"https:\/\/blog.iyatt.com\/?p=16480\">https:\/\/blog.iyatt.com\/?p=16480<\/a><br \/>\n\u81ea\u5b9a\u4e49\u7c7b\u4f7f\u7528\u65b9\u6cd5\u53c2\u8003\uff1a<a href=\"https:\/\/blog.iyatt.com\/?p=16635\">https:\/\/blog.iyatt.com\/?p=16635<\/a><\/p>\n<h1><span class=\"ez-toc-section\" id=\"%E5%AE%9E%E7%8E%B0\"><\/span>\u5b9e\u73b0<span class=\"ez-toc-section-end\"><\/span><\/h1>\n<p>Test.hpp<\/p>\n<pre><code class=\"language-cpp\">#pragma once\n\nclass Test\n{\npublic:\n    static void init();\n    static void unload();\n\nprivate:\n    \/**\n     * @brief \u83b7\u53d6\u5757\u8868\u8bb0\u5f55\n     *\/\n    static void getBlockTableRecord();\n\n    \/**\n     * @brief \u91ca\u653e\u5757\u8868\u8bb0\u5f55\u53ca\u56fe\u5f62\u5bf9\u8c61\n     * @param pEntity \u56fe\u5f62\u5bf9\u8c61\n     *\/\n    static void freeBlockTableRecord(AcDbEntity* pEntity);\n\n    \/**\n     * @brief \u63a5\u53d7\u7528\u6237\u7684\u4f4d\u7f6e\u548c\u5185\u5bb9\u8f93\u5165\n     * @param isMultiLine \u63a7\u5236\u662f\u5426\u591a\u884c\u5185\u5bb9\u8f93\u5165\u7684\u6807\u5fd7\n     * @return \u8f93\u5165\u6210\u529f\u5931\u8d25\u72b6\u6001\n     *\/\n    static bool input(bool isMultiLine = false);\n\n    \/**\n     * @brief \u521b\u5efa\u5355\u884c\u6587\u5b57\n     *\/\n    static void createSingleLineText();\n\n    \/**\n     * @brief \u521b\u5efa\u591a\u884c\u6587\u5b57\n     *\/\n    static void createMultiLineText();\n\nprivate:\n    static AcDbBlockTable* mpBlockTable; \/\/ \u5757\u8868\n    static AcDbBlockTableRecord* mpBlockTableRecord; \/\/ \u5757\u8868\u8bb0\u5f55\n    static ads_point mInsertPt; \/\/ \u63d2\u5165\u4f4d\u7f6e\n    static AcString mTextString; \/\/ \u63d2\u5165\u5b57\u7b26\u4e32\n};<\/code><\/pre>\n<p>Test.cpp<\/p>\n<pre><code class=\"language-cpp\">#include &quot;StdAfx.h&quot;\n#include &quot;Test.hpp&quot;\n\nvoid Test::init()\n{\n    acedRegCmds-&gt;addCommand(L&quot;IYATTyxTest&quot;, L&quot;CSLT&quot;, L&quot;CSLT&quot;, ACRX_CMD_MODAL, Test::createSingleLineText);\n    acedRegCmds-&gt;addCommand(L&quot;IYATTyxTest&quot;, L&quot;CMLT&quot;, L&quot;CMLT&quot;, ACRX_CMD_MODAL, Test::createMultiLineText);\n}\n\nvoid Test::unload()\n{\n    acedRegCmds-&gt;removeGroup(L&quot;IYATTyxTest&quot;);\n}\n\nAcDbBlockTable* Test::mpBlockTable = nullptr;\nAcDbBlockTableRecord* Test::mpBlockTableRecord = nullptr;\n\nvoid Test::getBlockTableRecord()\n{\n    if (mpBlockTable == nullptr)\n    {\n        acdbHostApplicationServices()-&gt;workingDatabase()-&gt;getBlockTable(mpBlockTable);\n    }\n    if (mpBlockTableRecord == nullptr)\n    {\n        mpBlockTable-&gt;getAt(ACDB_MODEL_SPACE, mpBlockTableRecord, AcDb::kForWrite);\n    }\n}\n\nvoid Test::freeBlockTableRecord(AcDbEntity* pEntity)\n{\n    if (pEntity != nullptr)\n    {\n        pEntity-&gt;close();\n        pEntity = nullptr;\n    }\n    if (mpBlockTable != nullptr)\n    {\n        mpBlockTable-&gt;close();\n        mpBlockTable = nullptr;\n    }\n    if (mpBlockTableRecord != nullptr)\n    {\n        mpBlockTableRecord-&gt;close();\n        mpBlockTableRecord = nullptr;\n    }\n}\n\nads_point Test::mInsertPt = { 0, 0, 0 };\nAcString Test::mTextString;\n\nbool Test::input(bool isMultiLine)\n{\n    if (acedGetPoint(nullptr, L&quot;\u8bf7\u9009\u62e9\u63d2\u5165\u4f4d\u7f6e\uff1a\\n&quot;, mInsertPt) != RTNORM)\n    {\n        return false;\n    }\n\n    mTextString.setEmpty(); \/\/ \u6e05\u7a7a\u8f93\u5165\u5b57\u7b26\u4e32\u7f13\u5b58\n\n    if (isMultiLine) \/\/ \u591a\u884c\u8f93\u5165\n    {\n        AcString line; \/\/ \u5355\u884c\u8f93\u5165\u7f13\u5b58\n        while (true)\n        {\n            if (acedGetString(Adesk::kTrue, L&quot;\\n\u8bf7\u8f93\u5165\u591a\u884c\u6587\u672c\u5185\u5bb9\uff08\u7a7a\u884c\u7ed3\u675f\uff09\uff1a\\n&quot;, line) != RTNORM)\n            {\n                return false;\n            }\n            if (line.empty()) \/\/ \u7a7a\u884c\u505c\u6b62\u8f93\u5165\n            {\n                break;\n            }\n            mTextString += &quot;\\n&quot;;\n            mTextString += line;\n        }\n    }\n    else\n    {\n        if (acedGetString(Adesk::kTrue, L&quot;\\n\u8bf7\u8f93\u5165\u5355\u884c\u6587\u672c\u5185\u5bb9\uff1a\\n&quot;, mTextString) != RTNORM)\n        {\n            return false;\n        }\n    }\n\n    return true;\n}\n\nvoid Test::createSingleLineText()\n{\n    getBlockTableRecord();\n    if (!Test::input())\n    {\n        acutPrintf(L&quot;\\n\u83b7\u53d6\u7528\u6237\u8f93\u5165\u5931\u8d25\uff0c\u53d6\u6d88\u64cd\u4f5c\u3002\\n&quot;);\n        return;\n    }\n\n    AcDbText* pText = new AcDbText(asPnt3d(mInsertPt), mTextString.kACharPtr()); \/\/ \u521b\u5efa\u5355\u884c\u6587\u5b57\u5bf9\u8c61\n    mpBlockTableRecord-&gt;appendAcDbEntity(pText); \/\/ \u6dfb\u52a0\u5230\u5757\u8868\u8bb0\u5f55\u4e2d\n\n    freeBlockTableRecord(pText);\n}\n\nvoid Test::createMultiLineText()\n{\n    getBlockTableRecord();\n    if (!Test::input(true))\n    {\n        acutPrintf(L&quot;\\n\u83b7\u53d6\u7528\u6237\u8f93\u5165\u5931\u8d25\uff0c\u53d6\u6d88\u64cd\u4f5c\u3002\\n&quot;);\n        return;\n    }\n\n    AcDbMText* pMText = new AcDbMText(); \/\/ \u521b\u5efa\u591a\u884c\u6587\u5b57\u5bf9\u8c61\n    pMText-&gt;setContents(mTextString.kACharPtr());\n    pMText-&gt;setLocation(asPnt3d(mInsertPt));\n    mpBlockTableRecord-&gt;appendAcDbEntity(pMText); \/\/ \u6dfb\u52a0\u5230\u5757\u8868\u8bb0\u5f55\u4e2d\n\n    freeBlockTableRecord(pMText);\n}<\/code><\/pre>\n<p>\u6d4b\u8bd5 CSLT \u547d\u4ee4\u521b\u5efa\u5355\u884c\u6587\u672c<br \/>\n<img decoding=\"async\" data-src=\"https:\/\/blog.iyatt.com\/wp-content\/uploads\/2024\/08\/image-1723293240337.png\" alt=\"file\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" class=\"lazyload\" style=\"--smush-placeholder-width: 550px; --smush-placeholder-aspect-ratio: 550\/370;\" \/><\/p>\n<p><img decoding=\"async\" data-src=\"https:\/\/blog.iyatt.com\/wp-content\/uploads\/2024\/08\/image-1723293251641.png\" alt=\"file\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" class=\"lazyload\" style=\"--smush-placeholder-width: 290px; --smush-placeholder-aspect-ratio: 290\/127;\" \/><\/p>\n<p>\u6d4b\u8bd5 CMLT \u547d\u4ee4\u521b\u5efa\u591a\u884c\u6587\u672c<br \/>\n<img decoding=\"async\" data-src=\"https:\/\/blog.iyatt.com\/wp-content\/uploads\/2024\/08\/image-1723293329758.png\" alt=\"file\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" class=\"lazyload\" style=\"--smush-placeholder-width: 405px; --smush-placeholder-aspect-ratio: 405\/193;\" \/><\/p>\n<p>\uff08\u516c\u5dee\u7528\u5927\u62ec\u53f7\u62ec\u8d77\u6765\uff0c\\H\u6307\u5b9a\u516c\u5dee\u90e8\u5206\u76f8\u5bf9\u5b57\u4f53\u7684\u5927\u5c0f\u6bd4\u4f8b\uff0c\\C\u6307\u5b9a\u989c\u8272\u503c\uff0c\\S\u6307\u5b9a\u516c\u5dee\u5185\u5bb9\u3002\u591a\u884c\u6587\u5b57\u4e2d\u4f1a\u81ea\u52a8\u8f6c\u6362\u683c\u5f0f\u663e\u793a\u3002\uff09<br \/>\n<img decoding=\"async\" data-src=\"https:\/\/blog.iyatt.com\/wp-content\/uploads\/2024\/08\/image-1723303825100.png\" alt=\"file\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" class=\"lazyload\" style=\"--smush-placeholder-width: 992px; --smush-placeholder-aspect-ratio: 992\/445;\" \/><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u73af\u5883 AutoCAD \u673a\u68b0\u7248 2025 ObjectARX 2025 VS 2022 \u73af\u5883\u914d\u7f6e\u53c2\u8003\uff1ahttps [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"zakra_page_container_layout":"customizer","zakra_page_sidebar_layout":"customizer","zakra_remove_content_margin":false,"zakra_sidebar":"customizer","zakra_transparent_header":"customizer","zakra_logo":0,"zakra_main_header_style":"default","zakra_menu_item_color":"","zakra_menu_item_hover_color":"","zakra_menu_item_active_color":"","zakra_menu_active_style":"","zakra_page_header":true,"_lmt_disableupdate":"no","_lmt_disable":"no","footnotes":""},"categories":[1,616,589,618,621],"tags":[],"class_list":["post-16965","post","type-post","status-publish","format-standard","hentry","category-all","category-autocad","category-c-c","category-cad-cam","category-objectarx"],"modified_by":"IYATT-yx","_links":{"self":[{"href":"https:\/\/blog.iyatt.com\/index.php?rest_route=\/wp\/v2\/posts\/16965","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.iyatt.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.iyatt.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.iyatt.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.iyatt.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=16965"}],"version-history":[{"count":2,"href":"https:\/\/blog.iyatt.com\/index.php?rest_route=\/wp\/v2\/posts\/16965\/revisions"}],"predecessor-version":[{"id":19652,"href":"https:\/\/blog.iyatt.com\/index.php?rest_route=\/wp\/v2\/posts\/16965\/revisions\/19652"}],"wp:attachment":[{"href":"https:\/\/blog.iyatt.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=16965"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.iyatt.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=16965"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.iyatt.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=16965"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}