哈哈,博客园找找看的功能很爽哎,简单问题一找就一堆,对于俺这种菜鸟正好适用。

感谢博客园团队!

posted @ 2008-08-15 00:40 liong 阅读(202) 评论(1) 编辑

信息:cnblogs首发 by:liong  转载请保留
链接:http://www.cnblogs.com/liong/archive/2008/05/21/1204404.html

起因:在对SolidWorks进行二次开发的过程中,SolidWorks API帮助必不可少,然而其中多数实例是用VB6.0和C++实现的,本文提供一个利用C#进行SolidWorks二次开发的小实例,希望能提供一个敲开这扇门的窗口。
环境:Windows XP + Visual Studio 2005 C# + SolidWorks 2008
目的:用C#打开SolidWorks的.SLDPRT文件。
步骤:
    1、安装SolidWorks2008 API包;
    2、添加两个COM引用:SldWorks 2008 Type LibrarySolidWorks 2008 Constant type library
    3、程序代码如下:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using SldWorks; //COM Reference: SldWorks 2008 Type Library.
using SwConst;  //COM Reference: SolidWorks 2008 Constant type library.

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


        
private void btnTest_Click_1(object sender, EventArgs e)
        
{
            
int IErrors = 0;
            
int IWarnings = 0;

            SldWorks.SldWorks swApp 
= new SldWorks.SldWorks();

            swApp.OpenDoc6(
@"E:\a.SLDPRT",(int)SwConst.swDocumentTypes_e.swDocPART,(int)SwConst.swOpenDocOptions_e.swOpenDocOptions_Silent,nullref IErrors, ref IWarnings);

            swApp.Visible 
= true;  
        }

    }

}

致谢:感谢SolidWorks Forum API版 Luke Malpass 的大力帮助。
Thanks for the great help of Luke Malpass  from SolidWorks Forum-API.
posted @ 2008-05-21 23:31 liong 阅读(1880) 评论(2) 编辑
这几天的问题原来出在把路径"E\a.SLDPRT"当"E:\a.SLDPRT"用了,记下来,下次这种粗心大意的错误要注意。
posted @ 2008-05-11 20:06 liong 阅读(16) 评论(0) 编辑
摘要: 刚学C#不久,看美剧时经常遇到身高几英尺几英寸的说法,故做了个inch和cm互换的小程序。
原理:1inch = 1/12foot = 2.54cm = 25.4mm
说明:inch转cm时可精确转换,cm转inch时约等。阅读全文
posted @ 2008-04-07 23:40 liong 阅读(1316) 评论(0) 编辑
来源:网络
   
   两个int型数相除(/)为整除,自动舍弃小数部分;而double型相除则不然,结果的值四舍五入。
--------
   如果/運算符中兩個操作數中有一個是double/float型,那麼另外一個數據類型數也會自動轉換為double型,結果也會為double型數.
   C#中確實沒有整除的操作符,你可以使用操作符重載的方法:

  //結果為四舍五入值
   public static int operator / (double x, double y)
 
{
         
double result = x/y;
         
return System.Convert.ToInt32(result);
  }
 
  //結果為舍弃小數的值,不四舍五入
  public static int operator / (double x, double y)
  
{
         
double result = x/y;
         
return System.Convert.ToInt32(result - x%y/y);
   }
 
posted @ 2008-04-03 12:39 liong 阅读(2102) 评论(0) 编辑