{"id":16912,"date":"2024-08-07T17:28:41","date_gmt":"2024-08-07T09:28:41","guid":{"rendered":"https:\/\/blog.iyatt.com\/?p=16912"},"modified":"2025-03-23T10:33:00","modified_gmt":"2025-03-23T02:33:00","slug":"objectarx-2025%ef%bc%88c%ef%bc%89%e5%ae%9e%e7%8e%b0%e5%b0%86%e9%a2%9c%e8%89%b2%e3%80%81%e7%ba%bf%e5%9e%8b%e5%92%8c%e7%ba%bf%e5%ae%bd%e6%94%b9%e4%b8%ba-bylayer%ef%bc%88%e5%be%85%e5%86%99%ef%bc%89","status":"publish","type":"post","link":"https:\/\/blog.iyatt.com\/?p=16912","title":{"rendered":"ObjectARX 2025\uff08C++\uff09\u5b9e\u73b0\u5c06\u989c\u8272\u3001\u7ebf\u578b\u548c\u7ebf\u5bbd\u6539\u4e3a ByLayer"},"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=16912\/#%E9%9C%80%E6%B1%82\" >\u9700\u6c42<\/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=16912\/#%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-3\" href=\"https:\/\/blog.iyatt.com\/?p=16912\/#%E5%AE%9E%E7%8E%B0\" >\u5b9e\u73b0<\/a><\/li><\/ul><\/nav><\/div>\n<h1><span class=\"ez-toc-section\" id=\"%E9%9C%80%E6%B1%82\"><\/span>\u9700\u6c42<span class=\"ez-toc-section-end\"><\/span><\/h1>\n<p>\u6211\u8fd9\u8fb9\u5728\u505a\u673a\u52a0\u5de5\u5de5\u827a\u8bbe\u8ba1\u7684\u65f6\u5019\uff0c\u7ecf\u5e38\u9700\u8981\u6839\u636e\u5ba2\u6237\u63d0\u4f9b\u7684\u4e09\u7ef4\u6a21\u578b\u5bfc\u51fa AutoCAD \u5de5\u7a0b\u56fe\u6765\u7f16\u5236\uff0c\u7528 SolidWorks \u5bfc\u51fa\u7684\u56fe\u7eb8\u7ebf\u6761\u7684\u989c\u8272\u3001\u7ebf\u578b\u548c\u7ebf\u5bbd\u90fd\u662f\u7279\u5b9a\u503c\uff0c\u800c\u4e0d\u662f ByLayer\uff08\u8ddf\u968f\u56fe\u5c42\uff09\u3002\u6211\u5728\u7f16\u5236\u5de5\u827a\u7684\u65f6\u5019\u4f1a\u5bf9\u52a0\u5de5\u9762\u3001\u975e\u52a0\u5de5\u9762\u3001\u5256\u9762\u586b\u5145\u7b49\u4f7f\u7528\u6211\u81ea\u5df1\u5b9a\u4e49\u7684\u56fe\u5c42\uff0c\u4f46\u662f\u5fc5\u987b\u8981\u628a\u5404\u9879\u5c5e\u6027\u6539\u6210 ByLayer \u624d\u80fd\u8ba9\u5916\u89c2\u8ddf\u968f\u56fe\u5c42\u663e\u793a\uff0c\u8fd9\u6837\u6211\u81ea\u5b9a\u4e49\u7684\u56fe\u5c42\u624d\u6709\u5b9e\u9645\u4f5c\u7528\u3002\u53ea\u662f\u6bcf\u6b21\u90fd\u8981\u624b\u52a8\u5206\u4e09\u6b21\u8bbe\u7f6e\u8fd9\u4e09\u79cd\u5c5e\u6027\u8fd8\u662f\u663e\u5f97\u9ebb\u70e6\uff0c\u56e0\u6b64\u60f3\u8981\u505a\u4e00\u4e2a\u6269\u5c55\u7a0b\u5e8f\u5b9e\u73b0\u4e00\u6b21\u6027\u5b8c\u6210\u4fee\u6539\u3002<\/p>\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>ChangePropertiesToByLayer.hpp<\/p>\n<pre><code class=\"language-cpp\">#pragma once\n\nclass ChangePropertiesToByLayer\n{\npublic:\n    static void init();\n    static void unload();\n\nprivate:\n    static void change();\n};<\/code><\/pre>\n<p>ChangePropertiesToByLayer.cpp<\/p>\n<pre><code class=\"language-cpp\">#include &quot;StdAfx.h&quot;\n#include &quot;ChangePropertiesToByLayer.hpp&quot;\n\nvoid ChangePropertiesToByLayer::init()\n{\n    \/\/ \u6ce8\u518c\u547d\u4ee4 CPTBL\uff08change properties to ByLayer)\n    acedRegCmds-&gt;addCommand(L&quot;IYATTyxTools&quot;, L&quot;CPTBL&quot;, L&quot;CPTBL&quot;, ACRX_CMD_MODAL, ChangePropertiesToByLayer::change);\n}\n\nvoid ChangePropertiesToByLayer::unload()\n{\n    acedRegCmds-&gt;removeGroup(L&quot;IYATTyxTools&quot;);\n}\n\nvoid ChangePropertiesToByLayer::change()\n{\n    acutPrintf(L&quot;\u529f\u80fd\uff1a\u4fee\u6539\u9009\u4e2d\u5bf9\u8c61\u7684\u989c\u8272\u3001\u7ebf\u578b\u3001\u7ebf\u5bbd\u4e3a ByLayer\uff0c\u4fee\u6539\u7ebf\u578b\u6bd4\u4f8b\u4e3a 1\u3002&quot;);\n    ads_name ss = { 0, 0 }; \/\/ \u9009\u62e9\u96c6\n    int ret = acedSSGet(nullptr, nullptr, nullptr, nullptr, ss); \/\/ \u83b7\u53d6\u7528\u6237\u9009\u62e9\u7684\u5bf9\u8c61\u96c6\n    if (ret != RTNORM)\n    {\n        acutPrintf(L&quot;\\n\u6ca1\u6709\u9009\u4e2d\u4efb\u4f55\u5bf9\u8c61\u3002&quot;);\n        return;\n    }\n\n    Adesk::Int32 length = 0; \/\/ \u9009\u62e9\u96c6\u957f\u5ea6\n    acedSSLength(ss, &amp;length); \/\/ \u83b7\u53d6\u9009\u62e9\u96c6\u7684\u957f\u5ea6\n\n    for (Adesk::Int32 i = 0; i &lt; length; ++i) \/\/ \u904d\u5386\u9009\u62e9\u96c6\n    {\n        ads_name name = { 0, 0 }; \/\/ \u5bf9\u8c61\u540d\n        acedSSName(ss, i, name); \/\/ \u83b7\u53d6\u9009\u62e9\u96c6\u4e2d\u7684\u7b2c i \u4e2a\u5bf9\u8c61\u540d\n\n        AcDbObjectId objId; \/\/ \u5bf9\u8c61ID\n        acdbGetObjectId(objId, name); \/\/ \u83b7\u53d6\u5bf9\u8c61 ID\n\n        AcDbObject* pObj = nullptr; \/\/ \u5bf9\u8c61\u6307\u9488\n        acdbOpenAcDbObject(pObj, objId, AcDb::kForWrite); \/\/ \u4ee5\u5199\u6743\u9650\u6253\u5f00\u5bf9\u8c61\n\n        AcDbEntity* pEntity = AcDbEntity::cast(pObj); \/\/ \u5f3a\u5236\u8f6c\u6362\u4e3a\u5b9e\u4f53\u5bf9\u8c61\n        if (pEntity != nullptr)\n        {\n            \/\/ pEntity-&gt;setColorIndex(256);  \/\/ \u989c\u8272\u8bbe\u7f6e\u4e3a ByLayer\n            AcCmColor color;\n            color.setByLayer();\n            pEntity-&gt;setColor(color);\n\n            pEntity-&gt;setLinetype(L&quot;ByLayer&quot;); \/\/ \u7ebf\u578b\u8bbe\u7f6e\u4e3a ByLayer\n            pEntity-&gt;setLinetypeScale(1.0);  \/\/ \u53ef\u9009\uff0c\u9ed8\u8ba4\u7ebf\u578b\u6bd4\u4f8b\n            pEntity-&gt;setLineWeight(AcDb::kLnWtByLayer); \/\/ \u7ebf\u5bbd\u8bbe\u7f6e\u4e3a ByLayer\n\n            pEntity-&gt;downgradeOpen(); \/\/ \u5c06\u5bf9\u8c61\u6539\u4e3a\u53ea\u8bfb\u6a21\u5f0f\n        }\n        pObj-&gt;close(); \/\/ \u5173\u95ed\u5bf9\u8c61\n    }\n\n    acedSSFree(ss); \/\/ \u91ca\u653e\u9009\u62e9\u96c6\n    acutPrintf(L&quot;\u9009\u4e2d\u5bf9\u8c61\u5df2\u4fee\u6539\u5c5e\u6027\u4e3a ByLayer\u3002&quot;);\n}<\/code><\/pre>\n<hr \/>\n<p>\u6f14\u793a\uff1a<br \/>\n\u7ed8\u5236\u4e86\u4e09\u6761\u76f4\u7ebf\uff0c\u90fd\u4fee\u6539\u4e86\u989c\u8272\u3001\u7ebf\u578b\u548c\u7ebf\u5bbd\uff0c\u5176\u4e2d\u4e00\u6761\u8fd8\u4fee\u6539\u4e86\u7ebf\u578b\u6bd4\u4f8b<br \/>\n<img decoding=\"async\" data-src=\"https:\/\/blog.iyatt.com\/wp-content\/uploads\/2024\/08\/image-1723032370524.png\" alt=\"file\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" class=\"lazyload\" style=\"--smush-placeholder-width: 1531px; --smush-placeholder-aspect-ratio: 1531\/731;\" \/><\/p>\n<p>\u6267\u884c CPTBL \u547d\u4ee4\uff0c\u9009\u62e9\u56fe\u4e0a\u7684\u5bf9\u8c61\uff0c\u786e\u8ba4\u547d\u4ee4\u4fee\u6539<br \/>\n<img decoding=\"async\" data-src=\"https:\/\/blog.iyatt.com\/wp-content\/uploads\/2024\/08\/image-1723032754646.png\" alt=\"file\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" class=\"lazyload\" style=\"--smush-placeholder-width: 612px; --smush-placeholder-aspect-ratio: 612\/126;\" \/><br \/>\n<img decoding=\"async\" data-src=\"https:\/\/blog.iyatt.com\/wp-content\/uploads\/2024\/08\/image-1723032455680.png\" alt=\"file\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" class=\"lazyload\" style=\"--smush-placeholder-width: 1456px; --smush-placeholder-aspect-ratio: 1456\/986;\" \/><br \/>\n<img decoding=\"async\" data-src=\"https:\/\/blog.iyatt.com\/wp-content\/uploads\/2024\/08\/image-1723032565098.png\" alt=\"file\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" class=\"lazyload\" style=\"--smush-placeholder-width: 370px; --smush-placeholder-aspect-ratio: 370\/154;\" \/><br \/>\n<img decoding=\"async\" data-src=\"https:\/\/blog.iyatt.com\/wp-content\/uploads\/2024\/08\/image-1723032496118.png\" alt=\"file\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" class=\"lazyload\" style=\"--smush-placeholder-width: 1595px; --smush-placeholder-aspect-ratio: 1595\/714;\" \/><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u9700\u6c42 \u6211\u8fd9\u8fb9\u5728\u505a\u673a\u52a0\u5de5\u5de5\u827a\u8bbe\u8ba1\u7684\u65f6\u5019\uff0c\u7ecf\u5e38\u9700\u8981\u6839\u636e\u5ba2\u6237\u63d0\u4f9b\u7684\u4e09\u7ef4\u6a21\u578b\u5bfc\u51fa AutoCAD \u5de5\u7a0b\u56fe\u6765\u7f16\u5236\uff0c\u7528 S [&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,621,575],"tags":[],"class_list":["post-16912","post","type-post","status-publish","format-standard","hentry","category-all","category-autocad","category-objectarx","category-575"],"modified_by":"IYATT-yx","_links":{"self":[{"href":"https:\/\/blog.iyatt.com\/index.php?rest_route=\/wp\/v2\/posts\/16912","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=16912"}],"version-history":[{"count":3,"href":"https:\/\/blog.iyatt.com\/index.php?rest_route=\/wp\/v2\/posts\/16912\/revisions"}],"predecessor-version":[{"id":19656,"href":"https:\/\/blog.iyatt.com\/index.php?rest_route=\/wp\/v2\/posts\/16912\/revisions\/19656"}],"wp:attachment":[{"href":"https:\/\/blog.iyatt.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=16912"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.iyatt.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=16912"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.iyatt.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=16912"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}