{"id":19634,"date":"2025-03-17T20:53:03","date_gmt":"2025-03-17T12:53:03","guid":{"rendered":"https:\/\/blog.iyatt.com\/?p=19634"},"modified":"2025-03-23T10:16:10","modified_gmt":"2025-03-23T02:16:10","slug":"objectarx-2025%ef%bc%88c%ef%bc%89%e7%bb%98%e5%88%b6%e5%9c%86%e5%bc%a7","status":"publish","type":"post","link":"https:\/\/blog.iyatt.com\/?p=19634","title":{"rendered":"ObjectARX 2025\uff08C++\uff09\u7ed8\u5236\u5706\u5f27 AcDbArc"},"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=19634\/#%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=19634\/#%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\uff08ISO C++14\uff09<\/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><\/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>Arc.hpp<\/p>\n<pre><code class=\"language-cpp\">#pragma once\nclass Arc\n{\npublic:\n    static void work();\n\nprivate:\n    static void drawArc(AcDbArc* arcObj);\n};<\/code><\/pre>\n<p>Arc.cpp<\/p>\n<pre><code class=\"language-cpp\">#include &quot;stdafx.h&quot;\n#include &quot;Arc.hpp&quot;\n\nvoid Arc::drawArc(AcDbArc* arcObj)\n{\n    AcDbBlockTable* pBlockTable = nullptr;\n    acdbHostApplicationServices()-&gt;workingDatabase()-&gt;getBlockTable(pBlockTable, AcDb::kForRead);\n    AcDbBlockTableRecord* pBlockTableRecord = nullptr;\n    pBlockTable-&gt;getAt(ACDB_MODEL_SPACE, pBlockTableRecord, AcDb::kForWrite);\n    pBlockTableRecord-&gt;appendAcDbEntity(arcObj);\n    pBlockTableRecord-&gt;close();\n    pBlockTable-&gt;close();\n}\n\nvoid Arc::work()\n{\n    \/\/ \u4e8c\u7ef4\u5e73\u9762\u5411\u91cf\n    AcGeVector3d normal(0, 0, 1);\n\n    \/\/ \u5706\u5fc3\u3001\u534a\u5f84\u3001\u8d77\u59cb\u89d2\u5ea6\u3001\u7ed3\u675f\u89d2\u5ea6\n    {\n        AcGePoint3d center(0, 0, 0);\n        double radius = 50;\n        double startAngle = 0;\n        double endAngle = 3.1415926 * 3 \/ 2;\n\n        AcDbArc* arcObj = new AcDbArc(center, normal, radius, startAngle, endAngle);\n        Arc::drawArc(arcObj);\n        arcObj-&gt;close();\n    }\n\n    \/\/ \u4e09\u70b9\n    {\n        AcGePoint2d startPt(0, 0);\n        AcGePoint2d endPt(50, 50);\n        AcGePoint2d otherPt(100, 0);\n\n        \/\/ \u83b7\u53d6\u5706\u5fc3\u3001\u534a\u5f84\n        AcGeCircArc2d geArc(startPt, endPt, otherPt);\n        AcGePoint2d center = geArc.center();\n        double radius = geArc.radius();\n\n        \/\/ \u83b7\u53d6\u8d77\u59cb\u89d2\u5ea6\u3001\u7ed3\u675f\u89d2\u5ea6\n        AcGeVector2d startVec(startPt.x - center.x, startPt.y - center.y);\n        double startAngle = startVec.angle();\n        AcGeVector2d endVec(endPt.x - center.x, endPt.y - center.y);\n        double endAngle = endVec.angle();\n\n        AcDbArc* arcObj = new AcDbArc(AcGePoint3d(center.x, center.y, 0), normal, radius, startAngle, endAngle);\n        Arc::drawArc(arcObj);\n        arcObj-&gt;close();\n    }\n\n    \/\/ \u5706\u5fc3\u3001\u8d77\u70b9\u3001\u89d2\u5ea6\n    {\n        AcGePoint2d startPt(20, 20);\n        AcGePoint2d center(0, 0);\n        double angle = 3.1415926 * 0.5;\n\n        \/\/ \u8ba1\u7b97\u534a\u5f84\n        double radius = startPt.distanceTo(center);\n\n        \/\/ \u8d77\u70b9\u3001\u7ec8\u70b9\u89d2\u5ea6\n        AcGeVector2d startVec(startPt.x - center.x, startPt.y - center.y);\n        double startAngle = startVec.angle();\n        double endAngle = startAngle + angle;\n\n        AcDbArc* arcObj = new AcDbArc(AcGePoint3d(center.x, center.y, 0), normal, radius, startAngle, endAngle);\n        Arc::drawArc(arcObj);\n        arcObj-&gt;close();\n    }\n\n    \/\/ \u8d77\u70b9\u3001\u7ec8\u70b9\u3001\u5706\u5fc3\n    {\n        AcGePoint2d startPt(25, 25);\n        AcGePoint2d endPt(50, 100);\n        AcGePoint2d center(0, 0);\n\n        \/\/ \u8ba1\u7b97\u534a\u5f84\n        double radius = startPt.distanceTo(center);\n\n        \/\/ \u8d77\u70b9\u3001\u7ec8\u70b9\u89d2\u5ea6\n        AcGeVector2d startVec(startPt.x - center.x, startPt.y - center.y);\n        double startAngle = startVec.angle();\n        AcGeVector2d endVec(endPt.x - center.x, endPt.y - center.y);\n        double endAngle = endVec.angle();\n\n        AcDbArc* arcObj = new AcDbArc(AcGePoint3d(center.x, center.y, 0), normal, radius, startAngle, endAngle);\n        Arc::drawArc(arcObj);\n        arcObj-&gt;close();\n    }\n}<\/code><\/pre>\n<p>\u5728 acrxEntryPoint.cpp \u4e2d\u5f15\u7528\u5934\u6587\u4ef6\uff0c\u5e76\u5728 On_kInitAppMsg \u65b9\u6cd5\u91cc\u8c03\u7528<br \/>\n<img decoding=\"async\" data-src=\"https:\/\/blog.iyatt.com\/wp-content\/uploads\/2025\/03\/image-1742215952888.png\" alt=\"file\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" class=\"lazyload\" style=\"--smush-placeholder-width: 981px; --smush-placeholder-aspect-ratio: 981\/566;\" \/><\/p>\n<p>\u8c03\u8bd5\u8fd0\u884c<br \/>\n<img decoding=\"async\" data-src=\"https:\/\/blog.iyatt.com\/wp-content\/uploads\/2025\/03\/image-1742215934386.png\" alt=\"file\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" class=\"lazyload\" style=\"--smush-placeholder-width: 916px; --smush-placeholder-aspect-ratio: 916\/718;\" \/><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u73af\u5883 AutoCAD \u673a\u68b0\u7248 2025 ObjectARX 2025 VS 2022\uff08ISO C++14\uff09 \u73af [&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,594],"tags":[],"class_list":["post-19634","post","type-post","status-publish","format-standard","hentry","category-all","category-autocad","category-c-c","category-cad-cam","category-objectarx","category-594"],"modified_by":"IYATT-yx","_links":{"self":[{"href":"https:\/\/blog.iyatt.com\/index.php?rest_route=\/wp\/v2\/posts\/19634","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=19634"}],"version-history":[{"count":3,"href":"https:\/\/blog.iyatt.com\/index.php?rest_route=\/wp\/v2\/posts\/19634\/revisions"}],"predecessor-version":[{"id":19657,"href":"https:\/\/blog.iyatt.com\/index.php?rest_route=\/wp\/v2\/posts\/19634\/revisions\/19657"}],"wp:attachment":[{"href":"https:\/\/blog.iyatt.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=19634"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.iyatt.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=19634"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.iyatt.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=19634"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}