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

Sheet Set: Access Sheet Properties

6 REPLIES 6
Reply
Message 1 of 7
ChrisPicklesimer
767 Views, 6 Replies

Sheet Set: Access Sheet Properties

I am able to access(list & modify) custom sheet properties within a sheet set via .GetCustomPropertyBag.  How are the OOTB sheet properties accessed?  Could someone point me in the right direction?

 

Thanks.

 

Chris

6 REPLIES 6
Message 2 of 7

Hi Chris,

 

Do you mean adding the custom properties to a sheet instead of a sheetset ?

 

If that is the case, it is very similar to the way the custom properties were added to the sheetset.

 

Here is a sample code :

 

    Private Sub SetSheetCustomProp()

        Dim doc As Document
        doc = Application.DocumentManager.MdiActiveDocument

        Dim ed As Autodesk.AutoCAD.EditorInput.Editor
        ed = doc.Editor

        sheetSetMgr = New AcSmSheetSetMgr

        Dim iterDb As IAcSmEnumDatabase
        iterDb = sheetSetMgr.GetDatabaseEnumerator

        Dim ItemDb As IAcSmPersist
        ItemDb = iterDb.Next

        sheetdb = ItemDb

        LockDatabase()

        Dim sheetsetEnum As IAcSmEnumComponent
        sheetsetEnum = sheetdb.GetSheetSet().GetSheetEnumerator()

        Dim sheetsetItem As IAcSmComponent
        sheetsetItem = sheetsetEnum.Next()

        Dim iterator As IAcSmEnumPersist
        iterator = sheetdb.GetEnumerator()

        Dim item As IAcSmPersist
        item = iterator.Next()

        While item IsNot Nothing
            Dim type As String
            type = item.GetTypeName()

            Select Case type
                Case "AcSmSheet"
                    'List the sheet
                    Dim sheet As IAcSmSheet = TryCast(item, IAcSmSheet)

                    Dim i As Integer
                    i = 0

                    Do While i < 5
                        Dim cBag As IAcSmCustomPropertyBag
                        Dim cBagVal As New AcSmCustomPropertyValue

                        cBag = sheet.GetCustomPropertyBag

                        cBagVal.InitNew(cBag)

                        cBagVal.SetFlags(PropertyFlags.CUSTOM_SHEET_PROP)
                        cBagVal.SetValue("Test" + i.ToString())

                        cBag.SetProperty("Test" + i.ToString(), cBagVal)

                        cBagVal = Nothing

                        i = i + 1
                    Loop

                Case Else
                    ed.WriteMessage("vbCrLfType :" + type)

            End Select
            item = iterator.Next()
        End While


        UnlockDatabase()
    End Sub

 

 

 



Balaji
Developer Technical Services
Autodesk Developer Network

Message 3 of 7

Hi,

 

Thanks for the response and code.  I was hoping to access the non-custom properties of a sheet like:

 

Sheet title, Sheet number, Revision number, Revision date, Purpose, Category, Description & Include for publish

 

I know I can do this through SSM but can I access progrmatically? 

 

Thanks.

 

Chris

Message 4 of 7

Hi Chris,

 

Here is a blog post on accessing these properties :

http://adndevblog.typepad.com/autocad/2013/01/accessing-revision-number-revision-date-purpose-and-ca...

 

 



Balaji
Developer Technical Services
Autodesk Developer Network

Message 5 of 7

Thanks!  I now see how I can loop through sheets and get the current values.  I would now like to modify these values,  I noticed the following methods: .SetRevisionNumber,  .SetRevisionDate, .SetIssuePurpose and .SetCategory.  I tried to update using these methods ( example: mySheet2.SetRevisionNumber("2")  )  but got an error. How are these values modified?  Thanks again.

 

Chris

Message 6 of 7

Hi Chris,

 

What is the error message that you get ? Maybe you havent locked the sheetset database before setting the revision number ?

 

Here is a sample code to set the revision number for all the sheets in a sheetset :

 

    <CommandMethod("SetRevision")> _
    Public Sub SetRevisionMethod()
        Dim dstFile As String
        dstFile = "C:\Temp\MySheetSet\MySheetSet.dst"

        Dim mgr As AcSmSheetSetMgr = New AcSmSheetSetMgr()
        Dim db As AcSmDatabase = New AcSmDatabase()
        db = mgr.OpenDatabase(dstFile, False)

        Dim lockStatus As AcSmLockStatus
        lockStatus = db.GetLockStatus

        If lockStatus = 0 Then
            db.LockDb(db)
        End If

        Dim ss As AcSmSheetSet = db.GetSheetSet()

        Dim EnumSheets As IAcSmEnumComponent = ss.GetSheetEnumerator()

        Dim smComponent As IAcSmComponent
        Dim sheet As IAcSmSheet
        Dim sheet2 As IAcSmSheet2

        smComponent = EnumSheets.Next()

        While True
            If smComponent Is Nothing Then
                Exit While
            End If

            sheet = TryCast(smComponent, IAcSmSheet)

            ' To access the revision number, 
            ' Revision date, Purpose and Category,
            ' cast it as IAcSmSheet2
            sheet2 = TryCast(smComponent, IAcSmSheet2)
            If sheet2 IsNot Nothing Then
                sheet2.SetRevisionNumber("111")
            End If

            smComponent = EnumSheets.Next()
        End While

        db.UnlockDb(db)

        mgr.Close(db)
    End Sub

 



Balaji
Developer Technical Services
Autodesk Developer Network

Message 7 of 7

Thanks, I'll give that a try.

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