几何尺寸与公差论坛------致力于产品几何量公差标准GD&T (GDT:ASME)|New GPS(ISO)研究/CAD设计/CAM加工/CMM测量  


返回   几何尺寸与公差论坛------致力于产品几何量公差标准GD&T (GDT:ASME)|New GPS(ISO)研究/CAD设计/CAM加工/CMM测量 » 仿射空间:CAX软件开发(三)二次开发与程序设计 » CAD二次开发 » SolidWorks二次开发
用户名
密码
注册 帮助 会员 日历 银行 搜索 今日新帖 标记论坛为已读


回复
 
主题工具 搜索本主题 显示模式
旧 2009-04-12, 07:39 PM   #1
yang686526
高级会员
 
注册日期: 06-11
帖子: 14579
精华: 1
现金: 224494 标准币
资产: 234494 标准币
yang686526 向着好的方向发展
默认 【转帖】solidworks api= library

solidworks api+ library
solidworks api+ library
i am currently writing a new library (dll to reference in .net) for the solidworks api. the new library will have an enhanced object called the sldworkex object, which will take care of all of the hard work for you. it managed the connection to solidworks for you, closing solidworks, can tell you the current version of solidworks as in integer, can open a file without the need to specifc the file type and adds the option to open visible or not, and much more.
expanding on that the library includes a modeldoc2ex, which can add/delete/set custom properties with ease managing the custompropertymanager for you so you don't have to hassle with it, as well as get all names, values, the total count any many other detials. it can save out the current model to any of the 28+ native formats that solidworks handles, again with no need to specific surplus data.
another object is the documentmanagerex, which again exposes the document manager and handles all of the connection for you so all you have to do is call functions to add/delete/set custom properties and get configurations etc...
all of the objects handle errors for you and return them in custom error objects with detailed descriptions. each *ex object provides the user with complete exposure to the underlying base object (sldworks, modeldoc2 etc...) so that you may still use any of the standard functions.
so, and example of use would be to add the angelsix.solidworksex.dll as a reference, and then do the following:
sldworksex swappex = new sldworksex();
if (!swappex.connect(false, true))
// error connecting so do whatever
// else show current version e.g. 2009
messagebox.show(swappex.version.tostring());
// open document, and get the modeldoc2ex object
modeldoc2ex swmodelex;
// default no options opens current configuration, silently, visible, and reports any error message to the opendocerrors string
swmodelex = swappex.open("c:\myfile.sldprt");
// if opening failed diplay message
if (swmodelex == null)
messagebox.show(swappex.opendocerrormessage);
// else set a custom property of the new part, selecting to overwrite if exist
bool b = swmodelex.setcustomproperty("description", "my description", true);
if (!b)
messagebox.show("failed to set custom property");
// show total custom properties including properties from all configurations
messagebox.show(swmodelex.custompropertycount(true).tostring());
// clear all custom properties
swmodelex.clearcustomproperties();
messagebox.show(swmodelex.custompropertycount(true).tostring());
// save as edrawing
if (!swmodelex.saveas("c:\mynewpart.eprt"))
messagebox.show(swappex.savedocerrormessage);
// close file
swmodelex.close();
// create new documentmanagerex
documentmanagerex dmex = new documentmanagerex();
dmex.opendoc("c:\mypart.sldprt");
dmex.setcustomproperty("description", "my description", true);
dmex.closedoc();
these are just a few examples of how tasks can be accomplished without the hassle involved for many using the standard api.
if you have any suggestions or ideas please post them and i will see about incorporating them.
the library will go on sale at angelsix in about a week or so once complete for £30 which buys you an unlimited use license for the individual/company using it for free or commercial use.
yang686526离线中   回复时引用此帖
GDT自动化论坛(仅游客可见)
回复


主题工具 搜索本主题
搜索本主题:

高级搜索
显示模式

发帖规则
不可以发表新主题
不可以回复主题
不可以上传附件
不可以编辑您的帖子

vB 代码开启
[IMG]代码开启
HTML代码关闭

相似的主题
主题 主题发起者 论坛 回复 最后发表
【转帖】solidworks 2009 constant tye library yang686526 SolidWorks二次开发 0 2009-04-12 07:38 PM
NIST Digital Library of Mathematical Functions huangyhg 前沿算法库 1 2009-03-25 12:40 AM
【发布】这个是约束控制的定义,约束控制的是自由度与自由度的关系 huangyhg 约束求解 0 2005-03-15 01:20 PM


所有的时间均为北京时间。 现在的时间是 12:05 PM.


于2004年创办,几何尺寸与公差论坛"致力于产品几何量公差标准GD&T | GPS研究/CAD设计/CAM加工/CMM测量"。免责声明:论坛严禁发布色情反动言论及有关违反国家法律法规内容!情节严重者提供其IP,并配合相关部门进行严厉查处,若內容有涉及侵权,请立即联系我们QQ:44671734。注:此论坛须管理员验证方可发帖。
沪ICP备06057009号-2
更多