It is great to see people are starting to use AutoCAD 2005, only days after it has started to ship. However, there have been many questions in the area of Sheet Sets of how to do certain things. One of these issues is how to get a Total Number of the Sheets in a Sheet Set and then use that number in a Field. There is no built in value for this, but you can use a custom property. Now that leads to manual work, so during my lunch hour I decided to tackle how to use the new Sheet Set API. I have a pretty good handle on the API, but there could be some improvements in the code that I am about to post. The improvement that I am looking at is the ability to use events that SheetSets have. Maybe, next lunch hour.
' Written by Lee Ambrosius
' Date: 3/24/04
' Program is provided AS-IS with no expressed written warranty
' This example demonstrates a couple of the new SheetSet API and some of its
' many properties and methods
' It creates a custom property at the Sheet Set level called "Total Sheets"
SheetCount.dvb
To use it follow the directions below after the file has been downloaded and unzipped.
1. Drag 'n drop the DVB module or use APPLOAD to load the project file
2. Start VBAMAN click on the Macros button and select the macro called basSheetCount.SetSheetCount
3. Click the run button
You should see the custom property added to the SheetSet. I see that Events can be trapped from Sheet Set Manager so I am going to look into that as a future change. Let it will be just a mater of loading the module and it should take care of recounting Automatically.
Hope you find value in the routine above.
Sincerely,
Lee Ambrosius
Hey, awesome VBA script! Thanks for posting it. I installed it and it ran like a charm. I notice that if I add or remove a sheet to the Sheet Manager, I have to run the macro again before it recounts. No biggie, though.
Posted by: Rob Roy | Wednesday, November 10, 2004 at 07:22 PM
Hi Lee,
Tried your script in Map 2005 3D and it comes up with a type mismatch at the Set sheet = Item line. Any ideas about why it might be doing this? Cheers.
Chris
Posted by: Chris Duke | Monday, January 31, 2005 at 09:28 AM
dear sir !
I am interested in Vba of autocad. But for along times, i found but i could'n find.So, can you show me how to get things.Thank alots
Posted by: TONG QUANG VINH | Wednesday, November 23, 2005 at 04:23 AM
Hello,
I stumbled onto this and wanted to apply it to our stuff, however we are a MEP firm, is there anyway for this to work in separate sub catagories? For example Mechanical, Electrical, and Plumbing.
Posted by: Mike McCall | Friday, July 14, 2006 at 12:54 PM
It shouldn't be a problem to step through a sheet set and figure out what drawings are under which caregories. However, you would need to create multiple different custom properties to hold the sheet count for each category, but it should be workable though.
Posted by: Lee | Friday, July 14, 2006 at 01:43 PM
I tried using this on AutoCAD 2007, but I get the following:
run-time error '-2147024770 (8007007e)':
Automation error
The specified module could not be found
Did I need a different code-snippet from you as well to run the thing?
this is a tool I could really use.
Posted by: Jon Trostad | Thursday, November 09, 2006 at 11:49 AM
The only thing that you should need to do to get the app to run under AutoCAD 2007 is change the library reference of the Sheet Set Object. To do this, follow the instructions below:
1. Open the project in the VBA Editor
2. Click Tools > References
3. Uncheck AcSmComponents16 1.0 Type Library
4. Check AcSmComponents17 1.0 Type Library
5. Click OK
6. Run the project
Posted by: Lee Ambrosius | Tuesday, November 21, 2006 at 08:38 AM
I am trying to adapt the SheetSet.DVB file that ships with ACAD to work with VB.
Whenever I try to create any SSM object, I get "Automation Error -- The specified module could not be found" error.
The code runs fine in VBA (both the SheetSet example from AutoCAD and my own application). Neither works in "straight" VB6, however.
Class code snippet
------------------------------
Private moSSM as AcSmSheetSetMgr
Public Setup()
...
Set moSSM = New AcSmSheetSetMgr
...
End Sub
-----------------------------------
The Set command generate the error. I have tried all manner of variations (like CreatObject) without success.
Any idea what is happening? Any assistance wold be appreciated.
Victor
Posted by: P. Victor Grambsch | Monday, May 21, 2007 at 01:23 PM
The blog article very surprised to me! Your writing is good. In this I learned a lot! Thank you!
Posted by: Rerto Jordans | Wednesday, June 23, 2010 at 07:17 PM