• Industries
  • Products
  • Buy
  • Services & Support
  • Communities
  • Discussion Groups

    .NET

    Reply
    Valued Contributor
    Posts: 66
    Registered: ‎04-07-2000

    Sheet Set: Access Sheet Properties

    168 Views, 6 Replies
    01-21-2013 09:37 AM

    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

    Please use plain text.
    ADN Support Specialist
    Balaji_Ram
    Posts: 359
    Registered: ‎03-21-2011

    Re: Sheet Set: Access Sheet Properties

    01-24-2013 10:38 AM in reply to: Chris.Picklesimer

    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

    Please use plain text.
    Valued Contributor
    Posts: 66
    Registered: ‎04-07-2000

    Re: Sheet Set: Access Sheet Properties

    01-25-2013 11:11 AM in reply to: Balaji_Ram

    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

    Please use plain text.
    ADN Support Specialist
    Balaji_Ram
    Posts: 359
    Registered: ‎03-21-2011

    Re: Sheet Set: Access Sheet Properties

    01-27-2013 08:25 PM in reply to: Chris.Picklesimer

    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

    Please use plain text.
    Valued Contributor
    Posts: 66
    Registered: ‎04-07-2000

    Re: Sheet Set: Access Sheet Properties

    01-28-2013 06:20 AM in reply to: Balaji_Ram

    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

    Please use plain text.
    ADN Support Specialist
    Balaji_Ram
    Posts: 359
    Registered: ‎03-21-2011

    Re: Sheet Set: Access Sheet Properties

    01-31-2013 04:56 AM in reply to: Chris.Picklesimer

    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

    Please use plain text.
    Valued Contributor
    Posts: 66
    Registered: ‎04-07-2000

    Re: Sheet Set: Access Sheet Properties

    02-01-2013 07:32 AM in reply to: Balaji_Ram

    Thanks, I'll give that a try.

    Please use plain text.