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

    .NET

    Reply
    Active Contributor
    BellwetherBill
    Posts: 33
    Registered: ‎01-14-2011
    Accepted Solution

    SaveAs with paperspace layout current

    235 Views, 12 Replies
    01-18-2012 02:04 PM

    I have a bit of code that batch processes from a template drawing. It all works fine until I get to the SaveAs() function. I have narrowed down the problem to have something to do with the drawing starting and saving in a paperspace layout. When I run the code with the template saved in model space it works fine but whe the current tab is a paperspace layout I get an error during the saveas() function "eInvalidInput"

     

    I am using VS2008 and Autocad 2011. Is there a difference in saving with a paperspace layout current?

    Please use plain text.
    *Expert Elite*
    Posts: 6,635
    Registered: ‎06-29-2007

    Re: SaveAs with paperspace layout current

    01-18-2012 11:27 PM in reply to: BellwetherBill

    Hi,

     

    can you show the parts of your code, that:

    a) does the opening/loading of the drawing (so we know at least is it loaded in editor or just opened the database)

    b) what are the steps you use to change the current layout + (at least described) what happend between change to layout and save

    c) how do you save

     

    I think without seeing anything you do we can't answer why "save" should not work.

     

    - alfred -

    -------------------------------------------------------------------------
    Alfred NESWADBA
    Ingenieur Studio HOLLAUS ... www.hollaus.at
    -------------------------------------------------------------------------
    Please use plain text.
    Active Contributor
    BellwetherBill
    Posts: 33
    Registered: ‎01-14-2011

    Re: SaveAs with paperspace layout current

    01-19-2012 05:51 AM in reply to: BellwetherBill

    Thanks Alfred. below is the code. This code works using the CloseAndSave Method with my template drawing saved with "Layout1" as the current space but the SaveAs method does not. If I save the template drawing with Modelspace as the current tab the SaveAs method and the CloseAndSave method both work.

     

    The exception I get is eInvalidInput using the SaveAs method in paperspace.

     

    Private Function BuildProject(ByVal drSession As DataRow) As Int32

            'Specify the template to use, if the template is not found 
            'the default settings are used. 
            Dim strTemplatePath As String = "MyTemplate.dwt"
            Dim acDocMgr As DocumentCollection = Application.DocumentManager
            Dim acDoc As Document = acDocMgr.Add(strTemplatePath)

     

            Using acLockDoc As DocumentLock = acDoc.LockDocument
                ModifyTemplateParameters(acDoc, drSession)
            End Using

     

            'acDoc.Database.SaveAs("C:\Programming\DotNet Projects\InsightProjects\Insight(" & drSession("ProjectId") & _
            '                      "_" & drSession("UnitNum") & ").dwg", DwgVersion.Current)

     

            acDoc.CloseAndSave("C:\Programming\DotNet Projects\InsightProjects\Insight(" & drSession("ProjectId") & _
                                  "_" & drSession("UnitNum") & ").dwg")

            Return 1

    End Function

    Please use plain text.
    *Expert Elite*
    Posts: 6,635
    Registered: ‎06-29-2007

    Re: SaveAs with paperspace layout current

    01-19-2012 06:09 AM in reply to: BellwetherBill

    Hi,

     

    do you need it to be loaded into the editor? Have you tried to just go by using "new database(....)".

    I would try that

     

    - alfred -

     

    PS: I have not tried your code now as of limited time, so for others and other ideas .... :smileywink:

    -------------------------------------------------------------------------
    Alfred NESWADBA
    Ingenieur Studio HOLLAUS ... www.hollaus.at
    -------------------------------------------------------------------------
    Please use plain text.
    Active Contributor
    BellwetherBill
    Posts: 33
    Registered: ‎01-14-2011

    Re: SaveAs with paperspace layout current

    01-19-2012 06:22 AM in reply to: alfred.neswadba

    I will ultimately be needing to plot my layouts. Do I need it to be loaded into the editor to plot?

    Please use plain text.
    *Expert Elite*
    Posts: 6,635
    Registered: ‎06-29-2007

    Re: SaveAs with paperspace layout current

    01-19-2012 06:34 AM in reply to: BellwetherBill

    Hi,

     

    >> I will ultimately be needing to plot my layouts.

    In that case YES, you have to load it into the editor.

     

    - alfred -

    -------------------------------------------------------------------------
    Alfred NESWADBA
    Ingenieur Studio HOLLAUS ... www.hollaus.at
    -------------------------------------------------------------------------
    Please use plain text.
    Active Contributor
    BellwetherBill
    Posts: 33
    Registered: ‎01-14-2011

    Re: SaveAs with paperspace layout current

    01-19-2012 06:57 AM in reply to: alfred.neswadba

    Thanks Alfred,

     

    At the end of the day I have to close the drawing anyway so the CloseAndSave method will work just fine. I would like to know why the SaveAs method doesn't work in this instance though as I spent a little time trying to figure out why my code didn't work.

     

    Thanks for your input.

    Please use plain text.
    Valued Mentor
    Posts: 306
    Registered: ‎03-31-2005

    Re: SaveAs with paperspace layout current

    01-19-2012 08:42 AM in reply to: BellwetherBill

    I can't recall where I found this.  Worth a try maybe.

     

    db.SaveAs(dwgfile, True, DwgVersion.Current, db.SecurityParameters)

    Please use plain text.
    *Expert Elite*
    Posts: 6,635
    Registered: ‎06-29-2007

    Re: SaveAs with paperspace layout current

    01-19-2012 08:49 AM in reply to: fieldguy

    Hi,

     

    and also I have one idea now: we had a thread (sorry that I don't find it for now) where it was a difference wether you write the filename directly into the statement or you created a variable before that stores the filename + at the .SaveAs statement use then the variable instead of the string(-calculation).

    In other words, try this:

    dim tFileName as string 
    tFileName = "C:\Programming\DotNet Projects\InsightProjects\Insight(" & _
                 drSession("ProjectId") & "_" & drSession("UnitNum") & ").dwg"
    acDoc.Database.SaveAs(tFileName, DwgVersion.Current)

     

    - alfred -

    -------------------------------------------------------------------------
    Alfred NESWADBA
    Ingenieur Studio HOLLAUS ... www.hollaus.at
    -------------------------------------------------------------------------
    Please use plain text.
    Active Contributor
    BellwetherBill
    Posts: 33
    Registered: ‎01-14-2011

    Re: SaveAs with paperspace layout current

    01-19-2012 09:17 AM in reply to: alfred.neswadba

    Alfred,

    I tried your suggestion but got the same result "eInvalidInput".

    Please use plain text.