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