PDA

View Full Version : Acad2005 SheetSets IAcSmFileReference object ?



KevinBarnett
2004-07-12, 10:57 AM
Greetings Gang,

How do you acquire and alter the properties of a SheetSets IAcSmFileReference object?

Here's the situation. I have appended code to the example sheet set VBA project file. The idea is to use the subset names as the new sheetset location folders. When you make a new sheet set the existing sub folders are used as the names of the subsets - for us, it would be ideal if the new sheet set location used the same folder (maybe we will adopt different concepts as we become more familiar with sheet sets). Anyway, the setnewsheetsetlocation subset method uses a IAcSmFileReference object and not a string to set the location. I just dont know how to acquire or use this object. The below code is appended to the SheetSet class in the example sheet set project.

This line:
FR.SetFileName RootFolder & Right$(SSetPath, Len(SSetPath) - 1)

produces this error:
The owner of the PerUser subscription is not logged on to the system specified.

Help! Please! ...

Thanks,

Kevin.


Public Sub FolderUpdate(db As IAcSmDatabase, RootFolder As String)

Dim iter As IAcSmEnumPersist
Dim Item As IAcSmPersist
Dim sheet As IAcSmSheet
Dim subset As IAcSmSubset
Dim osubset As IAcSmSubset
Dim SubOwner As IAcSmPersist
Dim SSetPath As String
Dim FR As IAcSmFileReference

Set iter = db.GetEnumerator
Set Item = iter.Next

Do While Not Item Is Nothing

If Item.GetTypeName = "AcSmSubset" Then
Set subset = Item
Set SubOwner = Item

SSetPath = "\" & subset.GetName
Int1 = 0
Do While SubOwner.GetTypeName <> "AcSmSheetSet"
Int1 = Int1 + 1
Set SubOwner = SubOwner.GetOwner
If SubOwner.GetTypeName = "AcSmSubset" Then
Set osubset = SubOwner
SSetPath = "\" & osubset.GetName & SSetPath
End If
Loop
Set FR = subset.GetNewSheetLocation
FR.SetFileName RootFolder & Right$(SSetPath, Len(SSetPath) - 1)
Err.Clear
On Error Resume Next
subset.SetNewSheetLocation FR
If Err <> 0 Then
MsgBox Err.Description
End If
End If

Set Item = iter.Next
Loop

ThisDrawing.Application.Update

End Sub

KevinBarnett
2004-07-21, 06:22 AM
Problem solved!

I had not locked the sheet set "database" before trying to change its data.

You must apply the LockDb method before writing code that changes the data.

Dim ssMgr As IAcSmSheetSetMgr
Set ssMgr = New AcSmSheetSetMgr
Dim db As IAcSmDatabase
Dim dbIter As IAcSmEnumDatabase
Set dbIter = ssMgr.GetDatabaseEnumerator
Set db = dbIter.Next 'gets the first sheet set database from the sheet set manager

'before changing data...
Call db.LockDb(db)

'now write code to change data

'on completion...
Call db.UnlockDb(db)

If you dont lock the sheet set database before trying to change data, then you get this error:
The owner of the PerUser subscription is not logged on to the system specified.

And the code that set the folder...

Public Sub FolderUpdate(db As IAcSmDatabase, RootFolder As String)

Dim iter As IAcSmEnumPersist
Dim Item As IAcSmPersist
Dim sheet As IAcSmSheet
Dim subset As IAcSmSubset
Dim osubset As IAcSmSubset
Dim SubOwner As IAcSmPersist
Dim SSetPath As String
Dim FR As IAcSmFileReference

Set iter = db.GetEnumerator
Set Item = iter.Next

Do While Not Item Is Nothing

If Item.GetTypeName = "AcSmSubset" Then
Set subset = Item
Set SubOwner = Item

SSetPath = "\" & subset.GetName
Int1 = 0
Do While SubOwner.GetTypeName <> "AcSmSheetSet"
Int1 = Int1 + 1
Set SubOwner = SubOwner.GetOwner
If SubOwner.GetTypeName = "AcSmSubset" Then
Set osubset = SubOwner
SSetPath = "\" & osubset.GetName & SSetPath
End If
Loop

Set FR = subset.GetNewSheetLocation

Err.Clear
On Error Resume Next
FR.SetFileName RootFolder & Right$(SSetPath, Len(SSetPath) - 1)

End If

Set Item = iter.Next
Loop

ThisDrawing.Application.Update

End Sub

Beware!!! This code is appended to the SheetSet Class of the sheetset example vba project supplied with AutoCAD 2005.

Have a great day,

Kevin.

RobertB
2004-07-22, 12:18 AM
I'm glad you figured it out and posted the solution!