.NET

.NET

Reply
Valued Contributor
Chris.Picklesimer
Posts: 91
Registered: ‎04-07-2000
Message 1 of 7 (363 Views)

Sheet Set: Access Sheet Properties

363 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

ADN Support Specialist
Balaji_Ram
Posts: 746
Registered: ‎03-21-2011
Message 2 of 7 (337 Views)

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

Valued Contributor
Chris.Picklesimer
Posts: 91
Registered: ‎04-07-2000
Message 3 of 7 (324 Views)

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

ADN Support Specialist
Balaji_Ram
Posts: 746
Registered: ‎03-21-2011
Message 4 of 7 (312 Views)

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

Valued Contributor
Chris.Picklesimer
Posts: 91
Registered: ‎04-07-2000
Message 5 of 7 (299 Views)

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

ADN Support Specialist
Balaji_Ram
Posts: 746
Registered: ‎03-21-2011
Message 6 of 7 (283 Views)

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

Valued Contributor
Chris.Picklesimer
Posts: 91
Registered: ‎04-07-2000
Message 7 of 7 (269 Views)

Re: Sheet Set: Access Sheet Properties

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

Thanks, I'll give that a try.

Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Do you have 60 seconds to spare? The Autodesk Community Team is revamping our site ranking system and we want your feedback! Please click here to launch the 5 question survey. As always your input is greatly appreciated.