Hi fellow hackers,
I am looking for a way to count "smart" elements using VBA.
I plan to use the ElementEnumerator together with BuildArrayFromContents, to get the count.According to this old post from 2012, the smart elements should be exposed in vba by now, but I don't see that. I really don't wanna go through all the elements if I don't have to, but anything will be better than nothing.
- I don't see them anywhere in the manual?- The ElementScanCriteria does not have any msdElementType constant defined that indicates it is a smart element. (like msdElementTypeShape would be used to filter shapes)
I speculate..
They might be cell elements, and the elementenumerator still doesn't know how to find them? Maybe I must use the ElementScanCriteria IncludeSubtype? But I see no information about the subType (assuming) constants anywhere in the manual. All the manual says is that the subType is a long?
Maybe I don't have the "new" vba installed? I notice the title of the F1-Help document says Microstation V8 Visual Basic for Applications help, (and not v8i SS3)
But any ideas on how to get the count of smart solids/surfaces are welcome :)
Bentley Accredited Developer: iTwin Platform - AssociateLabyrinth Technology | dev.notes() | cad.point
Answer Verified By: Torben
System: Win7 64bit 16GB Ram - microStation V8i SS3 08.11.09.578. + PoinTools CONNECT. - Intel i7-4800MQ CPU@2.70GHz, 4 core / 8 Logic proc.
Unknown said:If you say so, then that is probably my best shot.
You should not trust me too much, there is always a chance I am (completely) wrong ;-)
Regards,
Jan
Hah! So True. Fortunately the results matter more than the road in most programming-cases ;) Knowing that you don't know everything, but still provide a solution (indstead of arrogantly saying "no-way") is pretty much what counts - There are plenty nay-sayers around. Using the PropertyHandler for 1000's of cells is not noticeable slowing my project. We are talking milliseconds. (Loading the DGN's and huge DWG's are!)
Hello,
may be I'am wrong, but is this the function you are looking for?
Public Sub SolidCount() Dim count As Long Dim ee As ElementEnumerator Dim oscan As ElementScanCriteria Set oscan = New ElementScanCriteria oscan.ExcludeAllTypes oscan.IncludeType msdElementTypeSolid count = 0 Set ee = ActiveModelReference.GraphicalElementCache.Scan(oscan) Do While ee.MoveNext 'Debug.Print ee.Current.Type count = count + 1 Loop MsgBox CStr(count) & "Solids" End Sub
Best Regards
Martin
Unknown said:Lazy Bentley programmers!
The current situation (in V8i) is mostly because of historical reasons as different approaches and modelling tools were implemented.
The completely new technology based internally on dynamic construction of parametric objects (so no more cells and nested nested nested cells with tons of attributes) is a proof Bentley programmers are not lazy ;-)
Unknown said:as something in the scanning is actually taking ages.
VBA is not good environment for scanning huge datasets, because it requires very intensive memory allocation, which is even worse because of slow VBA API. Maybe your code can be enhanced to be faster, but in generall VBA scanning is always slow.
I take your word on that whole programmers not being lazy thing.. From a personal point of view, I code because I am lazy! I am probably the most lazy person I know - which has led to automations saving thousands of hours for my coworkers. ;)
Unknown said: VBA is not good environment for scanning huge datasets, because it requires very intensive memory allocation...
VBA is not good environment for scanning huge datasets, because it requires very intensive memory allocation...
True that. On a side note, and something that might pop up in another thread sometime: It seems the culprit is getting details from levels, but even that is to be honest fairly fast. About the whole "time" issue: My coworkers asked how long it would take to re-analyze all our files, and I replied "ages"... They looked scared.. .. "something like 20 minutes", and they literally laughed in relief! :D Time is indeed relative ;) The manual process would take weeks if not more and be very prone to human errors. Heh! :)