{"id":690,"date":"2023-07-15T14:57:03","date_gmt":"2023-07-15T06:57:03","guid":{"rendered":"http:\/\/localhost:8080\/?p=690"},"modified":"2023-07-15T14:57:06","modified_gmt":"2023-07-15T06:57:06","slug":"solidworks%e4%ba%8c%e6%ac%a1%e5%bc%80%e5%8f%91-%e6%89%93%e5%bc%80%e6%96%87%e4%bb%b6%e9%82%a3%e4%ba%9b%e4%ba%8b","status":"publish","type":"post","link":"https:\/\/blog.ke-zhi.com\/?p=690","title":{"rendered":"SolidWorks\u4e8c\u6b21\u5f00\u53d1&#8212;\u6253\u5f00\u6587\u4ef6\u90a3\u4e9b\u4e8b"},"content":{"rendered":"<p>\u6708\u672b\u4e86\uff0c\u8fd9\u4e2a\u6708\u7684\u4efb\u52a1\u8fd8\u6ca1\u5b8c\u6210\uff0c\u96be\u9053\u662f\u56e0\u4e3a\u592a\u5fd9\u4e86\u5417\uff0c\u597d\u50cf\u4e0d\u662f\u3002<br \/>\n\u4eca\u5929\u5c31\u7b80\u5355\u8bb0\u5f55\u4e00\u4e0b\u524d\u4e00\u6bb5\u65f6\u95f4\u6709\u4eba\u95ee\u7684\u4e00\u4e2a\u95ee\u9898\uff0c\u600e\u4e48\u77e5\u9053\u6587\u4ef6\u5728\u6ca1\u6709\u5728solidworks\u4e2d\u6253\u5f00\u3002\u5982\u679c\u6ca1\u6253\u5f00\u5c31\u505aA ,\u5df2\u7ecf\u6253\u5f00\u4e86\u5c31\u505aB. \u522b\u4e71\u60f3\uff0c\u53ea\u662f\u8bf4\u67d0\u4e2a\u52a8\u4f5c\u54c8\u3002<br \/>\n\u5927\u5bb6\u770b\u8fc7\u4e4b\u524d\u7684\u6559\u7a0b\u7684\u90fd\u77e5\u9053Opendoc\u8fd9\u4e2a\u65b9\u6cd5\u3002<br \/>\n\u8fd9\u4e2a\u5c31\u662f\u6253\u5f00\u67d0\u4e2a\u5df2\u7ecf\u5b58\u5728\u7684\u6587\u4ef6\u5e76\u8fd4\u56de\u5b83\u7684\u6307\u9488(\u778e\u7ffb\u8bd1\u7684\u54c8)<br \/>\n<img decoding=\"async\" src=\"https:\/\/img-blog.csdnimg.cn\/5581f617aa1a4c34baff9e2bed219d94.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><br \/>\n\u4f46\u662f\u8fd9\u4e2a\u548c\u7f51\u53cb\u95ee\u7684\u95ee\u9898\u6ca1\u4ec0\u4e48\u76f4\u63a5\u5173\u7cfb\uff0c\u8981\u60f3\u77e5\u9053\u6587\u4ef6\u6709\u6ca1\u6709\u6253\u5f00\uff0c\u5e38\u89c4\u601d\u8def\u5c31\u6709\u4ee5\u4e0b\u51e0\u79cd\uff1a<\/p>\n<ul>\n<li>\u904d\u5386\u5df2\u7ecf\u6253\u5f00\u7684\u6587\u4ef6\uff0c\u8fdb\u884c\u5bf9\u6bd4<\/li>\n<\/ul>\n<pre><code class=\"language-cpp\">Traverse All Open Documents Example (C++ COM)<\/code><\/pre>\n<ul>\n<li>\u5207\u6362\u5230\u8be5\u540d\u79f0\u7684\u6587\u4ef6\uff0c\u5982\u679c\u6210\u529f\u5219\u8868\u793a\u5df2\u7ecf\u6253\u5f00\u3002<\/li>\n<\/ul>\n<pre><code class=\"language-csharp\">var swModel= swApp.IActivateDoc(\"xxx.sldprt\");<\/code><\/pre>\n<ul>\n<li>\u76f4\u63a5\u5229\u7528\u6253\u5f00\u547d\u4ee4\uff0c\u770b\u770b\u6267\u884c\u5b8c\u662f\u4e0d\u662f\u5f53\u524d\u96f6\u4ef6\u3002\uff08\u5982\u679c\u6587\u4ef6\u5df2\u7ecf\u6253\u5f00\uff0c\u4f1a\u8fd4\u56de\u4e00\u4e2a\u5bf9\u8c61\uff0c\u4f46\u6ca1\u6709\u6fc0\u6d3b\uff09<\/li>\n<\/ul>\n<pre><code class=\"language-csharp\">            \/\/\u6253\u5f00\u6587\u4ef6\n            var fileName = @\"XXXXX\";\n            int errors = 0;\n            int warnings = 0;\n\n            var swModel = (ModelDoc2)swApp.OpenDoc6(fileName, (int)swDocumentTypes_e.swDocASSEMBLY, (int)swOpenDocOptions_e.swOpenDocOptions_Silent, \"\", ref errors, ref warnings);<\/code><\/pre>\n<pre><code>\u6709\u6ca1\u6709\u66f4\u5389\u5bb3\u7684\u529e\u6cd5\u5462\uff0c\u6211\u4eec\u518d\u627e\u4e00\u627e\u3002\u6211\u5047\u88c5\u6211\u82f1\u6587\u5f88\u725bB,\u641c\u7d22\u4e00\u4e0bopened document\n\u53d1\u73b0\u4ee5\u4e0b\u5185\u5bb9\uff0c\u6700\u540e\u4e00\u4e2a\u6709\u70b9\u50cf\u3002<\/code><\/pre>\n<p><img decoding=\"async\" src=\"https:\/\/img-blog.csdnimg.cn\/5eb80a933ba84df18790ccda9a6d2ace.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<p><img decoding=\"async\" src=\"https:\/\/img-blog.csdnimg.cn\/a4bba0645842469b8edcfadc2292f956.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><br \/>\n\u5230\u76ee\u524d\u4e3a\u6b62\uff0c\u6700\u76f4\u63a5\u7684\u65b9\u6cd5\u5c31\u662fGetOpenDocumentByName<br \/>\n<img decoding=\"async\" src=\"https:\/\/img-blog.csdnimg.cn\/173800bad96148d8a5141c7fc05c5f54.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><br \/>\n\u793a\u4f8b\u4ee3\u7801\u5982\u4e0b:<\/p>\n<pre><code class=\"language-csharp\">\n            var partOpened = swApp.GetOpenDocumentByName(@\"D:9_StudyCSharpAndSolidWorksCSharpAndSolidWorksTemplateModelclamp3.sldprt\");\n\n            if (partOpened!=null)\n            {\n                MessageBox.Show(\"\u8be5\u6587\u4ef6\u5df2\u7ecf\u88ab\u6253\u5f00\");\n            }\n            else\n            {\n                MessageBox.Show(\"\u8be5\u6587\u4ef6\u5df2\u7ecf\u6ca1\u6709\u88ab\u6253\u5f00\u3002\");\n            }<\/code><\/pre>\n<p>\u597d\u4e86\uff0c\u7ed3\u675f\u4e86\u3002<\/p>\n<p>\u6536\u85cf\u597d\u5730\u5740\uff0c\u4ee5\u9632\u627e\u4e0d\u5230\u3002<br \/>\n<a href=\"https:\/\/gitee.com\/painezeng\/CSharpAndSolidWorks\">https:\/\/gitee.com\/painezeng\/CSharpAndSolidWorks<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6708\u672b\u4e86\uff0c\u8fd9\u4e2a\u6708\u7684\u4efb\u52a1\u8fd8\u6ca1\u5b8c\u6210\uff0c\u96be\u9053\u662f\u56e0\u4e3a\u592a\u5fd9\u4e86\u5417\uff0c\u597d\u50cf\u4e0d\u662f\u3002 \u4eca\u5929\u5c31\u7b80\u5355\u8bb0\u5f55\u4e00\u4e0b\u524d\u4e00\u6bb5\u65f6\u95f4\u6709\u4eba\u95ee\u7684\u4e00\u4e2a\u95ee\u9898\uff0c\u600e [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","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":[5],"tags":[7,6],"series":[],"class_list":["post-690","post","type-post","status-publish","format-standard","hentry","category-solidworks","tag-api","tag-solidworks"],"views":553,"_links":{"self":[{"href":"https:\/\/blog.ke-zhi.com\/index.php?rest_route=\/wp\/v2\/posts\/690","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\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.ke-zhi.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=690"}],"version-history":[{"count":1,"href":"https:\/\/blog.ke-zhi.com\/index.php?rest_route=\/wp\/v2\/posts\/690\/revisions"}],"predecessor-version":[{"id":691,"href":"https:\/\/blog.ke-zhi.com\/index.php?rest_route=\/wp\/v2\/posts\/690\/revisions\/691"}],"wp:attachment":[{"href":"https:\/\/blog.ke-zhi.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=690"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.ke-zhi.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=690"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.ke-zhi.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=690"},{"taxonomy":"series","embeddable":true,"href":"https:\/\/blog.ke-zhi.com\/index.php?rest_route=%2Fwp%2Fv2%2Fseries&post=690"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}