{"id":649,"date":"2019-09-29T18:23:00","date_gmt":"2019-09-29T10:23:00","guid":{"rendered":"http:\/\/localhost:8080\/?p=649"},"modified":"2019-09-29T18:23:00","modified_gmt":"2019-09-29T10:23:00","slug":"c-solidworks-%e4%ba%8c%e6%ac%a1%e5%bc%80%e5%8f%91-api-%e5%a6%82%e4%bd%95%e9%80%9a%e8%bf%87%e9%9d%a2%e5%b1%9e%e6%80%a7%e5%91%bd%e5%90%8d%e9%80%89%e4%b8%ad%e5%af%b9%e8%b1%a1","status":"publish","type":"post","link":"https:\/\/blog.ke-zhi.com\/?p=649","title":{"rendered":"C# SolidWorks \u4e8c\u6b21\u5f00\u53d1 API&#8212;\u5982\u4f55\u901a\u8fc7\u9762\u5c5e\u6027\u547d\u540d\u9009\u4e2d\u5bf9\u8c61"},"content":{"rendered":"<h1> <a href=\"https:\/\/www.cnblogs.com\/solidworksapi\/p\/12897474.html\" target=\"_blank\" rel=\"nofollow noopener\"> <span>C# SolidWorks \u4e8c\u6b21\u5f00\u53d1 API&#8212;\u5982\u4f55\u901a\u8fc7\u9762\u5c5e\u6027\u547d\u540d\u9009\u4e2d\u5bf9\u8c61<\/span> <\/a> <\/h1>\n<p>\u4eca\u5929\u6709\u4eba\u95ee\u5230\u5982\u4f55\u9009\u4e2d\u96f6\u4ef6\u4e2d\u5df2\u7ecf\u547d\u540d\u7684\u9762.\u90a3\u6211\u4eec\u5c31\u5148\u628a\u8fd9\u4e2a\u8bb0\u5f55\u4e00\u4e0b.<\/p>\n<p>\u6bd4\u5982,\u96f6\u4ef6\u4e2d\u6211\u4eec\u547d\u540d\u4e86\u4e00\u4e2a\u9762\u7684\u540d\u79f0<\/p>\n<p><img decoding=\"async\" class=\"aligncenter\" src=\"https:\/\/img-blog.csdnimg.cn\/20190929181405667.png?x-oss-process=image\/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3plbmdxaDAzMTQ=,size_16,color_FFFFFF,t_70\"><\/p>\n<p>\u6709\u4e24\u79cd\u60c5\u51b5:<\/p>\n<p>1,\u96f6\u4ef6\u4e2d\u9009\u4e2d\u8be5\u9762:<\/p>\n<pre><code>             ISldWorks swApp = Utility.ConnectToSolidWorks();\n            ModelDoc2 swModel = swApp.ActiveDoc;\n            SelectionMgr swSelMgr = swModel.SelectionManager;          \n             PartDoc part1 = (PartDoc)swModel;\n            \/\/\u5728\u96f6\u4ef6\u4e2d\u9009\u62e9\n            Face2 face1 = part1.GetEntityByName(\"SFace1\", (int)swSelectType_e.swSelFACES);\n            Entity entity1 = (Entity)face1;\n            entity1.Select(false);<\/code><\/pre>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>2.\u88c5\u914d\u4e2d:<\/p>\n<pre><code> #region \u88c5\u914d\u4e2d\u9009\u62e9\n\n            \/\/\u8fd9\u91cc\u6211\u4eec\u9ed8\u8ba4\u8be5\u96f6\u4ef6\u5df2\u7ecf\u662f\u9009\u4e2d\u88c5\u914d,\u5426\u5219\u6211\u4eec\u9700\u8981\u904d\u5386\u4e00\u6b21\u96f6\u4ef6,\u4ec5\u505a\u793a\u4f8b\n\n            Component2 component = swSelMgr.GetSelectedObjectsComponent4(1, -1);\n\n            swModel.ClearSelection();\n\n            ModelDoc2 modelDoc = component.GetModelDoc2();\n\n            \/\/\u8f6c\u6362\u4e3aPartDoc\n            PartDoc part = (PartDoc)modelDoc;\n\n            Face2 face = part.GetEntityByName(\"SFace1\", (int)swSelectType_e.swSelFACES);\n\n            Entity entity = (Entity)face;\n\n            \/\/\u5728\u88c5\u914d\u4e2d\u518d\u8f6c\u6362\u6210\u88c5\u914d\u4e2d\u7684\u5b9e\u4f53\n            Entity entityInComp = (Entity)component.GetCorrespondingEntity(entity);\n\n            entityInComp.Select(false);\n\n            #endregion<\/code><\/pre>\n<p>&nbsp;<\/p>\n<p>          posted @<br \/>\n<span>2019-09-29 18:23<\/span>&nbsp;<br \/>\n<a href=\"https:\/\/www.cnblogs.com\/solidworksapi\/\" target=\"_blank\" rel=\"nofollow noopener\">painezeng<\/a>&nbsp; \u9605\u8bfb(<br \/>\n<span>134<\/span>)&nbsp; \u8bc4\u8bba(<br \/>\n<span>0<\/span>)&nbsp;<br \/>\n<a href=\"https:\/\/i.cnblogs.com\/EditPosts.aspx?postid=12897474\" 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;\u5982\u4f55\u901a\u8fc7\u9762\u5c5e\u6027\u547d\u540d\u9009\u4e2d\u5bf9\u8c61 \u4eca\u5929\u6709\u4eba\u95ee\u5230\u5982\u4f55\u9009\u4e2d\u96f6\u4ef6 [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":650,"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-649","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-solidworks-","category-solidworks","tag-api","tag-solidworks","tag-8"],"views":208,"_links":{"self":[{"href":"https:\/\/blog.ke-zhi.com\/index.php?rest_route=\/wp\/v2\/posts\/649","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=649"}],"version-history":[{"count":0,"href":"https:\/\/blog.ke-zhi.com\/index.php?rest_route=\/wp\/v2\/posts\/649\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blog.ke-zhi.com\/index.php?rest_route=\/wp\/v2\/media\/650"}],"wp:attachment":[{"href":"https:\/\/blog.ke-zhi.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=649"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.ke-zhi.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=649"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.ke-zhi.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=649"},{"taxonomy":"series","embeddable":true,"href":"https:\/\/blog.ke-zhi.com\/index.php?rest_route=%2Fwp%2Fv2%2Fseries&post=649"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}