|
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 |
|