{"id":558,"date":"2021-04-08T15:24:00","date_gmt":"2021-04-08T07:24:00","guid":{"rendered":"http:\/\/localhost:8080\/?p=558"},"modified":"2021-04-08T15:24:00","modified_gmt":"2021-04-08T07:24:00","slug":"solidworks%e4%ba%8c%e6%ac%a1%e5%bc%80%e5%8f%91-%e5%85%b3%e4%ba%8e%e5%bd%95%e5%88%b6%e5%ae%8f%e4%bf%9d%e5%ad%98%e7%9a%84%e6%a0%bc%e5%bc%8f","status":"publish","type":"post","link":"https:\/\/blog.ke-zhi.com\/?p=558","title":{"rendered":"SolidWorks\u4e8c\u6b21\u5f00\u53d1-\u5173\u4e8e\u5f55\u5236\u5b8f\u4fdd\u5b58\u7684\u683c\u5f0f"},"content":{"rendered":"<h1> <a href=\"https:\/\/www.cnblogs.com\/solidworksapi\/p\/17369403.html\" target=\"_blank\" rel=\"nofollow noopener\"> <span>SolidWorks\u4e8c\u6b21\u5f00\u53d1-\u5173\u4e8e\u5f55\u5236\u5b8f\u4fdd\u5b58\u7684\u683c\u5f0f<\/span> <\/a> <\/h1>\n<p>\u5bf9\u4e8e\u5f55\u5236\u5b8f\u64cd\u4f5c\u4e4b\u540e\uff0c\u4e4b\u524d\u7684\u7248\u672c\u662f\u53ef\u4ee5\u76f4\u63a5\u53e6\u5b58\u4e86Vb.net \u6216\u8005C# \u7684\u683c\u5f0f\u7684\u6587\u4ef6\u7684\uff0c\u867d\u7136\u5b83\u53ea\u662fVSTA\u7684\u9879\u76ee\uff0c\u4f46\u662f\u8bed\u6cd5\u57fa\u672c\u662f\u4e00\u6837\u7684\u3002<br \/> <img decoding=\"async\" src=\"https:\/\/img-blog.csdnimg.cn\/20210408151827433.png\" class=\"aligncenter\"><\/p>\n<p>\u521a\u63a5\u89e6SolidWorks\u4e8c\u6b21\u5f00\u7684\u5c0f\u4f19\u4f34\u53ef\u80fd\u53ea\u77e5\u9053swp\u8fd9\u4e2a\u539f\u59cb\u683c\u5f0f\u3002<\/p>\n<p>\u800c\u4e14Solidworks\u4e2d\u8fd8\u4e13\u95e8\u6709\u4e2a\u9009\u9879\uff0c\u59822018\u4e2d<br \/> <img decoding=\"async\" src=\"https:\/\/img-blog.csdnimg.cn\/20210408151226140.png?x-oss-process=image\/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3plbmdxaDAzMTQ=,size_16,color_FFFFFF,t_70\" class=\"aligncenter\"><\/p>\n<p>\u5e76\u4e14\u5f88\u591a\u7535\u8111\u4e0a\u5b8f\u5f55\u5236\u5b8c\u6210\u4e4b\u540e \uff0c\u6839\u672c\u5c31\u6ca1\u6709\u5176\u5b83\u683c\u5f0f\uff0c\u53ea\u6709swp.<\/p>\n<p>\u8fd9\u662f\u4e3a\u4ec0\u4e48\u5462\uff1f \u6211\u4eec\u4eca\u5929\u6765\u770b\u770b\u5b98\u65b9\u7684\u8bf4\u660e,\u6253\u5f00API \u5e2e\u52a9\u6587\u4ef6\u3002<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/img-blog.csdnimg.cn\/2021040815115160.png?x-oss-process=image\/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3plbmdxaDAzMTQ=,size_16,color_FFFFFF,t_70\" class=\"aligncenter\"><\/p>\n<p>\u641c\u7d22\u4e00\u4e0bVSTA\u8fd9\u4e2a\u5173\u952e\u5b57\u3002<br \/> <img decoding=\"async\" src=\"https:\/\/img-blog.csdnimg.cn\/20210408151438892.png?x-oss-process=image\/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3plbmdxaDAzMTQ=,size_16,color_FFFFFF,t_70\" class=\"aligncenter\"><\/p>\n<p><img decoding=\"async\" src=\"https:\/\/img-blog.csdnimg.cn\/20210408151519362.png?x-oss-process=image\/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3plbmdxaDAzMTQ=,size_16,color_FFFFFF,t_70\" class=\"aligncenter\"><\/p>\n<pre><code>Prerequisite Software \nInstalling VSTA \nCreating a .NET macro in SOLIDWORKS 2018 \nEditing a .NET macro created in SOLIDWORKS 2018 \nUpgrading a .NET macro created in SOLIDWORKS 2017 or earlier \nRunning a .NET DLL created in SOLIDWORKS 2017 or earlier \nPrerequisite Software\nMicrosoft Visual Studio 2015 (Community, Professional, Premium or Enterprise version) must be installed in order to record, edit, or debug VB.NET and C# macros using VSTA (3.0) 2015 in SOLIDWORKS 2018. \nNotes: \n\nIf you install a version of Microsoft Visual Studio that is later than 2015, you must ensure that a runtime version of Microsoft Visual Studio 2015 is also installed. \nIf you do not install Microsoft Visual Studio 2015 before you install SOLIDWORKS 2018, you will not be able to record, edit, or debug VSTA 3.0 macros. You will only be able to run VSTA 3.0 DLLs. \nIf you install Microsoft Visual Studio 2015 after you install SOLIDWORKS 2018, you must also install the VSTA runtime to record, edit, or debug VSTA 3.0 macros. \nInstalling VSTA\nSOLIDWORKS 2017 and earlier used VSTA 1.0 to create, edit, and run .NET macros. SOLIDWORKS 2018 supports both VSTA 1.0 and VSTA (3.0) 2015. SOLIDWORKS 2018 activates VSTA (3.0) 2015 by default on all Windows versions. If VSTA 3.0 is enabled, .NET macros created in previous releases are converted when they are edited in this release. If VSTA 3.0 is enabled, be sure to back up your VSTA 1.0 macros before editing them in SOLIDWORKS 2018. If you do not want to convert your .NET macros, you can still edit and run VSTA 1.0 macros in this release, provided you choose to install VSTA 1.0 during the SOLIDWORKS installation and then de-select Tools &gt; Options &gt; System Options &gt; General &gt; Enable VSTA VERSION 3.0.\n\nIf you need to edit or run VSTA 1.0 macros on:\n\nWindows 8 or later machines:\n\nDuring SOLIDWORKS 2018 installation, click Change above the Products window on the Summary screen. \nExpand SOLIDWORKS in the Product Selection window. \nSelect Visual Studio Tools for Applications (VSTA). \nOn the Summary screen, click Install Now. \nDuring installation, a message box appears with \"An app on your PC needs the following Windows feature: .NET Framework 3.5 (includes .NET 2.0 and 3.0).\" Click Download and install this feature. If you do not select to download and install this feature, then VSTA 1.0 will not work. \nVisual Studio Tools (1.0), Visual Studio Tools 2015, and other components are installed. \nWindows 7 machines:\n\nDuring SOLIDWORKS 2018 installation, click Change above the Products window on the Summary page. \nExpand SOLIDWORKS in the Product Selection window. \nVisual Studio Tools for Applications (VSTA) is selected by default to install VSTA 2015 and VSTA 1.0. After installing .NET Framework 4.6.2, a system reboot occurs. When the system comes back up, Visual Studio Tools 2015 and the remaining components are installed. If VSTA is de-selected in the installer, then VSTA 1.0 is not installed. \nAfter installing SOLIDWORKS 2018:\n\nSelect Tools &gt; Options &gt; System Options &gt; General &gt; Enable VSTA VERSION 3.0 to configure VSTA (3.0) 2015. When opened, .NET macros created in previous releases are converted to VSTA 2015, and an instance of Visual Studio 2015 opens the converted .NET macro for editing. See Prerequisite Software.\n  \nIf you prefer to use VSTA 1.0 to edit or run VSTA 1.0 macros created in previous releases, you must first activate VSTA 1.0 by de-selecting Tools &gt; Options &gt; System Options &gt; General &gt; Enable VSTA VERSION 3.0. \nNote: You  must have installed VSTA during SOLIDWORKS 2018 installation. \n  \nTools &gt; Macro &gt; Edit &gt; Open &gt; File name dropdown contains:\n \nSW VBA Macros (*.swp) \nSW VSTA VB Macro (*.vbproj) \nSW VSTA C# Macro (*.csproj) \nSW Macros (*.swp, *.swb, *.csproj, *.vbproj)\n  \nTools &gt; Macro &gt; New &gt; Save As &gt; Save as type dropdown contains:\n \nSW VBA Macros (*.swp) \nSW VSTA VB Macro (*.vbproj) \nSW VSTA C# Macro (*.csproj)\n  \nIf you did not select to install VSTA when you installed SOLIDWORKS, then all of the SOLIDWORKS macro dialog dropdowns contain only: \n        SW VBA Macros (*.swp)\n\nYou cannot modify or repair your SOLIDWORKS installation to add VSTA. You must uninstall and re-install SOLIDWORKS, selecting to install Visual Studio Tools for Applications (VSTA) during the installation. \nCreating a .NET macro in SOLIDWORKS 2018 using VSTA 3.0\nRead Installing VSTA. \nIn SOLIDWORKS, select Tools &gt; Macro &gt; New. \nIn the Save As dialog, navigate to the directory where to save the project. \nSpecify File name. \nIn Save as type select SW VSTA VB Macro (*.vbproj) or SW VSTA C# Macro (*.csproj). \nClick Save. \nA new instance of Visual Studio 2015 opens. See Prerequisite Software. \nSolution Explorer shows:\nThe solution, VstaProjects. \nThe project name. \nMy Project \nReferences (sldworks and swconst interop assemblies added from install_dir\\api\\redist\\) \nSolidWorksMacro.vb or SolidWorksMacro.cs. \nThe SolidWorksMacro class is assigned a GUID attribute. If you change this attribute, the macro will not run. \nWhen you compile the macro, the project's configuration (Debug or Release) and output directory are not read. Only a release DLL is saved in project_folder\/bin. \nEditing a .NET macro created in SOLIDWORKS 2018 using VSTA 3.0\nRead Installing VSTA. \nIn SOLIDWORKS, select Tools &gt; Macro &gt; Edit. \nIn the Open dialog, navigate to the project folder. \nSelect SW Macros in the project type dropdown. \nSelect the *.vbproj or *.csproj project file. \nClick Open. \nA new instance of Visual Studio 2015 opens the project you selected. See Prerequisite Software. \nUpgrading a .NET macro created in SOLIDWORKS 2017 or earlier\nRead Installing VSTA. \nIf VSTA 3.0 is enabled, be sure to back up your VSTA 1.0 .NET macro files before editing them in SOLIDWORKS 2018. \nIn order to successfully upgrade a .NET macro, the class name, \"SolidWorksMacro\", and the method name, \"Execute\", must be preserved. If you renamed those entities in your VSTA 1.0 macro, the macro cannot be upgraded to VSTA 2015. \nIn SOLIDWORKS, select Tools &gt; Macro &gt; Edit. \nIn the Open dialog, navigate to the SwMacro directory of the project folder created in a previous release. \nSelect SW Macros in the project type dropdown. \nSelect the *.vbproj or *.csproj project file. \nClick Open. \nA new project is created in project_folder\/SwMacro\/upgradedmacro. \nA new instance of Visual Studio 2015 opens the upgraded project. See Prerequisite Software. \nWhen you compile the macro, the project's configuration (Debug or Release) and output directory are not read. Only a release DLL is saved in project_folder\/SwMacro\/upgradedmacro\/bin. \nThe original macro is not modified or moved. \nRunning a .NET DLL created in SOLIDWORKS 2017 or earlier\nRead Installing VSTA. If you selected to install VSTA 1.0, and de-selected Tools &gt; Options &gt; System Options &gt; General &gt; Enable VSTA VERSION 3.0, you can edit or run VSTA 1.0 macros. If you did not install VSTA 1.0, then VSTA 2015 is active by default, and you must upgrade VSTA 1.0 macros to VSTA 2015: \n\nFollow the instructions in Upgrading a .NET macro created in SOLIDWORKS 2017 or earlier. \nSelect Tools &gt; Macro &gt; Run. \nSelect SW VSTA Macros (*.dll) in the file type dropdown. \nNavigate to project_folder\\SwMacro\\upgradedmacro\\bin. \nSelect the DLL. \nClick Open to run the macro. \n\n<\/code><\/pre>\n<p>\u5176\u5b9e\u5b98\u65b9\u8bf4\u4e86\u5f88\u591a\uff0c\u5176\u5b9e\u5f88\u5bb9\u6613\u770b\u61c2\u7684\u3002<br \/> \u548c\u5b89\u88c5(\u9700\u8981\u5355\u72ec\u53bb\u9009VSTA\u73af\u5883)\u4ee5\u53ca\u9009\u9879\u90fd\u6709\u5173\u7cfb\u3002<br \/> \u56e0\u4e3a\u6211\u4e0d\u5e38\u7528\u8fd9\u79cd\u65b9\u5f0f\uff0c\u6bd5\u7adf\u4e00\u90e8\u5206\u64cd\u4f5c\u901a\u8fc7\u5b8f\u4e5f\u662f\u5f55\u5236\u4e0d\u5230\u7684\uff0c\u800c\u4e14\u7528swp\u683c\u5f0f\u4e5f\u975e\u5e38\u65b9\u4fbf\uff0c\u5f55\u597d\u7684\u4ee3\u7801\u81ea\u5df1\u518d\u4f7f\u7528VS\u73af\u5883\u518d\u5199\u4e00\u6b21\uff0c\u80fd\u66f4\u597d\u7684\u52a0\u6df1\u5370\u8c61\uff0c\u7406\u89e3\u548c\u6d88\u5316\u6389\u77e5\u8bc6\u70b9\u3002<\/p>\n<p>\u6240\u4ee5\u6211\u8fd8\u662f\u5efa\u8bae\u5927\u5bb6\u4e0d\u8981\u7ea0\u7ed3\u8fd9\u4e2a\u5f55\u5236\u7684\u683c\u5f0f\uff0c\u4e60\u60ef\u5c31\u597d\u4e86\uff0c\u82b1\u592a\u591a\u65f6\u95f4\u53bb\u5f04\u8fd9\u4e2a\u6ca1\u5fc5\u8981\u7684\u73af\u5883\uff0c\u4e0d\u5212\u7b97\u3002<br \/> \u800c\u4e14\u76f4\u63a5\u7528VS \u6bd4\u90a3\u4e2a\u65b9\u4fbf\u7684\u591a\u3002<\/p>\n<p>          posted @<br \/>\n<span>2021-04-08 15:24<\/span>&nbsp;<br \/>\n<a href=\"https:\/\/www.cnblogs.com\/solidworksapi\/\" target=\"_blank\" rel=\"nofollow noopener\">painezeng<\/a>&nbsp; \u9605\u8bfb(<br \/>\n<span>0<\/span>)&nbsp; \u8bc4\u8bba(<br \/>\n<span>0<\/span>)&nbsp;<br \/>\n<a href=\"https:\/\/i.cnblogs.com\/EditPosts.aspx?postid=17369403\" 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> &nbsp;<br \/>\n<a href=\"\" target=\"_blank\" rel=\"nofollow noopener\">\u6765\u6e90<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>SolidWorks\u4e8c\u6b21\u5f00\u53d1-\u5173\u4e8e\u5f55\u5236\u5b8f\u4fdd\u5b58\u7684\u683c\u5f0f \u5bf9\u4e8e\u5f55\u5236\u5b8f\u64cd\u4f5c\u4e4b\u540e\uff0c\u4e4b\u524d\u7684\u7248\u672c\u662f\u53ef\u4ee5\u76f4\u63a5\u53e6\u5b58\u4e86Vb.net [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":559,"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-558","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\/558","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=558"}],"version-history":[{"count":0,"href":"https:\/\/blog.ke-zhi.com\/index.php?rest_route=\/wp\/v2\/posts\/558\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blog.ke-zhi.com\/index.php?rest_route=\/wp\/v2\/media\/559"}],"wp:attachment":[{"href":"https:\/\/blog.ke-zhi.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=558"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.ke-zhi.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=558"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.ke-zhi.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=558"},{"taxonomy":"series","embeddable":true,"href":"https:\/\/blog.ke-zhi.com\/index.php?rest_route=%2Fwp%2Fv2%2Fseries&post=558"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}