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

Import Page Setup from Template

17 REPLIES 17
SOLVED
Reply
Message 1 of 18
Mike.Wohletz
4869 Views, 17 Replies

Import Page Setup from Template

I am lost as to how to go about importing a page setup from a template file and set it current, I am using vb.net and working with AutoCAD 2010. I have searched this thread and from what I can see several others have asked this question and it has not been answered. any help in the correct direction would be great.
thanks
Mike
17 REPLIES 17
Message 2 of 18
Mike.Wohletz
in reply to: Mike.Wohletz

A sample or a point in the right direction would be a great help! anyone?
Message 3 of 18
KLGalloway
in reply to: Mike.Wohletz

Have you managed to find out anything on this issue of setting a pagesetup (plotsettings object) as current?

Message 4 of 18
norman.yuan
in reply to: Mike.Wohletz

Since I have not done this before, I decided to put togeter some quick code. It copies a layout from a drawing file into the current drawing in Acad. Here is the code:

 

using System;

using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.Runtime;

[assembly: CommandClass(typeof(CopyPageSetup.MyCommand))]

namespace CopyPageSetup
{
    public class MyCommand
    {
        [CommandMethod("CopyLayout")]
        public void RunThisMethod()
        {
            //The template drawing containing a layout named as 
            //"MyLayout" with desired page setup
            string sourceDwg = @"E:\Temp\Test.dwg";
            string layoutName = "MyLayout";

            Document dwg = Autodesk.AutoCAD.ApplicationServices
                        .Application.DocumentManager.MdiActiveDocument;

            //Get source database
            Database db = null;
            try
            {
                db = GetSourceDatabase(sourceDwg);
            }
            catch (System.Exception ex)
            {
                dwg.Editor.WriteMessage(
                    "\nReading source drawing error:\n {0}\n.",
                    ex.Message);
                return;
            }

            //If a layout with the same name as in the source drawing
            //exists. If yes, the layout's page setup will be overwritten
            LayoutManager mgr = LayoutManager.Current;
            try
            {
                //Set the eixsting layout active
                mgr.CurrentLayout = layoutName;
            }
            catch
            {
                //create the alyout and set it active
                mgr.CreateLayout(layoutName);
                mgr.CurrentLayout = layoutName;
            }

            //Do layout page setup copying
            using (db)
            {
                try
                {
                    CopyLayout(db, layoutName, dwg.Database, mgr.GetLayoutId(layoutName));
                }
                catch (System.Exception ex)
                {
                    dwg.Editor.WriteMessage(
                        "\nCopying layout error:\n {0}\n.", 
                        ex.Message);
                    return;
                }
            }

            dwg.Editor.Regen();
            dwg.Editor.WriteMessage("\nLayout copy completed.");
        }

        #region private methods

        private Database GetSourceDatabase(string sourceFile)
        {
            Database db = new Database();
            db.ReadDwgFile(sourceFile, FileOpenMode.OpenForReadAndReadShare, false, null);
            return db;
        }

        private void CopyLayout(Database sourceDB, 
            string layoutName, Database thisDB, ObjectId thisLayoutID)
        {
            using (Transaction tran = sourceDB.TransactionManager.StartTransaction())
            {
                DBDictionary lay1Dic = (DBDictionary)
                    tran.GetObject(sourceDB.LayoutDictionaryId, OpenMode.ForRead);
                try
                {
                    //Get source layout object in the source database
                    ObjectId lay1ID = lay1Dic.GetAt(layoutName);
                    Layout lay1 = (Layout)tran.GetObject(lay1ID, OpenMode.ForRead);

                    using (Transaction t = thisDB.TransactionManager.StartTransaction())
                    {
                        //Get the destination layout in current database
                        Layout lay2 = (Layout)
                            t.GetObject(thisLayoutID, OpenMode.ForWrite);
 
                        try
                        {
                            //Copy layout
                            lay2.CopyFrom(lay1);
                            t.Commit();
                        }
                        catch
                        {
                            t.Abort();
                            throw;
                        }
                    }
                }
                catch
                {
                    tran.Abort();
                    throw;
                }
            }
        }

        #endregion
    }
}

 

 HTH.

  

 

Message 5 of 18
KLGalloway
in reply to: norman.yuan

Norman,

At the risk of sounding like the one particular smartaleck that posts on here and other AutoCAD sites simply to ridicule and poke fun at perfectly serious questions and suggestions, what does your post have to do with the original question or my query? Your code is first of all in C# and the question requests a VB.Net solution and the requested solution deals with page setup/plot settings objects while your code is for copying layouts. Sure, one or more plot settings objects would be part of the drawing the copied layout comes from and layouts are derived from plotsettings objects, but which one is current for the drawing?

I don't want to discourage anyone from answering posts, but you really need to make your reply have something to do with the posted question.

For all posters, I would like to make a request that if you post a question and then find an answer on your own, please come back and post that solution. This thread is one of several that I have found asking the same questions I was researching, but with no updates or posted solutions. Even if the result was to abandon that line of pursuit because no  solution was found in the allotted time for the project that is all good information.

 

Kerry

Message 6 of 18
norman.yuan
in reply to: Mike.Wohletz

Are you the same person as "mike.wohletz"? If not, where is your ORIGINALPOST which specifically requires VB.NET solution?

The posts here is focusing on logic of Acad .NET solution, not on the language itself, especially when it is .NET code. If the code does what you want, are you going to ask some do the language conversion?

I am a bit sorry if you did not find the code is useful for you, after all it is not directly to your question. Given the not-so-detailed original post, if I assumed the OP wants to import page setup/plotting setup from other drawing's layout, at least the code works on that assumption.

If you bother to describe your requirement in details in YOUR OWN POST, someone might put forth a solution perfectly suitable to you, or there might be no solution at all because of very odd requirements, no one knows ahead of time until one can see your reasonably described post.

Message 7 of 18
caddzone
in reply to: KLGalloway

The only thing you've achieved here is to ensure that future

requests for help from you will probably be ignored.

 


@KLGalloway wrote:

Norman,

At the risk of sounding like the one particular smartaleck that posts on here and other AutoCAD sites simply to ridicule and poke fun at perfectly serious questions and suggestions, what does your post have to do with the original question or my query? Your code is first of all in C# and the question requests a VB.Net solution and the requested solution deals with page setup/plot settings objects while your code is for copying layouts. Sure, one or more plot settings objects would be part of the drawing the copied layout comes from and layouts are derived from plotsettings objects, but which one is current for the drawing?

I don't want to discourage anyone from answering posts, but you really need to make your reply have something to do with the posted question.

For all posters, I would like to make a request that if you post a question and then find an answer on your own, please come back and post that solution. This thread is one of several that I have found asking the same questions I was researching, but with no updates or posted solutions. Even if the result was to abandon that line of pursuit because no  solution was found in the allotted time for the project that is all good information.

 

Kerry


 



AcadXTabs for AutoCAD
Supporting AutoCAD 2000-2011


Message 8 of 18
KLGalloway
in reply to: norman.yuan

Norman,

I will just quote the original post with some added emphasis which actually was pretty detailed and very concise - "I am lost as to how to go about importing a page setup from a template file and set it current, I am using vb.net and working with AutoCAD 2010".

Never said the original post was mine only the later inquiry. You wrote "Given the not-so-detailed original post, if I assumed the OP wants to import page setup/plotting setup from other drawing's layout, at least the code works on that assumption". Actually your code doesn't import a page setup from another drawings layout. It imports the entire layout which is not the same at all; it doesn’t even look for page setups much less set one of them current and is actually not a good thing at all.

If I just want the page setup I can get that easily enough and there are lots of examples in VB.Net and C# around to do that without having to drag over and add an entire layout to my drawing. The important part is setting a particular plot settings object as current programmatically which still needs a solution.

Message 9 of 18
KLGalloway
in reply to: caddzone

Tell you what, Tony, I don't see a downside to having you ignore my posts. Smiley Very Happy After all you were the contributor I referenced in my first reply to Norman.

Message 10 of 18
KLGalloway
in reply to: Mike.Wohletz

Mike,

Here is the code that I have so far. The one thing that it doesn't explicitly do is set the copied or created PlotSettings object to current as per the first dialog when working with PageSetups. Let me know if you have questions. The constants are pretty self-explanatory and I haven’t included their contents as many of them contain company proprietary information. The code insert function for the forum keeps the indentations, but is not wide enough to keep the lines from wrapping so you will probably want to paste the code into VS to read through it.

Kerry

 

These are the imports from the code module not all of which are used by the two procedures included here.

Imports System
Imports System.Drawing.Printing
Imports System.Windows.Forms
Imports Autodesk.AutoCAD
Imports Autodesk.AutoCAD.ApplicationServices
Imports Autodesk.AutoCAD.ApplicationServices.Application
Imports Autodesk.AutoCAD.DatabaseServices
Imports Autodesk.AutoCAD.EditorInput
Imports Autodesk.AutoCAD.Geometry
Imports Autodesk.AutoCAD.Interop
Imports Autodesk.AutoCAD.Interop.Common
Imports Autodesk.AutoCAD.PlottingServices
Imports Autodesk.AutoCAD.Runtime

 

    Public Function CopyPageSetupFromFile(ByVal SourceName As String, ByVal CallerName As String) As Boolean
        '***************************************************************************************************************
        ' Procedure Name: CopyPageSetupFromFile
        '
        ' Purpose: Checks for the Passed PlotSettings Object in the Source Drawing File and Copies It to the Current Drawing's Layout1
        '
        ' Return Values: True/False
        '
        ' Assumptions: Any Called Procedures will Provide Error Handling and Messages
        '
        ' Globals: N/A
        '
        '***************************************************************************************************************
        Const CONST_PROCEDURE_NAME As String = "CopyPageSetupFromFile"

        ' Declare and Instanciate the Variables Needed for Handling the External Source Document.
        Dim objSourceDatabase As New Database
        Dim objSourceTransactionManager As DatabaseServices.TransactionManager

        '**************** Source Transaction Starts Here ****************
        objSourceTransactionManager = objSourceDatabase.TransactionManager
        Using objSourceTransaction As DatabaseServices.Transaction = objSourceTransactionManager.StartTransaction()

            ' Set Up the Source File Name
            Dim SourceFilePath As String = CONST_SPE_FILEPATH & "\" & SourceName.ToUpper & CONST_DWG_EXTENSION.ToUpper

            ' Try to Open the Source Drawing File
            Try
                objSourceDatabase.ReadDwgFile(SourceFilePath, FileOpenMode.OpenForReadAndReadShare, True, "")
            Catch excAutoCAD As Autodesk.AutoCAD.Runtime.Exception
                ' Handle Specific AutoCAD Exceptions Then
                ' Generic AutoCAD Exceptions and Then Generic System Exceptions
                Dim strMessage As String
                If excAutoCAD.Message = "eFileNotFound" Then
                    strMessage = "An Error Occurred While Attempting to Insert the Layout from" & vbCrLf & _
                                 SourceFilePath & " as a Source Drawing." & vbCrLf & vbCrLf & _
                                 "The File must be Located in Your SPE Folder and Must Have the " & vbCrLf & _
                                 "Values Set as per the SPE Installation Instructions." & vbCrLf & _
                                     CONST_ERRMSG_INSERTMAT_CLOSING
                    MsgBox(strMessage, MsgBoxStyle.ApplicationModal + MsgBoxStyle.Critical + MsgBoxStyle.OkOnly, CallerName)
                    Return False
                Else
                    strMessage = CONST_ACAD_ERRMSG_START & CONST_PROCEDURE_NAME & _
                                 CONST_GEN_ERRMSG_MIDDLE & excAutoCAD.ToString & _
                                 CONST_GEN_ERRMSG_END & _
                                 CONST_ERRMSG_INSERTMAT_CLOSING
                    MsgBox(strMessage, MsgBoxStyle.ApplicationModal + MsgBoxStyle.Critical + MsgBoxStyle.OkOnly, CallerName)
                    Return False
                End If
            Catch excGeneric As System.Exception
                Dim strMessage As String
                strMessage = CONST_GEN_ERRMSG_START & CONST_PROCEDURE_NAME & _
                             CONST_GEN_ERRMSG_MIDDLE & excGeneric.ToString & _
                             CONST_GEN_ERRMSG_END & _
                             CONST_ERRMSG_INSERTMAT_CLOSING
                MsgBox(strMessage, MsgBoxStyle.ApplicationModal + MsgBoxStyle.Critical + MsgBoxStyle.OkOnly, CallerName)
                Return False
            End Try

            Dim objSourcePlotSettings As PlotSettings = New PlotSettings(False)
            Dim objSourcePlotSettingsDictionary As DBDictionary = objSourceTransaction.GetObject _
                                                                  (objSourceDatabase.PlotSettingsDictionaryId, OpenMode.ForRead)

            ' Get the Passed PlotSettings Object as the Source If It Exists in the Source Drawing
            Dim PlotSettingsFound = False
            If objSourcePlotSettingsDictionary.Count > 0 Then
                For Each objDictionaryEntry As DictionaryEntry In objSourcePlotSettingsDictionary
                    If String.Compare(objDictionaryEntry.Key.ToString.ToUpper, SourceName.ToUpper, True) = 0 Then
                        objSourcePlotSettings = objSourceTransaction.GetObject(objDictionaryEntry.Value, OpenMode.ForRead)
                        PlotSettingsFound = True
                        Exit For
                    End If
                Next
            End If

            ' If It was Not Found, We Need to Send a Message and Shutdown the InsertMat Program
            If Not PlotSettingsFound Then
                Dim strMessage = "The File " & SourceFilePath & " Does Not Contain the " & SourceName & " Page Setup." & vbCrLf & _
                                 "You Must Rebuild the " & SourceName.ToUpper & CONST_DWG_EXTENSION & " File." & vbCrLf & _
                                 "The File must be Located in Your SPE Folder and Must Have the " & vbCrLf & _
                                 "Values Set as per the SPE Installation Instructions." & vbCrLf & _
                                 CONST_ERRMSG_INSERTMAT_CLOSING
                MsgBox(strMessage, MsgBoxStyle.ApplicationModal + MsgBoxStyle.Critical + MsgBoxStyle.OkOnly, CallerName)
                Return False
            End If

            '********************************************************************************************
            ' Set the Current Drawing Object to the Application's Active Document - Replaces ThisDrawing
            '********************************************************************************************
            Dim objCurrentDrawing As Document = DocumentManager.MdiActiveDocument
            '******** The CurrentDrawing Object will be the Destination Drawing for This Routine ********

            ' Set The Other Variables Needed to Handle the CurrentDrawing and Its Objects
            Dim objDatabase As Database = objCurrentDrawing.Database
            Dim objTransactionManager As DatabaseServices.TransactionManager = objDatabase.TransactionManager

            '**************** Destination Transaction Starts Here ****************
            Using objTransaction As DatabaseServices.Transaction = objTransactionManager.StartTransaction()

                If SetLayoutAsCurrent(CONST_LAYOUT1, CallerName) Then
                    ' The Layout Exists and is Current So Get a Reference to It Using the Layout Manager
                    Dim objLayoutManager As LayoutManager = LayoutManager.Current
                    Dim objLayout As Layout = objTransaction.GetObject(objLayoutManager.GetLayoutId(objLayoutManager.CurrentLayout), _
                                                                                                    OpenMode.ForWrite)
                    ' Output the Name of the Current Layout and Its Device
                    objCurrentDrawing.Editor.WriteMessage(vbLf & "Current Layout: " & objLayout.LayoutName & vbLf)
                    objCurrentDrawing.Editor.WriteMessage("Current Plot Configuration Name: " & objLayout.PlotConfigurationName & vbLf)

                    ' Reference the Destination PlotSettings Dictionary
                    Dim objPlotSettingsDictionary As DBDictionary = objTransaction.GetObject(objDatabase.PlotSettingsDictionaryId, _
                                                                                             OpenMode.ForRead)

                    ' If the Passed PlotSettings Object Exists in the Current Drawing, Delete It
                    If objPlotSettingsDictionary.Count > 0 Then
                        For Each objDictionaryEntry As DictionaryEntry In objPlotSettingsDictionary
                            If String.Compare(objDictionaryEntry.Key.ToString.ToUpper, SourceName.ToUpper, True) = 0 Then
                                objPlotSettingsDictionary.UpgradeOpen()
                                objPlotSettingsDictionary.Remove(objDictionaryEntry.Value)
                                objPlotSettingsDictionary.DowngradeOpen()
                                Exit For
                            End If
                        Next
                    End If

                    ' Create the Destination PlotSettings Object and Populate It from the Source PlotSettings
                    Dim objDestinationPlotSettings As PlotSettings = New PlotSettings(False)
                    objDestinationPlotSettings.CopyFrom(objSourcePlotSettings)

                    ' Update the PlotSettings Object to Make It Handle the Mat Insertion
                    Dim objDestinationPlotSettingsValidator As PlotSettingsValidator = PlotSettingsValidator.Current

                    ' Set to Use a Standard Scale Type 1:1
                    If Not objDestinationPlotSettings.UseStandardScale Then
                        objDestinationPlotSettingsValidator.SetUseStandardScale(objDestinationPlotSettings, True)
                    End If
                    If Not objDestinationPlotSettings.StdScaleType = StdScaleType.StdScale1To1 Then
                        objDestinationPlotSettingsValidator.SetStdScaleType(objDestinationPlotSettings, StdScaleType.StdScale1To1)
                    End If

                    ' Set to Scale the Lineweights
                    If Not objDestinationPlotSettings.ScaleLineweights Then
                        objDestinationPlotSettings.ScaleLineweights = True
                    End If

                    ' Make Sure that the Plot is in Landscape
                    If Not objDestinationPlotSettings.PlotRotation = PlotRotation.Degrees090 Then
                        objDestinationPlotSettingsValidator.SetPlotRotation(objDestinationPlotSettings, PlotRotation.Degrees090)
                    End If

                    ' Set to Plot Extents
                    If Not objDestinationPlotSettings.PlotType = DatabaseServices.PlotType.Extents Then
                        objDestinationPlotSettingsValidator.SetPlotType(objDestinationPlotSettings, DatabaseServices.PlotType.Extents)
                    End If

                    ' Add the Plot Settings Object to the Destination Plot Settings Dictionary
                    objDestinationPlotSettings.AddToPlotSettingsDictionary(objDatabase)
                    objLayout.CopyFrom(objDestinationPlotSettings)

                    ' Confirm that the Copied PlotSettings Object Exists in the Current Drawing's Plot Settings Dictionary
                    PlotSettingsFound = False
                    If objPlotSettingsDictionary.Count > 0 Then
                        For Each objDictionaryEntry As DictionaryEntry In objPlotSettingsDictionary
                            If String.Compare(objDictionaryEntry.Key.ToString.ToUpper, SourceName.ToUpper, True) = 0 Then
                                PlotSettingsFound = True

                                ' Output the Name of the Copied PlotSettings Object and Its Device Name
                                objCurrentDrawing.Editor.WriteMessage(vbLf & "Copied PlotSettings: " & objLayout.PlotSettingsName & vbLf)
                                objCurrentDrawing.Editor.WriteMessage("Copied Device Name: " & objLayout.PlotConfigurationName & vbLf)
                                Exit For
                            End If
                        Next
                    End If
                    objPlotSettingsDictionary = Nothing

                    ' If It was Not Found, We Need to Send a Message and Shutdown the InsertMat Program
                    If Not PlotSettingsFound Then
                        Dim strMessage = "The " & SourceName & " Page Setup Did Not Copy Correctly!" & vbCrLf & vbCrLf & _
                                         "You Must Rebuild the " & SourceName.ToUpper & CONST_DWG_EXTENSION & " File." & vbCrLf & _
                                         "The File must be Located in Your SPE Folder and Must Have the " & vbCrLf & _
                                         "Values Set as per the SPE Installation Instructions." & vbCrLf & _
                                         CONST_ERRMSG_INSERTMAT_CLOSING
                        MsgBox(strMessage, MsgBoxStyle.ApplicationModal + MsgBoxStyle.Critical + MsgBoxStyle.OkOnly, CallerName)
                        Return False
                    End If

                    ' Downgrade the Current Layout Mode Back to Read
                    objLayout.DowngradeOpen()

                    ' Commit and Save the Changes to the Current Drawing
                    objTransaction.Commit()

                    ' Clean Up the Destination Objects
                    objDestinationPlotSettingsValidator = Nothing
                    objDestinationPlotSettings = Nothing
                    objLayout = Nothing

                    objCurrentDrawing.Editor.Regen()
                    objCurrentDrawing.Editor.UpdateScreen()
                Else
                    Dim strMessage = "Layout1 could Not be Set as the Current Layout!" & vbCrLf & vbCrLf & _
                                     "Please be Sure That Layout1 Exists in the '" & objCurrentDrawing.Name & "' Drawing" & vbCrLf & _
                                     "and Re-run the Insert Mat Utility." & vbCrLf & vbCrLf & _
                                     "The Insert Mat Utility will Now be Terminated." & vbCrLf & _
                                     "Use the AutoCAD 'Undo' Button to Undo Changes Made by This Utility."
                    MsgBox(strMessage, MsgBoxStyle.ApplicationModal + MsgBoxStyle.Critical + MsgBoxStyle.OkOnly, CallerName)
                    ' Abort and Abandon the Changes to the Current Document
                    objTransaction.Abort()
                End If
            End Using     ' Destination Transaction
            ' Clean Up the Current Drawing Transaction Objects
            objTransactionManager.Dispose()
            objTransactionManager = Nothing
            objDatabase = Nothing
            objCurrentDrawing = Nothing

            ' Abort Any Changes to the Source Drawing
            objSourceTransaction.Abort()

            ' Clean Up the Source Drawing Transaction Objects
            objSourcePlotSettings = Nothing
            objSourcePlotSettingsDictionary = Nothing
        End Using     ' Source Transaction
        objSourceTransactionManager.Dispose()
        objSourceTransactionManager = Nothing
        objSourceDatabase.Dispose()
        objSourceDatabase = Nothing

        Return True
    End Function  ' CopyPageSetupFromFile

 

    Public Function SetLayoutAsCurrent(ByVal LayoutName As String, ByVal CallerName As String) As Boolean
        '***************************************************************************************************************
        ' Procedure Name: SetLayoutAsCurrent
        '
        ' Purpose: Checks for the Passed Layout in the Current Drawing, Sets It as Current, or Creates It.
        '
        ' Return Values: N/A
        '
        ' Assumptions: Any Called Procedures will Provide Error Handling and Messages
        '
        ' Globals: N/A
        '
        '***************************************************************************************************************
        Const CONST_PROCEDURE_NAME As String = "SetLayoutAsCurrent"

        '********************************************************************************************
        ' Set the Current Drawing Object to the Application's Active Document - Replaces ThisDrawing
        '********************************************************************************************
        Dim objCurrentDrawing As Document = DocumentManager.MdiActiveDocument

        Using objLock As DocumentLock = objCurrentDrawing.LockDocument
            ' Reference the Layout Manager
            Dim objLayoutManager As LayoutManager
            objLayoutManager = LayoutManager.Current

            ' If the Current Layout is Not the Passed Layout
            If Not objLayoutManager.CurrentLayout = LayoutName Then
                ' Set The Other Variables Needed to Handle the Current Drawing's Layouts
                Dim objDatabase As Database = objCurrentDrawing.Database
                Dim objTransactionManager As DatabaseServices.TransactionManager = objDatabase.TransactionManager
                Using objTransaction As Transaction = objTransactionManager.StartTransaction
                    ' Try to Set the Current Layout to the Passed Layout Name
                    Try
                        objLayoutManager.CurrentLayout = LayoutName
                    Catch excAutoCAD As Autodesk.AutoCAD.Runtime.Exception
                        If excAutoCAD.Message = "eSetFailed" Then
                            ' The Passed Layout Doesn't Exist So We Will Create It
                            Dim objLayout As Layout
                            objLayout = objTransaction.GetObject(objLayoutManager.CreateLayout(LayoutName), OpenMode.ForRead)
                            objLayoutManager.CurrentLayout = LayoutName
                            objLayout = Nothing
                        Else
                            Dim strMessage As String
                            strMessage = CONST_ACAD_ERRMSG_START & CONST_PROCEDURE_NAME & _
                                         CONST_GEN_ERRMSG_MIDDLE & excAutoCAD.ToString & _
                                         CONST_GEN_ERRMSG_END & _
                                         CONST_ERRMSG_INSERTMAT_CLOSING
                            MsgBox(strMessage, MsgBoxStyle.ApplicationModal + MsgBoxStyle.Critical + MsgBoxStyle.OkOnly, CallerName)
                            objCurrentDrawing = Nothing
                            Return False
                        End If
                    Catch excGeneric As System.Exception
                        Dim strMessage As String
                        strMessage = CONST_GEN_ERRMSG_START & CONST_PROCEDURE_NAME & _
                                     CONST_GEN_ERRMSG_MIDDLE & excGeneric.ToString & _
                                     CONST_GEN_ERRMSG_END & _
                                     CONST_ERRMSG_INSERTMAT_CLOSING
                        MsgBox(strMessage, MsgBoxStyle.ApplicationModal + MsgBoxStyle.Critical + MsgBoxStyle.OkOnly, CallerName)
                        objCurrentDrawing = Nothing
                        Return False
                    End Try

                    ' Commit the Transaction and Dispose of the Transaction Objects
                    objTransaction.Commit()
                    objTransactionManager.Dispose()
                    objTransactionManager = Nothing
                End Using
            End If
            objLayoutManager = Nothing
        End Using

        objCurrentDrawing = Nothing
        Return True
    End Function  ' SetLayoutAsCurrent

 

Message 11 of 18
caddzone
in reply to: KLGalloway

I'm pretty confident that it will not only be myself

that'll be ignoring your posts.

 

 



AcadXTabs for AutoCAD
Supporting AutoCAD 2000-2011


Message 12 of 18
caddzone
in reply to: KLGalloway

It's a shame that you're unable to figure out that a Layout is a PlotSettings

object, whcih explains why you were totally bewildered by the code in Norman's

post.

 

I'm not going to explain to you everything else you're missing, I would

much rather just sit back and watch you continue to make a complete

fool of yoursef.

 

 



AcadXTabs for AutoCAD
Supporting AutoCAD 2000-2011


Message 13 of 18
Jeffrey_H
in reply to: caddzone

A Page Setup is the UI in Autocad for  a plotSetting object

 A layout is plot setting with a blockTableRecord  

I will post the code we I get a chance to finish it up

You can also find your answers @ TheSwamp
Message 14 of 18
KLGalloway
in reply to: caddzone

It is not only unhelpful, but wrong statements such as your last which make me wish you would ignore my posts.

 

Here is the blurb on Plot Settings objects from the AutoCAD .NET Developer's Guide with some emphasis added to help out:

 

A PlotSettings object is similar to a Layout object, as both contain identical plot information and this is because the Layout class is derived from the PlotSettings class. The main difference is that a Layout object has an associated BlockTableRecord object containing the geometry to plot. A PlotSettings object is not associated with a particular BlockTableRecord object. It is simply a named collection of plot settings available for use with any geometry. PlotSettings objects are known as page setups in the AutoCAD user interface and are accessed from the Page Setup Manager.

 

There wouldn't be an issue if the Guide had just continued with a line or two about getting to them programmatically and performing whatever it is the "Set as Current" button does, but nothing is mentioned.

 

You really need to do some research before you smart off. You have been no more and probably less helpful to anyone on this issue than you were on this post of mine which first clued me in to your "I'd rather be cryptic and look clever than actually do enough research to be both clever and helpful" attitude. Please, please carry out your menacing and oh so horrible to contemplate threat not to reply to my posts!!! Please!!! Please!!! I<Lovely gratuitous comment about good advertising for your company not included because I really need to quit letting you think you have a chance so you will stop replying>.

Message 15 of 18
KLGalloway
in reply to: Jeffrey_H

fro2001,

I will be looking forward to your code submission.

Message 16 of 18
caddzone
in reply to: KLGalloway

And you just did exactly what I said I'd sit back and watch you do.

 

The docs you quoted unequivocally confirms what just I said (that a

Layout is a PlotSettings object). The fact that you are incapable of

figuring out how to make the settings from the latter 'current' even

after Norman's code shows how to do that, means that you should

probably stop wasting your employer's money.

 

 



AcadXTabs for AutoCAD
Supporting AutoCAD 2000-2011


Message 17 of 18
caddzone
in reply to: KLGalloway


@KLGalloway wrote:

 

You have been no more and probably less helpful to anyone on this issue than you were on this post of mine which first clued me in to your "I'd rather be cryptic and look clever than actually do enough research to be both clever and helpful" attitude.

 


It's clear from what little participation you've made here, that the problem is on your end,

rather than on mine or Norman's.

 

The fact that you conveniently confuse "cryptic", with your own comprehension problems

and inexperience would seem to more than adequately explain what leads you to expect

others to go out of their way to spell everything out for you in terms the average third-

grader can understand. Which in-turn, makes it abundantly clear that you really should not be

wasting your employer's money by making misrepresentations about your ability insofar as

customizing AutoCAD with the .NET API.

 

The attitude you've demonstrated to date in this and the thread you reference above, pretty

much seals your fate, insofar as getting help from this resource, as I'm fairly confident that

most who are able to help you will choose not to bother, after reading your posts.

 

 



AcadXTabs for AutoCAD
Supporting AutoCAD 2000-2011


Message 18 of 18
Jeffrey_H
in reply to: caddzone

I Added new post with code

You can also find your answers @ TheSwamp

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