Hi there,
@The moment i am trying to get the saveAs settings that were used when the user hits the save/saveAs button in autocad.
My addin needs to store the current document with these settings. i dont want to use some pop-up dialog.
The .currentVersion property saves the document with the applicationversions standard saveprofile.
I need some kind of property that reflects the users saveAs settings.
Is there any way getting those information via the .net api without doing the interop stuff?
thank you
Solved! Go to Solution.
Solved by Alexander.Rivilis. Go to Solution.
Solved by Alexander.Rivilis. Go to Solution.
Solved by Alexander.Rivilis. Go to Solution.
If you mean the current format for save, then, for example:
[CommandMethod("DefForSave")] public static void DefForSave() { Document doc = Application.DocumentManager.MdiActiveDocument; Editor ed = doc.Editor; object acadObject = Application.AcadApplication; object preferences = acadObject.GetType().InvokeMember("Preferences", BindingFlags.GetProperty, null, acadObject, null); object prefOpenSave = preferences.GetType().InvokeMember("OpenSave", BindingFlags.GetProperty, null, preferences, null); object dwgversion = prefOpenSave.GetType().InvokeMember("SaveAsType", BindingFlags.GetProperty, null, prefOpenSave, null); ed.WriteMessage("\nDefault Format For Save= {0}", dwgversion); }
Відповідь корисна? Клікніть на "ВПОДОБАЙКУ" цім повідомленням! | Do you find the posts helpful? "LIKE" these posts!
Находите сообщения полезными? Поставьте "НРАВИТСЯ" этим сообщениям!
На ваше запитання відповіли? Натисніть кнопку "ПРИЙНЯТИ РІШЕННЯ" | Have your question been answered successfully? Click "ACCEPT SOLUTION" button.
На ваш вопрос успешно ответили? Нажмите кнопку "УТВЕРДИТЬ РЕШЕНИЕ"
Alexander Rivilis / Александр Ривилис / Олександр Рівіліс
Programmer & Teacher & Helper / Программист - Учитель - Помощник / Програміст - вчитель - помічник
Facebook | Twitter | LinkedIn
Thank you very much for your quick answer Alexander,
i am getting an integer value.
unfortuntley i cannot just use this value within the saveAs method of my document.
i get the following values
DWG2010: 48
DWG2007: 36
DWG2000: 12
is there any mapping-Table ? do i have to map it myself?
@Anonymous wrote:
Thank you very much for your quick answer Alexander,
i am getting an integer value.
unfortuntley i cannot just use this value within the saveAs method of my document.
i get the following values
DWG2010: 48
DWG2007: 36
DWG2000: 12
is there any mapping-Table ? do i have to map it myself?
But you can use this value with AcadDocument.SaveAs method:
object adoc = doc.AcadDocument; object [] parms = new object[2]; parms[0] = doc.Name; parms[1] = dwgversion; adoc.GetType().InvokeMember("SaveAs", BindingFlags.InvokeMethod, null, adoc, parms);
Відповідь корисна? Клікніть на "ВПОДОБАЙКУ" цім повідомленням! | Do you find the posts helpful? "LIKE" these posts!
Находите сообщения полезными? Поставьте "НРАВИТСЯ" этим сообщениям!
На ваше запитання відповіли? Натисніть кнопку "ПРИЙНЯТИ РІШЕННЯ" | Have your question been answered successfully? Click "ACCEPT SOLUTION" button.
На ваш вопрос успешно ответили? Нажмите кнопку "УТВЕРДИТЬ РЕШЕНИЕ"
Alexander Rivilis / Александр Ривилис / Олександр Рівіліс
Programmer & Teacher & Helper / Программист - Учитель - Помощник / Програміст - вчитель - помічник
Facebook | Twitter | LinkedIn
Good morning Alexander.
Your suggestions where just perfect. Exactly what i was looking for. Thank you very much.
Is there any documentation about the invokemembers and its parameters for ACAD2012/13?
For the rest of this thread it can be closed. 5-Stars-Rating. 😄
InvokeMember is a method of type System.Type (part of Reflection)
AcadDocument, AcadPreferences, etc. are classes from AutoCAD ActiveX API
Відповідь корисна? Клікніть на "ВПОДОБАЙКУ" цім повідомленням! | Do you find the posts helpful? "LIKE" these posts!
Находите сообщения полезными? Поставьте "НРАВИТСЯ" этим сообщениям!
На ваше запитання відповіли? Натисніть кнопку "ПРИЙНЯТИ РІШЕННЯ" | Have your question been answered successfully? Click "ACCEPT SOLUTION" button.
На ваш вопрос успешно ответили? Нажмите кнопку "УТВЕРДИТЬ РЕШЕНИЕ"
Alexander Rivilis / Александр Ривилис / Олександр Рівіліс
Programmer & Teacher & Helper / Программист - Учитель - Помощник / Програміст - вчитель - помічник
Facebook | Twitter | LinkedIn
I realize this is an old post, but does this not work for 2016? I keep getting this error:
Method 'Autodesk.AutoCAD.ApplicationServices.Document.Saveas' not found.
I may have something wrong in my code, here's what I'm using:
Autodesk.AutoCAD.ApplicationServices.Document doc2 = Application.DocumentManager.MdiActiveDocument; //Get preferences set in AutoCAD for saveas file version. object acadObject = Application.AcadApplication; object preferences = acadObject.GetType().InvokeMember("Preferences", BindingFlags.GetProperty, null, acadObject, null); object prefOpenSave = preferences.GetType().InvokeMember("OpenSave", BindingFlags.GetProperty, null, preferences, null); object dwgversion = prefOpenSave.GetType().InvokeMember("SaveAsType", BindingFlags.GetProperty, null, prefOpenSave, null); ... .. object [] parms = new object[2]; parms[0] = DWGSaveName; parms[1] = dwgversion; DwgVersion ver = (DwgVersion)dwgversion; object adoc = doc2; //acDB.SaveAs(DWGSaveName, true, (DwgVersion)ver, acDB.SecurityParameters); adoc.GetType().InvokeMember("Saveas", BindingFlags.InvokeMethod, null, adoc, parms); returnMsg = "Success";
What am I doing wrong?
Try replace line of code:
object adoc = doc2;
with
object adoc = doc2.GetAcadDocument();
Відповідь корисна? Клікніть на "ВПОДОБАЙКУ" цім повідомленням! | Do you find the posts helpful? "LIKE" these posts!
Находите сообщения полезными? Поставьте "НРАВИТСЯ" этим сообщениям!
На ваше запитання відповіли? Натисніть кнопку "ПРИЙНЯТИ РІШЕННЯ" | Have your question been answered successfully? Click "ACCEPT SOLUTION" button.
На ваш вопрос успешно ответили? Нажмите кнопку "УТВЕРДИТЬ РЕШЕНИЕ"
Alexander Rivilis / Александр Ривилис / Олександр Рівіліс
Programmer & Teacher & Helper / Программист - Учитель - Помощник / Програміст - вчитель - помічник
Facebook | Twitter | LinkedIn
Can't find what you're looking for? Ask the community or share your knowledge.