Using code from http://www.la-solutions.co.uk/content/CONNECT/mvba/MVBA-ElementsIdentical.htm trying to implement duplicate element removal utility in VBA.
It seems to work for identical elements but there is inconsistent results when not using COMPAREOPT_IGNORE_LEVEL flag. It still deletes lines which are in different levels.
See attachment DGN and MVBA:
.Duplicates-levels.dgn
6521.deldup.mvba
Oto said:Using code from http://www.la-solutions.co.uk/content/CONNECT/mvba/MVBA-ElementsIdentical.htm
I've revised the function declaration on that page. I doubt that's the source of your problem, but it helps if I publish correct information!
Regards, Jon Summers LA Solutions
How sure you are about the flag constants? For me it seems removing COMPAREOPT_IGNORE_LEVEL doesn't work it still ignores level.
Oto said:How sure you are about the flag constants?
Here are the original definitions, found in C++ header file ..\include\Mstn\MdlApi\mselmdsc.fdf...
..\include\Mstn\MdlApi\mselmdsc.fdf
#define COMPAREOPT_IGNORE_MODEL_DIFFS (1<<0) #define COMPAREOPT_IGNORE_SYMBOLOGY (1<<1) #define COMPAREOPT_IGNORE_IDS (1<<2) #define COMPAREOPT_IGNORE_LINKAGES (1<<3) #define COMPAREOPT_IGNORE_MODIFIED (1<<4) #define COMPAREOPT_IGNORE_DGNSTORE (1<<5) #define COMPAREOPT_IGNORE_ATTRIBUTE_VALUE (1<<6) #define COMPAREOPT_IGNORE_SINGLE_EDF_VALUES (1<<7) #define COMPAREOPT_IGNORE_CELL_RANGEDIAG (1<<8) #define COMPAREOPT_IGNORE_DGNDWGTEXTDIFFERENCES (1<<9) #define COMPAREOPT_IGNORE_2D_RANGEZ (1<<10) #define COMPAREOPT_IGNORE_MULTISPANNINGSIBLINGBOUNDARIES (1<<11) // Set to compare en masse logical entities that may span multiple siblings of a complex header (e.g., B-spline surface boundary and // matrix data elements). Default (unset) enforces element-to-element comparison of such siblings. #define COMPAREOPT_IGNORE_UNORDEREDSIBLINGORDER (1<<12) // Set to compare sibling elements that may appear under a complex header in any order (e.g., matrix children of a mesh element). // Default (unset) enforces ordered comparison of such siblings. #define COMPAREOPT_IGNORE_LINESTYLEDIRECTION (1<<13) // Ignore all but linestyle scale. #define COMPAREOPT_IGNORE_LEVEL (1<<14) #define COMPAREOPT_IGNORE_2D_ZRANGE (1<<15) #define COMPAREOPT_IGNORE_CELL_TRANSFORM (1<<16) #define COMPAREOPT_IGNORE_XATTRIBUTES (1<<17) #define COMPAREOPT_TEST_FACEMATERIALS (1<<18) #define COMPAREOPT_IGNORE_INVISIBLE_ELEMENTS (1<<19) // If both elements are invisible say they are the same. #define COMPAREOPT_IGNORE_ELEMENT_CLASS (1<<20) #define COMPAREOPT_IGNORE_CELL_HEADER_ELM (1<<21) #define COMPAREOPT_STANDARD_IGNORES (COMPAREOPT_IGNORE_MODEL_DIFFS | COMPAREOPT_IGNORE_SYMBOLOGY | COMPAREOPT_IGNORE_IDS | COMPAREOPT_IGNORE_LINKAGES | COMPAREOPT_IGNORE_MODIFIED | COMPAREOPT_IGNORE_XATTRIBUTES)
Where 1<<N means 'left-shift one by N bits'.
1<<N
If you are only comparing lines (as per your sample file), to validate that your code is looping correctly, why note write a primitive element comparison function using a simple set of nested if statements which can compare the basic attributes of lines: e.g. Level/Class/Colour/Lineweight/Linestyle/Start & Endpoint locations etc...?
At least with that you can view what your loop does and if its not performing unrequired loops and giving expected results, then plug Jon's MDL function code back in. At least then you can be sure what you are passing to it, is working correctly.
Jon Summers said:Here are the original definitions, found in C++ header file ..\include\Mstn\MdlApi\mselmdsc.fdf..
What endian it is and how to translate it to VBA?
Oto said:What endian it is
Irrelevant.
Oto said:How to translate it to VBA?
I've already provided that here.
I give up it simply doesn't work.
Oto said:I give up it simply doesn't work.
What's not working?
Why don't you post where you've gotten too?
I got nowhere. I input not identical lines as from first post and the compare function returns them as identical. It is black box I can't verify what is happening.
Did you try what I suggested?
Hi Oto,
FWIW.
For #2 above I suggest to consider providing these 3 states to add some clarity to the problem you are seeing...
Bob