.NET
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic to the Top
- Bookmark
- Subscribe
- Printer Friendly Page
SaveAs with paperspace layout current
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
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?
Solved! Go to Solution.
Re: SaveAs with paperspace layout current
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
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
-------------------------------------------------------------------------
Re: SaveAs with paperspace layout current
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
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
Re: SaveAs with paperspace layout current
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
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
-------------------------------------------------------------------------
Re: SaveAs with paperspace layout current
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
I will ultimately be needing to plot my layouts. Do I need it to be loaded into the editor to plot?
Re: SaveAs with paperspace layout current
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
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
-------------------------------------------------------------------------
Re: SaveAs with paperspace layout current
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
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.
Re: SaveAs with paperspace layout current
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
I can't recall where I found this. Worth a try maybe.
db.SaveAs(dwgfile, True, DwgVersion.Current, db.SecurityParameters)
Re: SaveAs with paperspace layout current
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
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
-------------------------------------------------------------------------
Re: SaveAs with paperspace layout current
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Alfred,
I tried your suggestion but got the same result "eInvalidInput".


