I wrote some VBA code to compare two elements. The VBA code calls into the MDL. The VBA code uses mdlElmdscr_areIdenticalToTolerance because mdlElmdscr_areTwoIdentical never returns True.
Is mdlElmdscr_areTwoIdentical broken?
mdlElmdscr_areTwoIdentical just does a memcmp of the element data...so unless you created the 2nd descriptor by calling mdlElmdscr_duplicate you do want to allow for some "fuzz" in the comparison of doubles, etc.
HTH
-B
Answer Verified By: Jon Summers
Unknown said:mdlElmdscr_areTwoIdentical just does a memcmp of the element data
Two otherwise identical elements will have different and unique Element IDs. Since the Element ID is part of an element's data (see struct elm_hdr in mselems.h), performing memcmp on two MSElements will always tell us that they are different.
Consequently, mdlElmdscr_areIdenticalToTolerance is a better choice — not because of the tolerance parameters, but because of the comparison flags. The flags (see header file mselmdsc.fdf) let us instruct MicroStation to ignore certain data, such as the Element ID, when comparing two elements.
Regards, Jon Summers LA Solutions
Hi Jon, I use this mdlElmdscr_areIdenticalToTolerance api to compare the two duplicated mesh elements, but the result is always false,
do u know why it happens?
bool isSame = mdlElmdscr_areIdenticalToTolerance(preEle, curEle, COMPAREOPT_STANDARD_IGNORES, 0.1, 0.1);
Rick cheng said:I use this mdlElmdscr_areIdenticalToTolerance api
With which version (e.g. v10.x.y.z) of MicroStation?
You might like to experiment with different values of COMPAREOPT_XXX.
V8i: #include <mselmdsc.fdf> V10: #include <Mstn/MdlApi/mselmdsc.fdf>
Hi Rick cheng,
As a forum best practice, it is best to ask New questions as New posts, then simply copy the URL of a related issue like this one as reference within "your" (new) post. This helps ensure 1 question has the highest success of having 1 verified answer.
With respect to you question.
Mesh elements are "complex" elements and with complex elements and comparison, the siblings/children elements can be "identical", yet created and stored in completely different order. To ensure an identical comparison result can be returned such cases, you can bitwise OR the value below and hopefully get the results you expect.
Mstn\MdlApi\mselmdsc.fdf:2865:#define COMPAREOPT_IGNORE_UNORDEREDSIBLINGORDER
If not, possibly attach a "simple" design file (Test Case) only having 2 elements in question so that we can examine your test more closely.
HTH,Bob
sure, i will try with different options, thanks
forImport.dgn
i try with the new option, but still return false.
my code is as below,
bool isSame = mdlElmdscr_areIdenticalToTolerance(preEle, curEle, COMPAREOPT_IGNORE_UNORDEREDSIBLINGORDER, 0.1, 0.1);
I am running with Microstation CE, 10.07.00.39
thanks,
Rick
please check the attached dgn model for mesh element compare. thanks,
hi Robert Hook can you help check why i can't get it work for attached dgn model. thanks,
Hi Rick,
When I tested your DGN in my box, mdlElmdscr_areIdenticalToTolerance always returns true for me even only use compare option COMPAREOPT_STANDARD_IGNORES. I am testing on MSCE U12. The test code is as below:
void compareElems() { MSElementDescrP preEle, curEle; mdlAssoc_getElementDescr(&preEle, NULL, 798L, ACTIVEMODEL, FALSE); mdlAssoc_getElementDescr(&curEle, NULL, 803L, ACTIVEMODEL, FALSE); bool isSame = mdlElmdscr_areIdenticalToTolerance(preEle, curEle, COMPAREOPT_STANDARD_IGNORES, 0.1, 0.1); mdlElmdscr_freeAll(&preEle); mdlElmdscr_freeAll(&curEle); WPrintfString wStr(L"isSame = %d", isSame); mdlDialog_dmsgsPrint(wStr); }