AutoCAD MEP
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic to the Top
- Bookmark
- Subscribe
- Printer Friendly Page
*W, Matt
Count devices via VBA
Options
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
128 Views, 2 Replies
11-24-2003 12:10 AM
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.
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)
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
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".
count for each "objDeviceStyle".
I know it's something easy, but I'm just gonna
chalk it up to it being a Monday.
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.
*[Autodesk], Hakan Wikemar
Re: Count devices via VBA
Options
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
11-24-2003 04:36 PM in reply to:
*W, Matt
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.
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)
following: (Prints the stylename for everey ocurrance)
Public Sub CountDevices()
Dim obj As
AcadObject
Dim aDevice As AecbDevice
Dim obj As
AcadObject
Dim aDevice As AecbDevice
For Each obj In
Application.ActiveDocument.Database.ModelSpace
If TypeOf
obj Is AecbDevice Then
Application.ActiveDocument.Database.ModelSpace
If TypeOf
obj Is AecbDevice Then
Set
aDevice = obj
Debug.Print
aDevice.StyleName
End If
Next obj
End
Sub
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: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.
*W, Matt
Re:
Options
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
11-24-2003 09:35 PM in reply to:
*W, Matt
Ah ha!!
I knew I needed some kind of an
array.
array.
I took a look at your code in the CF group and
that's exactly what I was looking to do (and then some).
that's exactly what I was looking to do (and then some).
Thanks, Hakan!
--
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.
