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.
Answer Verified By: Jon Summers
Brien Bastings 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 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.
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.
sure, i will try with different options, thanks
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
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,
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:
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);
WPrintfString wStr(L"isSame = %d", isSame);