.NET
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic to the Top
- Bookmark
- Subscribe
- Printer Friendly Page
Get|Set Alignment of DBText
Options
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
158 Views, 2 Replies
12-07-2006 12:53 PM
I'm receiving a DBText object from the User. I want to create a given number of DBText objects changing the text string based on entered information. I want all of the newly created DBText objects to have the Same Justification. I know the DBText object Has (Boolean IsDefaultAlignment) and (Point3d AlignmentPoint), but there doesn't seem to be a way to get what the Alignment is of the Selected obj.
Any help is greatly appreciated,
Adam
Any help is greatly appreciated,
Adam
*Luis Esquivel
Re: Get|Set Alignment of DBText
Options
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
12-07-2006 01:39 PM in reply to:
acedmond
>to be a way to get what the Alignment is of the Selected obj.
Use something like this:
[CommandMethod("DBTEXT")]
public void dbtext()
{
Document doc = acadApp.DocumentManager.MdiActiveDocument;
Editor ed = doc.Editor;
Database db = doc.Database;
PromptEntityResult res = ed.GetEntity("\nSelect text: ");
if (res.Status != PromptStatus.OK) return;
using (Transaction tr =
db.TransactionManager.StartTransaction())
{
DBText text = tr.GetObject(res.ObjectId, OpenMode.ForRead,
false) as DBText;
ed.WriteMessage("\nAlignment is " +
text.HorizontalMode.ToString());
tr.Commit();
}
}
Use something like this:
[CommandMethod("DBTEXT")]
public void dbtext()
{
Document doc = acadApp.DocumentManager.MdiActiveDocument;
Editor ed = doc.Editor;
Database db = doc.Database;
PromptEntityResult res = ed.GetEntity("\nSelect text: ");
if (res.Status != PromptStatus.OK) return;
using (Transaction tr =
db.TransactionManager.StartTransaction())
{
DBText text = tr.GetObject(res.ObjectId, OpenMode.ForRead,
false) as DBText;
ed.WriteMessage("\nAlignment is " +
text.HorizontalMode.ToString());
tr.Commit();
}
}
*Luis Esquivel
Re: Get|Set Alignment of DBText
Options
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
12-07-2006 03:22 PM in reply to:
acedmond
I wrote, the previous code to fast.... and forgot something - to check if we
select a text....:
[CommandMethod("DBTEXT")]
public void dbtext()
{
Document doc = acadApp.DocumentManager.MdiActiveDocument;
Editor ed = doc.Editor;
Database db = doc.Database;
//PromptEntityOptions prOpt = new PromptEntityOptions("\nSelect
text: ");
//prOpt.SetRejectMessage("\nText object only!");
//prOpt.AddAllowedClass(typeof(DBText), true);
//PromptEntityResult rs = ed.GetEntity(prOpt);
PromptEntityResult res = ed.GetEntity("\nSelect text: ");
if (res.Status != PromptStatus.OK) return;
using (Transaction tr =
db.TransactionManager.StartTransaction())
{
DBText text = tr.GetObject(res.ObjectId, OpenMode.ForRead,
false) as DBText;
if (text != null)
{
ed.WriteMessage("\nAlignment is " +
text.HorizontalMode.ToString());
}
tr.Commit();
}
}
select a text....:
[CommandMethod("DBTEXT")]
public void dbtext()
{
Document doc = acadApp.DocumentManager.MdiActiveDocument;
Editor ed = doc.Editor;
Database db = doc.Database;
//PromptEntityOptions prOpt = new PromptEntityOptions("\nSelect
text: ");
//prOpt.SetRejectMessage("\nText object only!");
//prOpt.AddAllowedClass(typeof(DBText), true);
//PromptEntityResult rs = ed.GetEntity(prOpt);
PromptEntityResult res = ed.GetEntity("\nSelect text: ");
if (res.Status != PromptStatus.OK) return;
using (Transaction tr =
db.TransactionManager.StartTransaction())
{
DBText text = tr.GetObject(res.ObjectId, OpenMode.ForRead,
false) as DBText;
if (text != null)
{
ed.WriteMessage("\nAlignment is " +
text.HorizontalMode.ToString());
}
tr.Commit();
}
}

