.NET

Reply
Active Member
MiDu75
Posts: 7
Registered: ‎11-12-2012
Message 1 of 6 (283 Views)
Accepted Solution

Getting Saving Settings.

283 Views, 5 Replies
02-21-2013 05:15 AM

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

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);
}

 


MiDu75 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);

 

Moderator
Alexander.Rivilis
Posts: 1,457
Registered: ‎04-09-2008
Message 2 of 6 (263 Views)

Re: Getting Saving Settings.

02-21-2013 07:09 AM in reply to: MiDu75

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);
}

 


Пожалуйста не забывайте про Утвердить в качестве решения! Утвердить в качестве решения и Give Kudos!Баллы
Please remember to Accept Solution! Accept as Solution and Give Kudos!Kudos

Active Member
MiDu75
Posts: 7
Registered: ‎11-12-2012
Message 3 of 6 (255 Views)

Re: Getting Saving Settings.

02-21-2013 07:50 AM in reply to: Alexander.Rivilis

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?

Moderator
Alexander.Rivilis
Posts: 1,457
Registered: ‎04-09-2008
Message 4 of 6 (253 Views)

Re: Getting Saving Settings.

02-21-2013 07:52 AM in reply to: MiDu75

MiDu75 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);

 


Пожалуйста не забывайте про Утвердить в качестве решения! Утвердить в качестве решения и Give Kudos!Баллы
Please remember to Accept Solution! Accept as Solution and Give Kudos!Kudos

Active Member
MiDu75
Posts: 7
Registered: ‎11-12-2012
Message 5 of 6 (228 Views)

Re: Getting Saving Settings.

02-21-2013 11:53 PM in reply to: Alexander.Rivilis

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. :smileyvery-happy:

Moderator
Alexander.Rivilis
Posts: 1,457
Registered: ‎04-09-2008
Message 6 of 6 (220 Views)

Re: Getting Saving Settings.

02-22-2013 02:12 AM in reply to: MiDu75

InvokeMember is a method of type System.Type (part of Reflection)

AcadDocument, AcadPreferences, etc. are classes from AutoCAD ActiveX API

 


Пожалуйста не забывайте про Утвердить в качестве решения! Утвердить в качестве решения и Give Kudos!Баллы
Please remember to Accept Solution! Accept as Solution and Give Kudos!Kudos

Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Do you have 60 seconds to spare? The Autodesk Community Team is revamping our site ranking system and we want your feedback! Please click here to launch the 5 question survey. As always your input is greatly appreciated.