几何尺寸与公差论坛------致力于产品几何量公差标准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-13, 08:47 AM   #1
yang686526
高级会员
 
注册日期: 06-11
帖子: 14579
精华: 1
现金: 224494 标准币
资产: 234494 标准币
yang686526 向着好的方向发展
默认 【转帖】addmate error

addmate error
dear all,
i got a new problem and need your help so much.
i selected two edges from two parts in a part document and then call "addmate". the following is how i call this api function using c#:
---------
int errorstatus;
mate2 mt = featdata.addmate(entedge, (int)swmatetype_e.swmatecoincident, (int)swmatealign_e.swalignsame, 0, 0, out errorstatus);
---------
featdata is "movecopybodyfeaturedata" object obtained by "getdefinition()", which is not null;
entedge is "entity" array (entity[2]) containing two selected edges
the "mt" object is not null after the call. however, when i check the return value of "errorstatus", it is "swaddmateerror_erroruknown". if the call to "addmate" is not successful, i cannot go further in developing.
please help. many thanks
firstly, check the mate object mt by trying to get some value from it such as:
messagebox.show(mt.getmatedimensionvalue());
second, change the entity[] to an object[] and give them both a try
hi, luke,
thank you very much for your suggestions. this is my test code
-------
int errorstatus;
mate2 mt = featdata.addmate(entedge, (int)swmatetype_e.swmatecoincident, (int)swmatealign_e.swalignsame, 0, 0, out errorstatus);
if (mt == null)
{
messagebox.show("no mate is added");
return 0;
}
else
{
messagebox.show("entity number is " + mt.getmateentitycount().tostring());
mateentity2 mt2 = mt.mateentity(0);
messagebox.show("parameter size is " + mt2.getentityparamssize().tostring());
}
-------------------
i added a "if" loop to test the mate2 object "mt". the result is "entity number is 2" and "parameter size is 8". it seems that the mate2 object "mt" is correct. the return value of "errorstatus" is still "swaddmateerror_erroruknown".
however, if i change entity[] to object[], the "if" loop will not be executed and the watch window in debug mode turns to grey. i cannot check any variable in watch window then. the "addmate" api function may return without any message and the remaining code doesn't execute. it is strange.
do you have any idea? sorry for the trouble.
newform
this seems like a bug as i have tried everything to get it to work including accessselections and the like. on top of that an actual example of modifying a movecopyfeaturedata object also does nothing it does not work:
example from sw api:
sub main()
dim swapp as sldworks.sldworks
dim part as sldworks.partdoc
dim component as sldworks.component2
dim movecopyfeat as sldworks.feature
dim movecopy_featdata as sldworks.movecopybodyfeaturedata
dim boolstatus as boolean
set swapp = application.sldworks
set part = swapp.activedoc
set movecopyfeat = part.featurebyname("body-move/copy1")
set movecopy_featdata = movecopyfeat.getdefinition
boolstatus = movecopy_featdata.accessselections(part, component)
movecopy_featdata.transformtype = swtransformtype_translation
movecopy_featdata.transformx = 0.1
movecopy_featdata.transformy = 1.03
movecopy_featdata.transformz = 0.74
boolstatus = movecopyfeat.modifydefinition(movecopy_featdata, part, nothing)
movecopy_featdata.releaseselectionaccess
end sub
dear luke,
appreciate your effort and time.
i ever implemented the example in c# to be familiar with movecopybodyfeaturedata. this example is little bit different from what i am doing.
now i have to "addmate" for two parts in one part document. as mt is not null, i tried to continue by executing "modifydefinition". then solidworks exits. i think it is the problem of "swaddmateerror_erroruknown" when i call "addmate" api function. i also tried different approaches. but it doesn't work too.
i sent support request to solidworks. hopefully, they can provide a solution for this issue.
thanks again for your help, luke.
newform
yes i did the exact example in c# before myself but i was also getting null for the mt variable too as well as the unknown error.
the example i provided was one i took from the help file to see if the function was working on an official example and it wasn't on that either so i presume it is a bug. lets see what they say.
thank you, luke,
i will let people here about the solution if i get their reply.
thank you, luke,
i will let people here know about the solution if i get their reply.
quick
yang686526离线中   回复时引用此帖
GDT自动化论坛(仅游客可见)
 


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

高级搜索
显示模式

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

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

相似的主题
主题 主题发起者 论坛 回复 最后发表
【转帖】macro to update dimension has an error message yang686526 SolidWorks二次开发 0 2009-04-12 06:56 PM
OpenCSG-1.0.2 sample yogy vc编程 2 2007-07-22 04:43 PM


所有的时间均为北京时间。 现在的时间是 04:40 AM.


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