Community
style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
"Matt W" <mattw@bvhis.com>
wrote in message
href="news:1023E691E6DD2CEFC185355AF8B161BD@in.WebX.maYIadrTaRb">news:1023E691E6DD2CEFC185355AF8B......
I want to do a quick count of devices in a
drawing and I want to do it via VBA, but I'm running into a wall on how to do
it.
(I know I can create a schedule, but I don't
want to)
Here's what I have so far...
Public Sub CountDevices()
Dim objDeviceStyle As AecbDeviceStyle
Dim
objDeviceStyles As AecbDeviceStyles
Dim aecDB As New
AecbDatabase
aecDB.Init
ThisDrawing.Database
Set objDeviceStyles =
aecDB.DeviceStyles
For Each
objDeviceStyle In
objDeviceStyles
If
objDeviceStyle.Name <> "Standard"
Then
Debug.Print objDeviceStyle.Name
End If
Next objDeviceStyle
End Sub
I can't quite figure out how to get the total
count for each "objDeviceStyle".
I know it's something easy, but I'm just gonna
chalk it up to it being a Monday. 🙂
Thanks in advance!
--
Matt W
There are 3 kinds
of people:
Those who can count, and those who
can't.
style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
"Hakan Wikemar [Autodesk]" <
href="mailto:hakan.wikemar@autodesk.com">hakan.wikemar@autodesk.com>
wrote in message
href="news:A0E322DC63BD64B0540948A1C9C9E5C4@in.WebX.maYIadrTaRb">news:A0E322DC63BD64B0540948A1C9C......
Hi Matt!
The Code you have produced works fine when it
comes to identifying the device styles that exist in the drawing, imported
styles, inserted or not. However, if you want to scan the drawing of how many
devices there is in it you will need to search through the modelspace or
dictionaries databases. The easiest way (in my experience) is to
scan through the modelspace, you will then only get the devices that are
actually inserted into the drawing. If you look at my VBA project below the
header DEVICE COUNT in the autodesk.autocad.customer-files newsgrop (a part of
a discussion I had about Device Counting in the BS wishes discussion
newsgroup), you might find it useful, it counts the presence of devices and
groups them by system and style.
The basic syntax I usually use is the
following: (Prints the stylename for everey ocurrance)
Public Sub CountDevices()
Dim obj As
AcadObject
Dim aDevice As AecbDevice
For Each obj In
Application.ActiveDocument.Database.ModelSpace
If TypeOf
obj Is AecbDevice Then
Set
aDevice = obj
Debug.Print
aDevice.StyleName
End If
Next obj
End
Sub
I hope this helps
/Hakan Wikemar
style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
"Matt W" <mattw@bvhis.com>
wrote in message
href="news:1023E691E6DD2CEFC185355AF8B161BD@in.WebX.maYIadrTaRb">news:1023E691E6DD2CEFC185355AF......
I want to do a quick count of devices in a
drawing and I want to do it via VBA, but I'm running into a wall on how to
do it.
(I know I can create a schedule, but I don't
want to)
Here's what I have so far...
Public Sub
CountDevices()
Dim objDeviceStyle As
AecbDeviceStyle
Dim objDeviceStyles As
AecbDeviceStyles
Dim aecDB As New
AecbDatabase
aecDB.Init
ThisDrawing.Database
Set objDeviceStyles =
aecDB.DeviceStyles
For Each
objDeviceStyle In
objDeviceStyles
If
objDeviceStyle.Name <> "Standard"
Then
Debug.Print
objDeviceStyle.Name
End
If
Next objDeviceStyle
End Sub
I can't quite figure out how to get the total
count for each "objDeviceStyle".
I know it's something easy, but I'm just gonna
chalk it up to it being a Monday. 🙂
Thanks in advance!
--
Matt W
There are 3
kinds of people:
Those who can count, and those who
can't.