Jump to content

SheetSet VBA index


KaiBo

Recommended Posts

I have written some code that pulls sheets and subsets from the sheetset manager, but the information that comes out, is out of order. Is there a way to pull this information out in the same order that it appears in the sheetset manager pallet? Or is there a way to get some kind of index number for each sheet and subset?

Pulling the page numbers, does not help, because our page numbers have letters and numbers.

Dim ShtNum As String
Dim oSubset As AcSmSubset
Dim pSubset As AcSmSubset
Dim oSheet As AcSmSheet
Dim oItem As IAcSmPersist
Dim ShSetAR(1 To 3, 1 To 200) As String 
Dim ShSetARCount As Integer

'' Synchronize Sheets with Sheet Properties
Private Sub CopyShsetarray()
'' Create a Reference to the Sheet Set Manager Object
   Dim oSheetSetMgr As AcSmSheetSetMgr
   Set oSheetSetMgr = New AcSmSheetSetMgr
'' Get the current Sheet Set
   Dim oSheetDb As AcSmDatabase
   Set oSheetDb = oSheetSetMgr.GetDatabaseEnumerator().Next
'' Get the objects in the Sheet Set
   Dim oEnum As IAcSmEnumPersist
   Set oEnum = oSheetDb.GetEnumerator
'' Get the first object in the Enumerator
MsgBox oSheetDb.GetFileName
   Set oItem = oEnum.Next
'' Step through all the objects in the Sheet Set
MsgBox oItem.GetTypeName
       Do While Not oItem Is Nothing

'' Add Item to Array
On Error Resume Next

           If oItem.GetTypeName = "AcSmSheet" Or oItem.GetTypeName = "AcSmSubset" Then
               ShSetARCount = 1 + ShSetARCount
               Set pSubset = oItem.GetOwner()
               ShSetAR(2, (ShSetARCount)) = pSubset.GetName
               ShSetAR(3, (ShSetARCount)) = oItem.GetTypeName
                   If oItem.GetTypeName = "AcSmSheet" Then
                       Set oSheet = oItem
                       ShSetAR(1, (ShSetARCount)) = ShtNumFromPath(oSheet.GetLayout.GetFileName)
                       Else
                       Set oSubset = oItem
                       ShSetAR(1, (ShSetARCount)) = oSubset.GetName
                   End If
               'MsgBox ShSetARCount & "___" & ShSetAR(1, (ShSetARCount)) & "___" & ShSetAR(2, (ShSetARCount)) & "___" & ShSetAR(3, (ShSetARCount))
           End If

'' Get the next Sheet
       Set oItem = oEnum.Next
       Loop
       Next
End Sub

Link to comment
Share on other sites

Hi Kaibo,

I am not totally sure what you are asking, however, this line

Dim ShSetAR(1 To 3, 1 To 200) As String 'number of used rows in (1,0)

may be a problem.

 

Shouldn't those values be declared as integers as opposed to string variables?

 

ML

Link to comment
Share on other sites

Ml0940,

no it should not be integers, because I'm not trying to put integers in the array. for each sheet or subset in the sheetset I am putting in the name of the Item, it's parent name, whether it's a sheet or subset, and Ideally it's position in the sheetset. Only the last of these items is an integer, and I can’t figure out how to pull that information yet.

I’m basically trying to create a link between our database and our sheetsets, and I need to know the order that things appear in the sheetset, because some of our employs don’t understand the complicated way our package needs to be arranged.

Link to comment
Share on other sites

I see, it is a string array.

 

Yes, I understand the value of Sheet Sets and fields; once they are understood, they are very useful for streamlining some things.

 

I have a VBA project that I did "almost" a year ago; I have been away from CAD and VBA for a few months now, however, I would be glad to share the project with you.

 

I can not guarantee that it will get you what you need, but you can certainly take a look.

 

Also, the sheet set manager automatically creates an index of each drawing. Again, I am rusty, but I may recall that you have have to loop through each Set to get to the subset.

 

Well, if you'd like, I can get you the project?

 

ML

Link to comment
Share on other sites

The Sheet Sets are tricky, and the VBA code is bizarre, compared to other VBA/ACAD code.

 

I recall spending a lot of time trying to find "any" info on Sheet Set code; there may be more since.

 

OK,

I am attaching The Project; you will need to unzip it.

 

The primary function of this project was to deal with custom fields, however, I think that the answer you need "may" be in The CustomSheetSetProps Module, Sub routine: LoopThroughSheets.

 

I believe that I am using all of the functions except for The MiscFunctions, which were extra, for a later time.

 

I hope this helps.

 

Let me know how you make out.

 

ML

CustSheetSetProps-1.zip

Link to comment
Share on other sites

Kaibo,

I meant to say custom properties and fields, however, the same holds true; you would still need to iterate through each Drawing Set and Subset to get to your custom properties; that is why I am pretty sure that you will find what you need in there.

 

I do recall it working 100%, last time I used it.

 

OK, well, again, let me know how you make out.

 

ML

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...