I have a problem with the function mdlScanCriteria_setXAttributeTest mentioned by Yongan.Fu in this post:https://communities.bentley.com/products/programming/microstation_programming/f/microstation-programming---forum/115328/v8i-c-finding-xattribute-data-in-a-model-file/353836#353836
When setting a XAttribute as a Filter, this function does not look into Cells. Same for ParametricCells but there I do not get any Information's no matter if scanning or looking directly into it, but this as a side note. Other Elements are found with that function and when not using mdlScanCriteria_setXAttributeTest I get all Elements inside a Cell (ParametricCells still doesn't work). The same code does work in V8i.The C# Code:
BCOM.ElementScanCriteria scanCri = new BCOM.ElementScanCriteriaClass(); scanCri.ExcludeNonGraphical(); mdlScanCriteria_setReturnType(scanCri.MdlScanCriteriaP(), 1 , 0 /* FALSE */, 2 /* TRUE */); XYZmdlScanCriteria_setXAttributeTest(scanCri.MdlScanCriteriaP(), 42 , 42); BCOM.ElementEnumerator num = currentModelRef.Scan(scanCri); BCOM.Element[] arrElemente = num.BuildArrayFromContents();
XYZmdlScanCriteria_setXAttributeTest is Wrapped and in C++, the XAttributeID gets build. Both 42s are only used for the ID and I've replaced them here.
return mdlScanCriteria_setXAttributeTest(reinterpret_cast<ScanCriteriaP>(p_ScanCriteria), &h_XAttrID, XAttributeHandle::MATCH_ANY_ID, NULL);
mdlScanCriteria_setReturnType(scanCri.MdlScanCriteriaP(), 1 , 0 /* FALSE */, 2 /* TRUE */);gets used like this in V8i and works there. I do not know why true is a 2 but I've tried 1 also. Removing this line completely doesn't changed anything.Just getting all Elements with a specific XAttributeID would be faster
It's been a few days and no Ideas? Robert Hook do you have an idea?
Mit freundlichen Grüßen / Best regardsJean-Pierre Hundhausen
| AB_DATE Engineering Software | ab-date.de |
Hi Jean-Pierre Hundhausen and Volker HĂĽfner,
Arnab Gogoi had brought this thread to my attention this morning to try and review and provide any feedback possible.
From our meeting and review of this issue I find two fundamental questions/paths to pursue.
Fortunately I am seeing options for both; however there is the direct getting up and running with the old approach (recommended for now) and the find and recommend a new replacement CONNECT API (requires some additional exploration/investigation in order to recommend).
So, for #1. In our review we searched and found a few prior posts (this thread and Volker) leading to the progression to this thread and can state a couple points with a recommendation (if not current in your code):
From the code snip provided in this thread above (thank you), Given if all the other scancriteria is configured properly, then we have to question if the function prototype is correct - specifically the last parameter's: data type and how the value is passed. can you confirm your function prototype and value type passed conform to this signature?
MSCORE_EXPORT int mdlScanCriteria_setXAttributeTest (ScanCriteriaP scP, XAttributeHandlerId* handlerId, UInt32 attrId)
For #2 (new/replacement API recommendation). As mentioned at this time I do not have a concrete recommendation for a replacement API, though I suspect the new e.g. XAttributeHandle, XAttributeHandler API may likely provide an effective replacement, though I would need to see if I can find or create any code snips to exercise associated setup and call backs. I will try to place a few more cycles in on this in parallel to final preparations needed towards the MSCE SDK U14 release (sorry - no specific date I can announce yet).
In summary, please check the function prototype to see if it helps make this unpublished function come to life again for you and I will try to find a new replacement to recommend or file an enhancement if XAttributeHandle/XAttributeHandler API is not capable of replacing mdlScanCriteria_setXAttributeTest .
Please reply back to this thread with your results when possible.
Thank you and HTH,Bob
Hello Bob
thank you very much for your answer. While JP will collect some code snippets, I will try to explain the problem in a different way, hopefully somewhat clearer.
Think of a DGN file with 4 rectangles, each with an XAttribut, lets call them R1, R2, R3, R4. Let’s further consider (R3 x R4) are grouped to a cell.
With our V8i code, we will find R1, R2, R3, R4 fast. Great thanks to mdlScanCriteria_setXAttributeTest().
Our CE code with mdlScanCriteria_setXAttributeTest() will only find R1, R2, but not the nested R3 and R4. It also finds cells, if they have XAttributes. It seems setting this test will “optimize” the scan-process to scan only the outmost elements.
If we just comment mdlScanCriteria_setXAttributeTest() out, the scan with the same criteria’s will find R1, R2, R3, R4, and we have to try, if they have any XAttributes. This works of course, but it is awfully slow.
Mit freundlichen Grüßen / Best regards Volker Hüfner
Volker,
Thank you for clarifying the current problem statement further. Let me continue to check both paths #1 w/more priority and #2 as well.
Thank you,Bob
Robert Hook do you have any informations?
Robert Hook Its been a while. Is there an update to this issue?
Robert Hook U14 still has the same problem
Robert Hook Its been a while. U16 still has the same problems