{"id":635,"date":"2019-10-11T19:38:00","date_gmt":"2019-10-11T11:38:00","guid":{"rendered":"http:\/\/localhost:8080\/?p=635"},"modified":"2019-10-11T19:38:00","modified_gmt":"2019-10-11T11:38:00","slug":"c-solidworks-%e4%ba%8c%e6%ac%a1%e5%bc%80%e5%8f%91-api-%e8%8e%b7%e5%8f%96%e8%b4%a8%e9%87%8f%e5%b1%9e%e6%80%a7","status":"publish","type":"post","link":"https:\/\/blog.ke-zhi.com\/?p=635","title":{"rendered":"C# SolidWorks \u4e8c\u6b21\u5f00\u53d1 API&#8212;\u83b7\u53d6\u8d28\u91cf\u5c5e\u6027"},"content":{"rendered":"<h1> <a href=\"https:\/\/www.cnblogs.com\/solidworksapi\/p\/12897467.html\" target=\"_blank\" rel=\"nofollow noopener\"> <span>C# SolidWorks \u4e8c\u6b21\u5f00\u53d1 API&#8212;\u83b7\u53d6\u8d28\u91cf\u5c5e\u6027<\/span> <\/a> <\/h1>\n<p>\u6709\u4e9b\u60c5\u51b5\u6211\u4eec\u9700\u8981\u901a\u8fc7\u7cfb\u7edf\u7684\u8d28\u91cf\u5c5e\u6027\u83b7\u53d6\u4e00\u4e9b\u4fe1\u606f.<\/p>\n<p><img decoding=\"async\" class=\"aligncenter\" src=\"https:\/\/img-blog.csdnimg.cn\/20191011193654865.png?x-oss-process=image\/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3plbmdxaDAzMTQ=,size_16,color_FFFFFF,t_70\"><\/p>\n<p>\u8fd9\u4e2aapi\u5e2e\u52a9\u91cc\u81ea\u5e26\u4f8b\u5b50.<\/p>\n<pre><code>        private void btn_GetMass_Click(object sender, EventArgs e)\n        {\n            \/\/ \u83b7\u53d6\u8d28\u91cf\u5c5e\u6027\u53ef\u53c2\u8003 Get Mass Properties of Visible and Hidden Components Example (C#)\n\n            ISldWorks swApp = Utility.ConnectToSolidWorks();\n\n            ModelDoc2 swModel = swApp.ActiveDoc;\n\n            ModelDocExtension swModelDocExt = (ModelDocExtension)swModel.Extension;\n\n            swModelDocExt.IncludeMassPropertiesOfHiddenBodies = false;\n            int massStatus = 0;\n\n            double[] massProperties = (double[])swModelDocExt.GetMassProperties(1, ref massStatus);\n            if ((massProperties != null))\n            {\n                Debug.Print(\" CenterOfMassX = \" + massProperties[0]);\n                Debug.Print(\" CenterOfMassY = \" + massProperties[1]);\n                Debug.Print(\" CenterOfMassZ = \" + massProperties[2]);\n                Debug.Print(\" Volume = \" + massProperties[3]);\n                Debug.Print(\" Area = \" + massProperties[4]);\n                Debug.Print(\" Mass = \" + massProperties[5]);\n                Debug.Print(\" MomXX = \" + massProperties[6]);\n                Debug.Print(\" MomYY = \" + massProperties[7]);\n                Debug.Print(\" MomZZ = \" + massProperties[8]);\n                Debug.Print(\" MomXY = \" + massProperties[9]);\n                Debug.Print(\" MomZX = \" + massProperties[10]);\n                Debug.Print(\" MomYZ = \" + massProperties[11]);\n            }\n            Debug.Print(\"-------------------------------\");\n        }<\/code><\/pre>\n<p>&nbsp;<\/p>\n<p>          posted @<br \/>\n<span>2019-10-11 19:38<\/span>&nbsp;<br \/>\n<a href=\"https:\/\/www.cnblogs.com\/solidworksapi\/\" target=\"_blank\" rel=\"nofollow noopener\">painezeng<\/a>&nbsp; \u9605\u8bfb(<br \/>\n<span>196<\/span>)&nbsp; \u8bc4\u8bba(<br \/>\n<span>0<\/span>)&nbsp;<br \/>\n<a href=\"https:\/\/i.cnblogs.com\/EditPosts.aspx?postid=12897467\" 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;\u83b7\u53d6\u8d28\u91cf\u5c5e\u6027 \u6709\u4e9b\u60c5\u51b5\u6211\u4eec\u9700\u8981\u901a\u8fc7\u7cfb\u7edf\u7684\u8d28\u91cf\u5c5e\u6027\u83b7\u53d6 [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":636,"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-635","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-solidworks-","category-solidworks","tag-api","tag-solidworks","tag-8"],"views":173,"_links":{"self":[{"href":"https:\/\/blog.ke-zhi.com\/index.php?rest_route=\/wp\/v2\/posts\/635","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=635"}],"version-history":[{"count":0,"href":"https:\/\/blog.ke-zhi.com\/index.php?rest_route=\/wp\/v2\/posts\/635\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blog.ke-zhi.com\/index.php?rest_route=\/wp\/v2\/media\/636"}],"wp:attachment":[{"href":"https:\/\/blog.ke-zhi.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=635"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.ke-zhi.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=635"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.ke-zhi.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=635"},{"taxonomy":"series","embeddable":true,"href":"https:\/\/blog.ke-zhi.com\/index.php?rest_route=%2Fwp%2Fv2%2Fseries&post=635"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}