SolidWorks插件开发模板文件功能
(2011-12-06 00:13:53)
标签:
solidworks
api
it
|
分类:
软件技术
|
下面是由SW插件开发模板自动产生的文件(C#):
class
文件名称
|
描述
Description
|
AssemblyInfo.cs
|
This file provides a means to organize and publish assembly-specific information.
C#应用程序必须的文件。
|
EventHandling.cs
|
This file contains the event handling objects for documents and model views.
文件包括文档和模型视图的事件处理对象。
The DocumentEventHandler object is a base class that exposes the interface and contains code for dealing with ModelView events.
DocumentEventHandler对象是一个基类,用于扩展界面,同时包括了一些用于处理模型事件的详细的代码。
(注:文档事件处理类是一个基类,也可以理解为抽象类,PartEventHandler, AssemblyEventHandler,和DrawingEventHandler是它的子类,分别用于处理零件,装配和工程图事件,文档视图是windows窗口的一个概念,比如word就称为多文档视图,即MDI,当然用户也可以使用单文档视图)
PartEventHandler, AssemblyEventHandler, and DrawingEventHandler are the three object types that can listen for document events. There must be one instance of each class for each open document of that type.
PartEventHandler, AssemblyEventHandler,和DrawingEventHandler是三个对象类型,他们依付于文档事件。他们必须是每一个打开类型对象的实例。
(注:这三个对象,不一定都需要,比如你只画零件,就只处理PartEventHandler,其他两个就不管,多余代码全删除)
The ModelViewEventHandler object listens for ModelView events. There should be one instance of ModelViewEventHandler for each ModelView in each open document.
ModelViewEventHandler对象依付于 ModelView模型视图事件,在每个打开的文档中的每个模型视图中必须有一个ModelViewEventHandler的实例。
|
PMPHandler.cs
|
This file contains the class that implements the PropertyManager page handler interface. An instance of this object is passed to SolidWorks when creating a PropertyManager page. When a control on the page is manipulated, the corresponding method in this object is called.
本文件包括了这样一些类,他们实现了PropertyManager的处理界面,当产生一个PropertyManager页时,本对象的实例被传入SW环境中,当页上的一个控制发生时,本对象中的方法就被调用。
(注:PMP就是特征管理,这里只管处理,不关特征如何表现)
|
SwAddinn.cs
|
This file contains the main add-in class.
本文件包括主要的插件类。
Visual Studio adds the letter n to the default name SwAddin, if more than one project by that name exists in the same location.
如果同一位置有多个工程,VS向缺省的名称SwAddin附件了字符n。
Examine the code in each region of this file:
Region
|
Description
|
Local Variables
局部变量
|
Contains the definitions of this class's variables
包括了一些类变量的定义。
|
SolidWorks Registration
SW注册
|
Contains methods to register and unregister the add-in
包括了插件注册和反注册的方法。
|
ISwAddin Implementation
插件实现
|
Contains
ISwAddin::ConnectToSW()
ISwAddin::DisconnectFromSW() which are the entry and exit points for the add-in
包括两个方法,一个插件的入口点,一个退出点。
(注:没有这个,插件无法和SW发生关系)
|
UI Methods
用户界面方法
|
Contains methods that define how the add-in behaves within the SolidWorks application
包括的方法有,定义一个插件如何在SW应用程序中表现。
(注:主要是菜单等的定义,但是菜单的定义有些不自然,是用字符串来构造菜单)
|
Event Methods
事件方法
|
Contains SolidWorks event handling methods
包括SW事件处理方法。
|
Event Handlers
事件句柄
|
Contains the event callbacks for the SolidWorks object
包括从SW对象的事件回调。
|
UI Callbacks
用户界面的回调
|
Contains methods that are called from the add-in user interface
包括从插件用户界面被调用的方法
|
|
UserPMPage.cs
|
This file contains the wrapper class and layout methods for the add-in's PropertyManager page. To modify the controls on the PropertyManager page, change the code in the AddControls() method.
本文件包括了一个包装类和布局方法,用于PropertyManager页,这能够修改PropertyManager页,在AddControls方法中写控制代码。
Add all controls to group boxes. Group boxes are displayed top to bottom in the order in which they are added to the page. Controls are displayed top to bottom in the order in which they are added to the group box.
向成组盒中添加所有的控制,成组盒被显示从上到下挨个显示,这主要是为了他们每一个都能被加入到页上,控制也是如此,控制比加入到成组盒中。
(注:特征控制定义的外观全在这里,几乎所有的windwos中可用的控制方法都可加入,比如按钮、下拉条等等,甚至ActiveX,定义的方法也有些不自然)
|
SW开发中,很多时候都要明确输入的类型或者输出的类型,但是SW的集成关系比较复杂,有时根本弄不清。单元dotnet4.0的var变量能够解决这个问题,把问题交给编译器去判断吧,没有试过。
有一个开发的技巧是,先打开宏记录,你就画呀画呀,最后生成了VBA代码,直接将这些代码拷贝到SharpDevelop中,自动转换成C#代码,开始修改吧!!!!!!
喜欢
0
赠金笔
加载中,请稍候......