﻿{"id":36201,"date":"2012-06-01T09:18:10","date_gmt":"2012-06-01T01:18:10","guid":{"rendered":"http:\/\/www.lanmaowang.com\/?p=36201"},"modified":"2015-04-01T21:22:06","modified_gmt":"2015-04-01T13:22:06","slug":"delphi-development-autocad-selects-and-deletes-the-object","status":"publish","type":"post","link":"http:\/\/www.lanmaowang.com\/?p=36201","title":{"rendered":"Delphi\u5f00\u53d1AutoCAD\u4e4b\u9009\u62e9\u5e76\u5220\u9664\u5bf9\u8c61"},"content":{"rendered":"<p>\u3000\u3000Delphi\u4e0eAutoCAD\u8fdb\u884c\u8fde\u63a5\uff08ActiveX\uff09\uff0c\u53ef\u4ee5\u5f00\u53d1\u51fa\u5f88\u591a\u7a0b\u5e8f\u3002VB API\u624b\u518c\u4e2d\u4e5f\u8be6\u7ec6\u4e86\u8bb2\u8ff0\u4e86\u5173\u4e8eVBA\u5f00\u53d1CAD\u7684\u65b9\u6cd5\u3002\u4f46\u662f\u6709\u4e9b\u65b9\u6cd5\u5e76\u6ca1\u6709\u5b9e\u4f8b\uff0c\u6bd4\u5982\u9009\u62e9\u5f53\u524d\u753b\u5e03\u4e2d\u6240\u6709\u5bf9\u8c61\u3002&nbsp;<\/p>\n<p>\u3000\u3000\u5728\u6211\u4eec\u5f00\u53d1\u4e00\u4e2a\u5c0f\u7a0b\u5e8f\u7684\u65f6\u5019\uff0c\u6709\u65f6\u5019\u4f1a\u9047\u5230\u5b9e\u65f6\u8fdb\u884c\u4fee\u6539\u7684\u60c5\u51b5\u3002\u5982\u679c\u4e0d\u8fdb\u884c\u539f\u5bf9\u8c61\u7684\u5220\u9664\u64cd\u4f5c\uff0c\u5c06\u5728\u4e0d\u540c\u53c2\u6570\u4e0b\u51fa\u73b0\u8bb8\u591a\u5bf9\u8c61\u3002\u6bd4\u5982\u6211\u4eec\u8981\u83b7\u5f97\u957f\u5ea6\u4e3a5\u7684\u7ebf\uff0c\u4f46\u662f\u7b2c\u4e00\u6b21\u6211\u4eec\u7ed8\u5236\u7684\u662f\u957f\u5ea6\u4e3a10\u7684\u7ebf\uff0c\u8fd9\u6837\u5728\u5237\u65b0\u7684\u8fc7\u7a0b\u4e2d\u6211\u4eec\u9700\u8981\u5c06\u957f\u5ea6\u4e3a5\u7684\u7ebf\u5220\u9664\u3002\u5173\u4e8e\u5355\u5bf9\u8c61\u7684\u5220\u9664\uff0c\u6bd4\u8f83\u7b80\u5355\uff0c\u5728VBA\u5f00\u53d1\u6587\u6863\u4e2d\u6709\u8be6\u7ec6\u7684\u63cf\u8ff0\u3002\u4f46\u662f\u5bf9\u8c61\u591a\u7684\u65f6\u5019\uff0c\u5173\u4e8e\u9009\u62e9\u5c31\u662f\u4e00\u4ef6\u7e41\u7410\u7684\u4e8b\u60c5\uff0c\u53ef\u80fd\u4f1a\u4f7f\u4f60\u7684\u4ee3\u7801\u91cf\u589e\u52a0\u51e0\u500d\u3002\u8fd9\u6837\u6211\u4eec\u9700\u8981\u4e00\u6b21\u6027\u5220\u9664\u6240\u6709\u5bf9\u8c61\u3002&nbsp;<\/p>\n<p>\u3000\u3000\u5173\u4e8e\u9009\u62e9\u64cd\u4f5c\uff0c\u9996\u5148\u6211\u4eec\u8981\u5728\u6587\u6863\u4e2d\u6dfb\u52a0\u4e00\u4e2a\u65b0\u7684\u9009\u62e9\u96c6\uff08\u6216\u8005\u5229\u7528\u5148\u524d\u7684\u9009\u62e9\u96c6\uff09&nbsp;<\/p>\n<pre class=\"brush:delphi;toolbar:false\">\/\/\u6837\u4f8b\u4ee3\u7801\uff1a&nbsp;\r\nvar&nbsp;\r\n&nbsp;&nbsp;cad:AcadApplication;&nbsp;\r\n&nbsp;&nbsp;ft,FilterData,pointsArray:Variant;&nbsp;\r\n&nbsp;&nbsp;Set_Select:AcadSelectionSet;&nbsp;\r\nbegin&nbsp;\r\n&nbsp;&nbsp;cad:=GetActiveOleObject(&#39;AutoCAD.Application&#39;)&nbsp;as&nbsp;AcadApplication;\/\/Createoleobject&nbsp;\r\n&nbsp;&nbsp;cad.Visible:=true;&nbsp;\r\n&nbsp;&nbsp;Set_Select_Count:=cad.ActiveDocument.selectionSets.count;&nbsp;\r\n&nbsp;&nbsp;if&nbsp;Set_Select_Count=0&nbsp;then&nbsp;Set_Select:=cad.ActiveDocument.SelectionSets.Add(&#39;Select_All&#39;)&nbsp;\r\n&nbsp;&nbsp;else&nbsp;\r\n&nbsp;&nbsp;&nbsp;&nbsp;begin&nbsp;\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;for&nbsp;Set_Select_Count:=0&nbsp;to&nbsp;cad.ActiveDocument.selectionSets.count-1&nbsp;do&nbsp;\/\/\u904d\u5386\u9009\u62e9\u96c6\uff0c\u5982\u679c&#39;Select_All&#39;\u5df2\u7ecf\u5b58\u5728\u5c31\u4e0d\u5efa\u4e86\u3002&nbsp;\r\n&nbsp;&nbsp;&nbsp;&nbsp;begin&nbsp;\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;cad.ActiveDocument.selectionSets.Item(Set_Select_Count).Name=&#39;Select_All&#39;&nbsp;then&nbsp;\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Set_Select:=cad.ActiveDocument.SelectionSets.Item(Set_Select_Count)&nbsp;\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;else&nbsp;\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Set_Select:=cad.ActiveDocument.SelectionSets.Add(&#39;Select_All&#39;);&nbsp;\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end;&nbsp;\r\n&nbsp;&nbsp;&nbsp;&nbsp;end;&nbsp;\r\n&nbsp;&nbsp;ft:=&nbsp;VarArrayCreate([0,0],VT_I2);&nbsp;\r\n&nbsp;&nbsp;ft[0]:=100;&nbsp;\r\n&nbsp;&nbsp;\/\/ft[1]:=0;&nbsp;\r\n&nbsp;&nbsp;FilterData:=VarArrayCreate([0,0],VT_Variant);;&nbsp;\r\n&nbsp;&nbsp;\/\/FilterData[0]&nbsp;:=&nbsp;&#39;&#39;;&nbsp;\r\n&nbsp;&nbsp;\/\/FilterData[1]&nbsp;:=&nbsp;&#39;&#39;;&nbsp;\r\n&nbsp;&nbsp;Set_Select.Select(acSelectionSetAll,&#39;&#39;,&nbsp;&#39;&#39;,ft,FilterData);&nbsp;\r\n&nbsp;&nbsp;\/\/Set_Select.Highlight(True);\/\/\u8be5\u4ee3\u7801\u9ad8\u4eae\u663e\u793a\u9009\u62e9\u7684\u5bf9\u8c61&nbsp;\r\n&nbsp;&nbsp;\/\/ShowMessage(IntToStr(Set_Select.Count));\/\/\u8be5\u4ee3\u7801\u5c06\u663e\u793a\u9009\u62e9\u7684\u5bf9\u8c61\u6570&nbsp;\r\n&nbsp;&nbsp;Set_Select.Erase;&nbsp;\/\/Erase\u65b9\u6cd5\u5220\u9664\u9009\u62e9\u96c6\u4e2d\u7684\u6240\u6709\u9879\u3002\u9009\u62e9\u96c6\u4ecd\u7136\u5b58\u5728\uff0c\u4f46\u4e0d\u518d\u5305\u542b\u4efb\u4f55\u9879\u3002\u539f\u6765\u5305\u542b\u5728\u9009\u62e9\u96c6\u4e2d\u7684\u9879\u4e5f\u4e0d\u518d\u5b58\u5728\u3002&nbsp;\r\ncad.ZoomExtents;&nbsp;\r\nend;<\/pre>\n<p>\u3000\u3000\u5173\u4e8e\u5168\u9009\u6240\u6709\u5bf9\u8c61\uff0c\u8fd8\u6709\u53e6\u4e00\u4e2a\u529e\u6cd5\u5c31\u662f\u5229\u7528SendCommand\u547d\u4ee4\u3002\u6548\u679c\u662f\u4e00\u6837\u7684\uff0c\u5927\u5bb6\u53ef\u4ee5\u81ea\u5df1\u5efa\u7acb\u4e0d\u540c\u7684\u9879\u76ee\uff0c\u5bf9\u6bd4\u4e24\u8005\u4e4b\u95f4\u7684\u5dee\u5f02\u548c\u6548\u7387\u95ee\u9898<\/p>\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u3000\u3000Delphi\u4e0eAutoCAD\u8fdb\u884c\u8fde\u63a5\uff08ActiveX\uff09\uff0c\u53ef\u4ee5\u5f00\u53d1\u51fa\u5f88\u591a\u7a0b\u5e8f\u3002VB API\u624b\u518c\u4e2d\u4e5f\u8be6\u7ec6\u4e86\u8bb2\u8ff0 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":36146,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[193],"tags":[214,211],"_links":{"self":[{"href":"http:\/\/www.lanmaowang.com\/index.php?rest_route=\/wp\/v2\/posts\/36201"}],"collection":[{"href":"http:\/\/www.lanmaowang.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.lanmaowang.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.lanmaowang.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.lanmaowang.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=36201"}],"version-history":[{"count":1,"href":"http:\/\/www.lanmaowang.com\/index.php?rest_route=\/wp\/v2\/posts\/36201\/revisions"}],"predecessor-version":[{"id":36202,"href":"http:\/\/www.lanmaowang.com\/index.php?rest_route=\/wp\/v2\/posts\/36201\/revisions\/36202"}],"wp:featuredmedia":[{"embeddable":true,"href":"http:\/\/www.lanmaowang.com\/index.php?rest_route=\/wp\/v2\/media\/36146"}],"wp:attachment":[{"href":"http:\/\/www.lanmaowang.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=36201"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.lanmaowang.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=36201"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.lanmaowang.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=36201"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}