熱點推薦:
您现在的位置: 電腦知識網 >> 編程 >> .NET編程 >> 正文

C#打開SolidWorks2008零件文件

2022-06-13   來源: .NET編程 

  起因在對SolidWorks進行二次開發的過程中SolidWorks API幫助必不可少然而其中多數實例是用VB和C++實現的本文提供一個利用C#進行SolidWorks二次開發的小實例希望能提供一個敲開這扇門的窗口
    環境Windows XP + Visual Studio C# + SolidWorks
    目的用C#打開SolidWorks的SLDPRT文件
    步驟
        安裝SolidWorks API包
        添加兩個COM引用SldWorks Type Library和SolidWorks Constant type library
        程序代碼如下

  using System;
    using SystemCollectionsGeneric;
    using SystemComponentModel;
    using SystemData;
    using SystemDrawing;
    using SystemText;
    using SystemWindowsForms;
    using SldWorks; //COM Reference: SldWorks Type Library
    using SwConst;  //COM Reference: SolidWorks Constant type library

  namespace swTest
    {
        public partial class frmTest : Form
        {
            public frmTest()
            {
                InitializeComponent();
            }

  private void btnTest_Click_(object sender EventArgs e)
            {
                int IErrors = ;
                int IWarnings = ;

  SldWorksSldWorks swApp = new SldWorksSldWorks();

  swAppOpenDoc(@E:\aSLDPRT(int)SwConstswDocumentTypes_eswDocPART(int)SwConstswOpenDocOptions_eswOpenDocOptions_Silentnull ref IErrors ref IWarnings);

  swAppVisible = true;
            }
        }
    }


From:http://tw.wingwit.com/Article/program/net/201311/11324.html
    推薦文章
    Copyright © 2005-2022 電腦知識網 Computer Knowledge   All rights reserved.