.NET

Reply
Active Contributor
kylei7449
Posts: 32
Registered: ‎10-16-2012
Message 1 of 2 (126 Views)

AcSmComponents17 1.0 library missing/Code Help

126 Views, 1 Replies
02-08-2013 12:53 PM

I'm not a programmer so my question may seem obvious. I'm trying to run this code and it gives me a library missing error. I changed the reference from 17 to the AcSmComponents18 library. Now it gives me a runtime error "can't create object."  [at the Set sheetSetMgr = New AcSmSheetSetMgr line]

 

Does anyone know how I can get this code to run in ACAD 2010...thx

 

 

' 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

 

Option Explicit

Dim sheetSetMgr As IAcSmSheetSetMgr

Dim sheetdb As IAcSmDatabase

 

' Lets count up Sheets and iterate through all open SheetSets

Public Sub SetSheetCount()  

Dim sheetCount As Integer  

Dim iterDb As IAcSmEnumDatabase  

Dim ItemDb As IAcSmPersist    

 

Set sheetSetMgr = New AcSmSheetSetMgr    

Set iterDb = sheetSetMgr.GetDatabaseEnumerator  

Set ItemDb = iterDb.Next      

Do While Not ItemDb Is Nothing    

Set sheetdb = ItemDb      

' Lock Database    

LockDatabase      

 

On Error Resume Next        

 

Dim sheet As IAcSmSheet    

Dim iter As IAcSmEnumPersist    

Dim Item As IAcSmPersist          

Set iter = sheetdb.GetEnumerator    

Set Item = iter.Next        

Do While Not Item Is Nothing      

Set sheet = Item              

If Item.GetTypeName = "AcSmSheet" Then        

sheetCount = sheetCount + 1      

End If          

Set Item = iter.Next    

Loop      

' Apply the Sheet Count as a custom property    

Dim cBag As IAcSmCustomPropertyBag    

Dim cBagVal As New AcSmCustomPropertyValue      

Set cBag = sheetdb.GetSheetSet().GetCustomPropertyBag      

cBagVal.InitNew cBag

    cBagVal.SetFlags CUSTOM_SHEETSET_PROP    

cBagVal.SetValue CStr(sheetCount)      

cBag.SetProperty "Total Sheets", cBagVal        

Set cBagVal = Nothing        

 

' Unlock the database    

UnlockDatabase        

 

' Clear and check for next SheetSet that is open    

sheetCount = 0    

Set ItemDb = iterDb.Next  

Loop

End Sub

 

' Used to Lock the database back up (SheetSet)

Private Sub LockDatabase()    

On Error Resume Next        

Dim lockStatus As AcSmLockStatus    

Let lockStatus = sheetdb.GetLockStatus

    If lockStatus = AcSmLockStatus_UnLocked Then      

sheetdb.LockDb sheetdb    

End If

End Sub

 

' Used to Unlock the database back up (SheetSet)

Private Sub UnlockDatabase()    

On Error Resume Next        

Dim lockStatus As AcSmLockStatus    

If lockStatus = AcSmLockStatus_Locked_Local Or AcSmLockStatus_Locked_Remote Then      

sheetdb.UnlockDb sheetdb    

End If

End Sub

*Expert Elite*
norman.yuan
Posts: 961
Registered: ‎04-27-2009
Message 2 of 2 (113 Views)

Re: AcSmComponents17 1.0 library missing/Code Help

02-08-2013 02:49 PM in reply to: kylei7449

Is your code VBA code or VB.NET API code (since you post in .NET forum)? To me, it looks suspiciously like VBA code.

 

Also, you mentioned you use AutoCAD 2010, but did not mention it is 32-bit or 64-bit version. If the code is VBA code, 32/64-bit really matters.

 

That is, if the code is VBA code and you are using 64-bit AutoCAD, the code simply does not work and no way to fix. You need to find other workaround (i.e. use .NET API DLL in conjunction with 64-bit Sheet Manager COM interop).

You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.

Need installation help?

Start with some of our most frequented solutions to get help installing your software.

Ask the Community