[V8 MDL] Is mdlElmdscr_areTwoIdentical broken?

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?

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

    Answer Verified By: Jon Summers 

  • 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);

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

     
    Regards, Jon Summers
    LA Solutions

  • Hi ,

    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



Reply
  • Hi ,

    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



Children