.NET

Reply
Active Contributor
BellwetherBill
Posts: 38
Registered: ‎01-14-2011
Message 1 of 13 (309 Views)
Accepted Solution

SaveAs with paperspace layout current

309 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?

*Expert Elite*
Alfred.NESWADBA
Posts: 8,890
Registered: ‎06-29-2007
Message 2 of 13 (295 Views)

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
-------------------------------------------------------------------------
Active Contributor
BellwetherBill
Posts: 38
Registered: ‎01-14-2011
Message 3 of 13 (285 Views)

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

*Expert Elite*
Alfred.NESWADBA
Posts: 8,890
Registered: ‎06-29-2007
Message 4 of 13 (281 Views)

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
-------------------------------------------------------------------------
Active Contributor
BellwetherBill
Posts: 38
Registered: ‎01-14-2011
Message 5 of 13 (280 Views)

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?

*Expert Elite*
Alfred.NESWADBA
Posts: 8,890
Registered: ‎06-29-2007
Message 6 of 13 (278 Views)

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
-------------------------------------------------------------------------
Active Contributor
BellwetherBill
Posts: 38
Registered: ‎01-14-2011
Message 7 of 13 (274 Views)

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.

Valued Mentor
fieldguy
Posts: 367
Registered: ‎03-31-2005
Message 8 of 13 (267 Views)

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)

*Expert Elite*
Alfred.NESWADBA
Posts: 8,890
Registered: ‎06-29-2007
Message 9 of 13 (263 Views)

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
-------------------------------------------------------------------------
Active Contributor
BellwetherBill
Posts: 38
Registered: ‎01-14-2011
Message 10 of 13 (259 Views)

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".

You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.

Need installation help?

Start with some of our most frequented solutions to get help installing your software.

Ask the Community