• Industries
  • Products
  • Buy
  • Services & Support
  • Communities
  • Discussion Groups

    .NET

    Reply
    Active Member
    Posts: 9
    Registered: ‎06-15-2006

    Get|Set Alignment of DBText

    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
    Please use plain text.
    *Luis Esquivel

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

    }
    Please use plain text.
    *Luis Esquivel

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

    }
    Please use plain text.