{"id":781,"date":"2024-06-19T10:16:22","date_gmt":"2024-06-19T02:16:22","guid":{"rendered":"http:\/\/www.wyrcad.com\/?p=781"},"modified":"2024-07-11T13:38:26","modified_gmt":"2024-07-11T05:38:26","slug":"autocad-%e9%80%89%e6%8b%a9%e5%9b%be%e5%85%83","status":"publish","type":"post","link":"https:\/\/www.wyrcad.com\/?p=781","title":{"rendered":"AutoCAD \u9009\u62e9\u56fe\u5143"},"content":{"rendered":"\n<p>&#8216;\u672c\u8282\u4ecb\u7ecd\u51e0\u4e2a\u77e5\u8bc6\u70b9\uff0c\u5373\u5efa\u7acb\u8fc7\u6ee4\u5668\u3001\u5efa\u7acb\u9009\u62e9\u96c6\u3001\u56db\u79cd\u65b9\u5f0f\u9009\u62e9\u56fe\u5143\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>'\u6253\u5f00\u5e76\u7ed1\u5b9a\u6587\u4ef6 D:\/Test.dwg\nDim I As Integer, J As Integer\nDim oAutoCAD As Object\nCall <a href=\"https:\/\/www.wyrcad.com\/?p=618\">BindAutoCAD<\/a>(True)\nDim oDraw As Object\nSet oDraw = oAutoCAD.Application.Documents.Open(\"D:\/Test.dwg\")\n\n'\u7533\u660e\u9009\u62e9\u96c6\u53ca\u96c6\u6210\u5458\nDim oSelset As Object, oItem As Object\n\n'\u5efa\u7acb\u8fc7\u6ee4\u5668\uff0c\u76ee\u6807\u662f\u4f4d\u4e8e 0 \u5c42\u7684\u7ea2\u8272\u7684\u5355\u884c\u6587\u5b57\u3001\u76f4\u7ebf\u3001\u5706(\u534a\u5f84\u4e3a15)\u3001\u6837\u6761\u66f2\u7ebf\u3001\u591a\u4e49\u7ebf\nDim FilterType(13) As Integer\nDim FilterData(13) As Variant\nFilterType(0) = -4\nFilterData(0) = \"&lt;AND\"\nFilterType(1) = 8 'Layer\nFilterData(1) = \"0\"\nFilterType(2) = 62 'Color\nFilterData(2) = 1 'Red\nFilterType(3) = -4\nFilterData(3) = \"&lt;OR\"\nFilterType(4) = 0 '\u56fe\u5143\nFilterData(4) = \"text\"\nFilterType(5) = 0 '\u56fe\u5143\nFilterData(5) = \"line\"\nFilterType(6) = -4\nFilterData(6) = \"&lt;AND\"\nFilterType(7) = 0 '\u56fe\u5143\nFilterData(7) = \"circle\"\nFilterType(8) = 40 '\u534a\u5f84\nFilterData(8) = 15\nFilterType(9) = -4\nFilterData(9) = \"AND>\"\nFilterType(10) = 0 '\u56fe\u5143\nFilterData(10) = \"spline\"\nFilterType(11) = 0 '\u56fe\u5143\nFilterData(11) = \"Polyline\"\nFilterType(12) = -4\nFilterData(12) = \"OR>\"\nFilterType(13) = -4\nFilterData(13) = \"AND>\"\n\n'\u70b9\u9009\u5f0f\u9009\u62e9\u56fe\u5143\uff0c\u540c\u65f6\u6ee1\u8db3\u8fc7\u6ee4\u5668\u539f\u5219\nCall AppActivate(oAutoCAD.Caption)\nSet oSelset = oDraw.SelectionSets.Add(<a href=\"https:\/\/www.wyrcad.com\/?p=785\">SelName<\/a>(8))\noSelset.Select 5, , , FilterType, FilterData\n'acSelectionSetWindow = 0;\n'acSelectionSetCrossing = 1;\n'acSelectionSetFence = 2;\n'acSelectionSetPrevious = 3;\n'acSelectionSetLast = 4;\n'acSelectionSetAll = 5;\nFor I = 0 To oSelset.Count - 1\nDebug.Print Replace(oSelset(I).ObjectName, \"AcDb\", \"\", 1, -1, vbTextCompare)\nNext I\nDebug.Print\n\n'\u5c4f\u5e55\u9009\u62e9\u56fe\u5143\uff0c\u540c\u65f6\u6ee1\u8db3\u8fc7\u6ee4\u5668\u539f\nCall AppActivate(oAutoCAD.Caption)\nSet oSelset = oDraw.SelectionSets.Add(SelName(8))\noSelset.SelectOnScreen FilterType, FilterData\nFor I = 0 To oSelset.Count - 1\nDebug.Print Replace(oSelset(I).ObjectName, \"AcDb\", \"\", 1, -1, vbTextCompare)\nNext I\nDebug.Print\n\n'\u591a\u8fb9\u5f62\u9009\u62e9\u56fe\u5143\uff0c\u540c\u65f6\u6ee1\u8db3\u8fc7\u6ee4\u5668\u539f\u5219\nCall AppActivate(oAutoCAD.Caption)\nSet oSelset = oDraw.SelectionSets.Add(SelName(8))\nDim PointArray(0 To 11) As Double\nPointArray(0) = 0\nPointArray(1) = 0\nPointArray(2) = 0\nPointArray(3) = 77\nPointArray(4) = 380\nPointArray(5) = 0\nPointArray(6) = 215\nPointArray(7) = 425\nPointArray(8) = 0\nPointArray(9) = 466\nPointArray(10) = 188\nPointArray(11) = 0\noSelset.SelectByPolygon 2, PointArray, FilterType, FilterData\n'acSelectionSetFence = 0\n'acSelectionSetWindowPolygon = 1\n'acSelectionSetCrossingPolygon = 2\nFor I = 0 To oSelset.Count - 1\nDebug.Print Replace(oSelset(I).ObjectName, \"AcDb\", \"\", 1, -1, vbTextCompare)\nNext I\nDebug.Print\n\n'\u901a\u8fc7\u67d0\u70b9\u9009\u62e9\u56fe\u5143\uff0c\u540c\u65f6\u6ee1\u8db3\u8fc7\u6ee4\u5668\u539f\u5219\nCall AppActivate(oAutoCAD.Caption)\nSet oSelset = oDraw.SelectionSets.Add(SelName(8))\nDim TempPoint(0 To 2) As Double\nTempPoint(0) = 10\nTempPoint(1) = 10\nTempPoint(2) = 0\noSelset.SelectAtPoint TempPoint, FilterType, FilterData\nFor I = 0 To oSelset.Count - 1\nDebug.Print Replace(oSelset(I).ObjectName, \"AcDb\", \"\", 1, -1, vbTextCompare)\nNext I\nDebug.Print<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>&#8216;\u672c\u8282\u4ecb\u7ecd\u51e0\u4e2a\u77e5\u8bc6\u70b9\uff0c\u5373\u5efa\u7acb\u8fc7\u6ee4\u5668\u3001\u5efa\u7acb\u9009\u62e9\u96c6\u3001\u56db\u79cd\u65b9\u5f0f\u9009\u62e9\u56fe\u5143\u3002<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12],"tags":[24,17],"class_list":["post-781","post","type-post","status-publish","format-standard","hentry","category-bianchengyuandi","tag-vb","tag-biancheng"],"_links":{"self":[{"href":"https:\/\/www.wyrcad.com\/index.php?rest_route=\/wp\/v2\/posts\/781","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wyrcad.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wyrcad.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wyrcad.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wyrcad.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=781"}],"version-history":[{"count":11,"href":"https:\/\/www.wyrcad.com\/index.php?rest_route=\/wp\/v2\/posts\/781\/revisions"}],"predecessor-version":[{"id":1150,"href":"https:\/\/www.wyrcad.com\/index.php?rest_route=\/wp\/v2\/posts\/781\/revisions\/1150"}],"wp:attachment":[{"href":"https:\/\/www.wyrcad.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=781"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wyrcad.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=781"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wyrcad.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=781"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}