.NET

Reply
Distinguished Contributor
VB_Autocad_guy
Posts: 136
Registered: ‎07-24-2009
Message 1 of 3 (234 Views)
Accepted Solution

IteratePageSetups (Iterate PlotSettingsDicitionary)

234 Views, 2 Replies
06-13-2011 12:09 PM
    <CommandMethod("IterateSetups")> _
    Public Sub IteratePageSetups()
        '' Get the current document and database, and start a transaction
        Dim acDoc As Document = Application.DocumentManager.MdiActiveDocument
        Dim acCurDb As Database = acDoc.Database
        Using acTrans As Transaction = acCurDb.TransactionManager.StartTransaction()
            '' This example returns the PageSetup table for the current database
            Dim acPltDic As DBDictionary
            acPltDic = acTrans.GetObject(acCurDb.PlotSettingsDictionaryId, _
                                               OpenMode.ForRead)
            '' Step through the PageSetup table and print each PageSetup name
            For Each acObjId In acPltDic
                Dim acPlotSet As PlotSettings
                acPlotSet = acTrans.GetObject(acObjId, OpenMode.ForRead)
                acDoc.Editor.WriteMessage(vbLf & acPlotSet.PlotSettingsName)
            Next
            '' Dispose of the transaction
        End Using
    End Sub

 What's the sub object for a PlotSettings Dicitionary here? I'm just trying to iterate through them. 

 

Okay so I Figured out the object I needed

 Dim acPltDic As DBDictionary     

 Dim acPltDicEntry As DBDictionaryEntry

 

In business: 

 

 <CommandMethod("its")> _
Public Sub IteratePage()
'' Get the current document and database, and start a transaction
Dim acDoc As Document = Application.DocumentManager.MdiActiveDocument
Dim acCurDb As Database = acDoc.Database
Using acTrans As Transaction = acCurDb.TransactionManager.StartTransaction()
'' This example returns the PageSetup table for the current database
Dim acPltDic As DBDictionary
Dim acPltDicEntry As DBDictionaryEntry
Dim acPageSetup As PlotSettings
acPltDic = acTrans.GetObject(acCurDb.PlotSettingsDictionaryId, _
OpenMode.ForRead)
'' Step through the PageSetup table and print each PageSetup name
Dim objId As ObjectId
For Each acPltDicEntry In acPltDic
MsgBox("Key: " & acPltDicEntry.Key)
'Get PageSetup
ObjId = acPltDic.GetAt(acPltDicEntry.Key)
acPageSetup = objID.GetObject(OpenMode.ForRead)
MsgBox("Pagesetup: " & acPageSetup.PlotSettingsName)
Next
'' Dispose of the transaction
End Using
End Sub

 Maybe this will help someone else. 


Distinguished Contributor
VB_Autocad_guy
Posts: 136
Registered: ‎07-24-2009
Message 2 of 3 (219 Views)

Re: IteratePageSetups (Iterate PlotSettingsDicitionary)

06-13-2011 01:38 PM in reply to: VB_Autocad_guy

Okay so I Figured out the object I needed

 Dim acPltDic As DBDictionary     

 Dim acPltDicEntry As DBDictionaryEntry

 

In business: 

 

    <CommandMethod("its")> _
    Public Sub IteratePage()
        '' Get the current document and database, and start a transaction
        Dim acDoc As Document = Application.DocumentManager.MdiActiveDocument
        Dim acCurDb As Database = acDoc.Database
        Using acTrans As Transaction = acCurDb.TransactionManager.StartTransaction()
            '' This example returns the PageSetup table for the current database
            Dim acPltDic As DBDictionary
            Dim acPltDicEntry As DBDictionaryEntry
            Dim acPageSetup As PlotSettings

            acPltDic = acTrans.GetObject(acCurDb.PlotSettingsDictionaryId, _
                                               OpenMode.ForRead)
            '' Step through the PageSetup table and print each PageSetup name

            Dim objId As ObjectId
            For Each acPltDicEntry In acPltDic
                MsgBox("Key: " & acPltDicEntry.Key)

                'Get PageSetup
                ObjId = acPltDic.GetAt(acPltDicEntry.Key)
                acPageSetup = objID.GetObject(OpenMode.ForRead)
                MsgBox("Pagesetup: " & acPageSetup.PlotSettingsName)

            Next

            '' Dispose of the transaction
        End Using
    End Sub

 Maybe this will help someone else. 


Contributor
Dave_B
Posts: 24
Registered: ‎03-25-2009
Message 3 of 3 (160 Views)

Re: IteratePageSetups (Iterate PlotSettingsDicitionary)

01-26-2012 09:45 AM in reply to: VB_Autocad_guy

Yes, it helped alot - a very straightforward anwser.

Need installation help?

Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.