{"id":606,"date":"2019-11-25T13:53:00","date_gmt":"2019-11-25T05:53:00","guid":{"rendered":"http:\/\/localhost:8080\/?p=606"},"modified":"2019-11-25T13:53:00","modified_gmt":"2019-11-25T05:53:00","slug":"c-solidworks-%e4%ba%8c%e6%ac%a1%e5%bc%80%e5%8f%91-api-%e5%88%a9%e7%94%a8%e5%b0%84%e7%ba%bf%e9%80%89%e6%8b%a9%e7%9b%b8%e5%af%b9%e9%9d%a2","status":"publish","type":"post","link":"https:\/\/blog.ke-zhi.com\/?p=606","title":{"rendered":"C# SolidWorks \u4e8c\u6b21\u5f00\u53d1 API &#8212; \u5229\u7528\u5c04\u7ebf\u9009\u62e9\u76f8\u5bf9\u9762"},"content":{"rendered":"<h1> <a href=\"https:\/\/www.cnblogs.com\/solidworksapi\/p\/12897449.html\" target=\"_blank\" rel=\"nofollow noopener\"> <span>C# SolidWorks \u4e8c\u6b21\u5f00\u53d1 API &#8212; \u5229\u7528\u5c04\u7ebf\u9009\u62e9\u76f8\u5bf9\u9762<\/span> <\/a> <\/h1>\n<p>\u6700\u8fd1\u7684\u9879\u76ee\u4e2d\u9700\u8981\u7528\u5230\u4e00\u4e2a\u65b0\u7684\u529f\u80fd\uff0c\u5728\u7528\u6237\u9009\u62e9\u4e86\u4e00\u4e2a\u9762\u7684\u60c5\u51b5\u4e0b\uff0c\u627e\u5230\u6b64\u9762\u7684\u5bf9\u9762\u90a3\u4e2a\u9762\u3002\u7528\u6765\u5728\u8fd9\u4e24\u4e2a\u9762\u4e0a\u521b\u5efa\u4e00\u5bf9\u7279\u5f81\u3002<\/p>\n<p>\u5982\u4e0b\u56fe\uff0c\u9700\u8981\u9009\u4e2d\u7ea2\u8272\u7bad\u5934\u4e2d\u7684\u90a3\u4e2a\u9762\uff1a<\/p>\n<p><img decoding=\"async\" class=\"aligncenter\" src=\"https:\/\/img-blog.csdnimg.cn\/20191125134351564.png?x-oss-process=image\/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3plbmdxaDAzMTQ=,size_16,color_FFFFFF,t_70\"><\/p>\n<p>\u901a\u8fc7\u6d4b\u8bd5\uff0c\u53ef\u4ee5\u901a\u8fc7 SelectByRay\u8fd9\u4e2a\u51fd\u6570\u6765\u83b7\u53d6\u3002<\/p>\n<p>\u610f\u601d\u662f\u5728\u67d0\u4e2a\u70b9\uff0c\u753b\u4e00\u6761\u5c04\u7ebf\uff0c\u770b\u54ea\u4e2a\u9762\u4e0e\u5b83\u76f8\u4ea4\u3002<\/p>\n<p><img decoding=\"async\" class=\"aligncenter\" src=\"https:\/\/img-blog.csdnimg.cn\/2019112513511873.png?x-oss-process=image\/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3plbmdxaDAzMTQ=,size_16,color_FFFFFF,t_70\"><\/p>\n<p><img decoding=\"async\" class=\"aligncenter\" src=\"https:\/\/img-blog.csdnimg.cn\/20191125135006218.png?x-oss-process=image\/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3plbmdxaDAzMTQ=,size_16,color_FFFFFF,t_70\"><\/p>\n<p>\u9700\u8981\u6ce8\u610f\u7684\u662f\uff0c\u5982\u679c\u4e00\u4e2a\u8f74\u7ebf\u4e0a\u6709\u5f88\u591a\u4e2a\u76f8\u4ea4\u9762\u5b83\u4f1a\u9009\u62e9\u6700\u540e\u4e00\u4e2a.<\/p>\n<pre><code>private void btn_SelectByRay_Click(object sender, EventArgs e)\n        {\n            \/\/\u8fde\u63a5\u5230Solidworks\n            ISldWorks swApp = Utility.ConnectToSolidWorks();\n\n            ModelDoc2 swModel = (ModelDoc2)swApp.ActiveDoc;\n\n            Face2 swSelFace = default(Face2);\n            SelectionMgr swSelMgr = (SelectionMgr)swModel.SelectionManager;\n\n            \/\/\u83b7\u53d6\u9009\u62e9\u6570\u636e\n            SelectData swSelData = default(SelectData);\n\n            swSelData = swSelMgr.CreateSelectData();\n\n            swSelFace = (Face2)swSelMgr.GetSelectedObject6(1, 0);\n\n            var t = (double[])swSelFace.Normal;\n\n            \/\/\u83b7\u53d6\u5c4f\u5e55\u9f20\u6807\u9009\u62e9\u7684\u90a3\u4e2a\u70b9\n            var mousePoint = (double[])swSelMgr.GetSelectionPoint2(1, 0);\n\n            swModel.ClearSelection2(true);\n\n            \/\/\u521b\u5efaRay\u9009\u62e9\n\n            var boolstatus = swModel.Extension.SelectByRay(mousePoint[0], mousePoint[1], mousePoint[2], t[0], t[1], t[2], 0.1, 2, false, 0, 0);\n\n            if (boolstatus == true)\n            {\n                MessageBox.Show(\"\u9009\u62e9\u5b8c\u6210!\");\n            }\n        }<\/code><\/pre>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>          posted @<br \/>\n<span>2019-11-25 13:53<\/span>&nbsp;<br \/>\n<a href=\"https:\/\/www.cnblogs.com\/solidworksapi\/\" target=\"_blank\" rel=\"nofollow noopener\">painezeng<\/a>&nbsp; \u9605\u8bfb(<br \/>\n<span>101<\/span>)&nbsp; \u8bc4\u8bba(<br \/>\n<span>0<\/span>)&nbsp;<br \/>\n<a href=\"https:\/\/i.cnblogs.com\/EditPosts.aspx?postid=12897449\" rel=\"nofollow noopener\" target=\"_blank\">\u7f16\u8f91<\/a>&nbsp;<br \/>\n<a href=\"\" target=\"_blank\" rel=\"nofollow noopener\">\u6536\u85cf<\/a>&nbsp;<br \/>\n<a href=\"\" target=\"_blank\" rel=\"nofollow noopener\">\u4e3e\u62a5<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>C# SolidWorks \u4e8c\u6b21\u5f00\u53d1 API &#8212; \u5229\u7528\u5c04\u7ebf\u9009\u62e9\u76f8\u5bf9\u9762 \u6700\u8fd1\u7684\u9879\u76ee\u4e2d\u9700\u8981\u7528\u5230\u4e00\u4e2a\u65b0\u7684 [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":607,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"footnotes":""},"categories":[4,5],"tags":[7,6,8],"series":[],"class_list":["post-606","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-solidworks-","category-solidworks","tag-api","tag-solidworks","tag-8"],"views":161,"_links":{"self":[{"href":"https:\/\/blog.ke-zhi.com\/index.php?rest_route=\/wp\/v2\/posts\/606","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.ke-zhi.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.ke-zhi.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.ke-zhi.com\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.ke-zhi.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=606"}],"version-history":[{"count":0,"href":"https:\/\/blog.ke-zhi.com\/index.php?rest_route=\/wp\/v2\/posts\/606\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blog.ke-zhi.com\/index.php?rest_route=\/wp\/v2\/media\/607"}],"wp:attachment":[{"href":"https:\/\/blog.ke-zhi.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=606"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.ke-zhi.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=606"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.ke-zhi.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=606"},{"taxonomy":"series","embeddable":true,"href":"https:\/\/blog.ke-zhi.com\/index.php?rest_route=%2Fwp%2Fv2%2Fseries&post=606"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}