Message 1 of 6
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi all,
I.m trying to convert my 2012 code to 2015, but I'm having problems with a part of my code where I want to switch to modelspace. In 2012 I used
ed.Command("_.TILEMODE", "1");This works as expected. But in 2015 this gives an 'einvalidinput' exception. After reading the ObjectArx 2015 documentation I changed that line to:
ed.Command(new Object[] { "_.TILEMODE", "1" });but that still gives an 'einvalidinput' exception.
I also tried
Autodesk.AutoCAD.ApplicationServices.Application.SetSystemVariable("TILEMODE", 1);
oDoc.SendStringToExecute("_.TILEMODE 1 ", true, false, false);but both seem to do nothing.
Below is the entire code which is called from an UserControl within a paletteset:
private void exportbutton_Click(object sender, EventArgs e)
{
string dwgFileName = Autodesk.AutoCAD.ApplicationServices.Application.GetSystemVariable("DWGNAME") as string;
string dwgPath = Autodesk.AutoCAD.ApplicationServices.Application.GetSystemVariable("DWGPREFIX") as string;
string tmp = "TBX_" + dwgFileName.Remove(dwgFileName.Length - 4);
SaveFileDialog saveFileDialog1 = new SaveFileDialog();
saveFileDialog1.FileName = tmp;
saveFileDialog1.InitialDirectory = dwgPath;
saveFileDialog1.RestoreDirectory = true;
saveFileDialog1.Filter = "Autocad dwg(*.dwg)|*.dwg";
DialogResult result1 = saveFileDialog1.ShowDialog();
if (result1 == DialogResult.OK)
{
try
{
Database db = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Database;
db.SaveAs(saveFileDialog1.FileName, DwgVersion.Current);
Document oDoc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.Open(saveFileDialog1.FileName, false);
var ed = oDoc.Editor;
string bordlaag = "";
BordnrClass bnc = new BordnrClass();
bordlaag = bnc.bordlaag();
if (bordlaag == "")
{
bordlaag = "tekstborden";
}
TSNedTool.clsTSNed tscl = new TSNedTool.clsTSNed();
using (Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.LockDocument())
{
corelExportClass cec = new corelExportClass();
cec.export_to_corel();
UnlockLayersClass ul = new UnlockLayersClass();
ul.UnlockAllLayers();
BordColorClass bcc = new BordColorClass();
bcc.Change_bord_color();
SorteerBordenClass srtbrd = new SorteerBordenClass();
srtbrd.SorteerBorden();
tscl.ReScaleBorden();
tscl.RotateBorden();
tscl.LayersOnUnlockUnfrozen();
tscl.CleanUpEverythingExceptBorden(bordlaag);
tscl.CleanUpVisibility();
tscl.LayersVerwijderen();
//tscl.PurgeAll();
//PurgeAll pg = new PurgeAll();
//while (pg.purgeAll(db, false))
// continue;
if (LayoutManager.Current.CurrentLayout != "Model")
{
ed.Command("_.TILEMODE", "1");
//Autodesk.AutoCAD.ApplicationServices.Application.SetSystemVariable("TILEMODE", 1);
//ed.Command(new Object[] { "_.TILEMODE", "1" });
//oDoc.SendStringToExecute("_.TILEMODE 1 ", true, false, false);
}
ed.Command("_.ZOOM", "EXTENTS");
//ed.Command(new Object[] { "_.ZOOM", "EXTENTS" });
//oDoc.SendStringToExecute("_.ZOOM EXTENTS ", true, false, false);
oDoc.Editor.Regen();
}
oDoc.CloseAndSave(oDoc.Name);
Autodesk.AutoCAD.ApplicationServices.Application.UpdateScreen();
}
catch(Autodesk.AutoCAD.Runtime.Exception ex)
{
MessageBox.Show("Fout bij exporteren naar Coreldraw bestand!", "Export error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
Am I using editor.command incorrectly, or is there something else I'm missing?
Solved! Go to Solution.