Message 1 of 3
Change an Entity in an Extern DWG
Not applicable
11-28-2007
03:10 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi,
I want to change an Mtext in an extern DWG.
I Tried it with this code:
Database db = new Database(false, false);
db.ReadDwgFile("C:\\Zeichnung123.dwg", System.IO.FileShare.ReadWrite, true, "");
Autodesk.AutoCAD.DatabaseServices.TransactionManager tm = db.TransactionManager;
Autodesk.AutoCAD.DatabaseServices.Transaction tr = tm.StartTransaction();
//texte.Contents = FormSprache.ShowDialog("");
//PromptPointOptions prPO = new PromptPointOptions("\nAn welche Stelle soll das Textfeld");
PromptStringOptions pso1 = new PromptStringOptions("Geben Sie die ObjectId ein:");
PromptResult presult = ed.GetString(pso1);
if (presult.Status == PromptStatus.OK)
{
String stringobjectid = presult.StringResult.ToString();
ObjectId test = new ObjectId(2130268248);
test.GetObject(OpenMode.ForWrite, false);
MText texte = (MText)tm.GetObject(test, OpenMode.ForWrite);
texte.Contents = "blablub";
tr.Commit();
MeineForms.MessageBox.Show(texte.ObjectId.ToString());
}
if i run the code then Autocad says that he not found the ObjectId.
But if i open the dwg and try the same on the activedocument database it is successfully.
I hope anybody can help me.
Maybe in you can answer me in german 🙂
Greetings Steffen
I want to change an Mtext in an extern DWG.
I Tried it with this code:
Database db = new Database(false, false);
db.ReadDwgFile("C:\\Zeichnung123.dwg", System.IO.FileShare.ReadWrite, true, "");
Autodesk.AutoCAD.DatabaseServices.TransactionManager tm = db.TransactionManager;
Autodesk.AutoCAD.DatabaseServices.Transaction tr = tm.StartTransaction();
//texte.Contents = FormSprache.ShowDialog("");
//PromptPointOptions prPO = new PromptPointOptions("\nAn welche Stelle soll das Textfeld");
PromptStringOptions pso1 = new PromptStringOptions("Geben Sie die ObjectId ein:");
PromptResult presult = ed.GetString(pso1);
if (presult.Status == PromptStatus.OK)
{
String stringobjectid = presult.StringResult.ToString();
ObjectId test = new ObjectId(2130268248);
test.GetObject(OpenMode.ForWrite, false);
MText texte = (MText)tm.GetObject(test, OpenMode.ForWrite);
texte.Contents = "blablub";
tr.Commit();
MeineForms.MessageBox.Show(texte.ObjectId.ToString());
}
if i run the code then Autocad says that he not found the ObjectId.
But if i open the dwg and try the same on the activedocument database it is successfully.
I hope anybody can help me.
Maybe in you can answer me in german 🙂
Greetings Steffen