Good evening people :-)
Do you know how ScanCriteria works? In which way ScanCriteria finds out elements in the space? Can I (code) drive the "scan" through the space?
I am going to (try to) explain myself.
For example, I hava a 3D dgn file where, in the Default model, same level, I have 3 "lines" of pipes.(separate and casually arranged in space)
Each line has two or more pipes. Each pipe is a cell.
My aim is fill "Description" field of CellElement with a progressive ID; first one is given by user.
Each pipe of the same line has to have a continuous ID.
For example: if Line 1 has 3 pipes and the starting ID is "AA-021", first pipe will be named "AA-021", 2nd "AA-022" and 3rd "AA-023".
Using ScanCriteria, I got an ElementEnumerator filled with right elements (in this case, cells) but in a order apparently random.
So the naming appears randomly and without a sense: for example: for Line 1 I could have first pipe named "AA-021", 2nd "AA-024" and 3rd "AA-027". And "AA-022" is given to a pipe of Line 2 and may "AA-023" is given to Line 3....
Any suggestions?
Thanks a lot.
Bye,
Paolo
Hi Paolo,
a few comments from "strictly tech & dev perspective":
Paolo Maggiani said:Do you know how ScanCriteria works?
No, it's an internal implementation detail. The functionality is defined by API documentation and you cannot expect more (so no order is ensured).
Of course, we can "assume" how it's implemented, because it's quite simple: Design file (graphical element cache in this case) is iterated in the same order as elements are stored in the file.
Paolo Maggiani said:In which way ScanCriteria finds out elements in the space?
No such rule is defined, the scanning file does not work in any relation to 2D / 3D space (when range criteria is not used).
Paolo Maggiani said:For example, I hava a 3D dgn file where
Don't use words! Use DGN example or at least screen capture. It will provide more information. We are typically engineers, so we don't like words, but we love drawings and pictures ;-)
Paolo Maggiani said:but in a order apparently random.
Nothing in software development is random ... in fact, to create something (really) random is extremely complex math and dev task (because normal random methods provided by standard libraries are pseudo-random, not random).
As I wrote above, my assumption (I never though about it, because "order" makes no sense) is that it's defined by elements order in DGN file. Which can be ... any. Originally it's equal to how elements are drawn, but when the file is modified, the order can change and become very different quickly (but still not random, because it's changed accordingly to rules and DGN file format specification).
Paolo Maggiani said:Any suggestions?
You have to create a list of found cells in the first step, analyze design file content (a kind of topology analysis) and to link cells in the list with their positions.
Because you do not provide any example how the drawing look like, it's hard to eve guess how complicated it can be.
Frankly, I think VBA is not very good tool to implement such code, because often this type of tasks leads to comparing different lists and VBA does not contain good support for lists. But the complexity really depends on drawings structure (to find "cells on line from left to right" is much simpler than e.g. general algorithm to analyze complete drawing).
With regards,
Jan
Bentley Accredited Developer: iTwin Platform - AssociateLabyrinth Technology | dev.notes() | cad.point
It's not easy, for the reasons that Jan has stated.
Here's an example of spatial analysis using VBA: a Text Table exporter. It analyses a 2D 'table' of text and writes a CSV file. The catch is that, depending on how the DGN model was edited, the text is not organised except how it's viewed by the human eye. The code has to make sense of that disorganised text.
VBA is not my choice programming language for this work. C++ and .NET offer much better flexibility and capability when handling and sorting collections. Those languages make the programmer's life easier. They are also faster than VBA at run-time, although performance is not an issue in that example.
The VBA project provides an example of ScanCriteria and spatial analysis. From your description, I guess that your 'pipes' are even less organised than the text in that 'table'.
Regards, Jon Summers LA Solutions
Here's an article about the MicroStation scanner for programmers.
Let me know if it helps.