.NET

Reply
Active Member
acedmond
Posts: 9
Registered: ‎06-15-2006
Message 1 of 3 (184 Views)

Get|Set Alignment of DBText

184 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
Message 2 of 3 (184 Views)

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
Message 3 of 3 (184 Views)

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
Need installation help?

Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.