.NET

Reply
Active Member
9 Posts
0 Kudos
Registered: ‎06-15-2006
Post 1 of 3

Get|Set Alignment of DBText

189 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
*Luis Esquivel
Post 2 of 3

Re: Get|Set Alignment of DBText

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

}
*Luis Esquivel
Post 3 of 3

Re: Get|Set Alignment of DBText

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

}
Post to the Community

Have questions about Autodesk products? Ask the community.

New Post