.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

AcSmComponents17 1.0 library missing/Code Help

1 REPLY 1
Reply
Message 1 of 2
kylei7449
424 Views, 1 Reply

AcSmComponents17 1.0 library missing/Code Help

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

1 REPLY 1
Message 2 of 2
norman.yuan
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).

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost