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

SaveAs with paperspace layout current

12 REPLIES 12
SOLVED
Reply
Message 1 of 13
BellwetherBill
857 Views, 12 Replies

SaveAs with paperspace layout current

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?

12 REPLIES 12
Message 2 of 13

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 ... blog.hollaus.at ... CDay 2024
------------------------------------------------------------------------------------
(not an Autodesk consultant)
Message 3 of 13

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

Message 4 of 13

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

------------------------------------------------------------------------------------
Alfred NESWADBA
Ingenieur Studio HOLLAUS ... www.hollaus.at ... blog.hollaus.at ... CDay 2024
------------------------------------------------------------------------------------
(not an Autodesk consultant)
Message 5 of 13

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

Message 6 of 13

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 ... blog.hollaus.at ... CDay 2024
------------------------------------------------------------------------------------
(not an Autodesk consultant)
Message 7 of 13

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.

Message 8 of 13
fieldguy
in reply to: BellwetherBill

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

 

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

Message 9 of 13
Alfred.NESWADBA
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 ... blog.hollaus.at ... CDay 2024
------------------------------------------------------------------------------------
(not an Autodesk consultant)
Message 10 of 13

Alfred,

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

Message 11 of 13
cincir
in reply to: BellwetherBill

try more reliable acDoc.Database.SaveAs(acDoc.Name, True, DwgVersion.Current, acDoc.Database.SecurityParameters) instead.

Message 12 of 13
BellwetherBill
in reply to: cincir

That works. Thanks for your help.

Message 13 of 13
BellwetherBill
in reply to: cincir

Interesting. When I set the bBakAndRename argument to false I get the "eInvalidInput" error again.

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