.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Get|Set Alignment of DBText

2 REPLIES 2
Reply
Message 1 of 3
acedmond
508 Views, 2 Replies

Get|Set Alignment of DBText

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
2 REPLIES 2
Message 2 of 3
Anonymous
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();
}

}
Message 3 of 3
Anonymous
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();
}

}

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost