Select multiple texts with many annotative scales

Select multiple texts with many annotative scales

hoanggiacf258
Participant Participant
216 Views
1 Reply
Message 1 of 2

Select multiple texts with many annotative scales

hoanggiacf258
Participant
Participant

I have texts with multiple annotative scales and need to filter and select only those matching a specific scale. Suppose I have a series of texts I want to move—I can manually grab the grip and move them, but with a large quantity, this becomes impractical.

I assumed that using SELECTIONANNODISPLAY would display only the annotative scale I intended to modify—such as 1:30—but when I moved the selected texts, those with other annotative scales changed simultaneously.

How can I select multiple texts and move them simultaneously without affecting the position of texts with a different annotation scale? I’ve tried using filter, quick select, and select similar, but none seem to allow selecting texts based on a specific annotation scale.

Thanks everyone!

hoanggiacf258_0-1749787350170.png

 

0 Likes
217 Views
1 Reply
Reply (1)
Message 2 of 2

Gepaha
Collaborator
Collaborator

See if this helps you.

https://adndevblog.typepad.com/autocad/2015/07/setting-position-of-an-mtext-for-each-annotation-scal...

public void SetMTextPositionByAnnotativeScaleContext()
{
    Document doc = Application.DocumentManager.MdiActiveDocument;
    Database db = doc.Database;
    Editor ed = doc.Editor;
    string contextNameToMove = "1:50";

    ObjectContextManager ocm = db.ObjectContextManager;
    ObjectContextCollection occ = ocm.GetContextCollection("ACDB_ANNOTATIONSCALES");

    if (ocm == null)
        return;

    if (!occ.HasContext(contextNameToMove))
        return;            

    PromptSelectionOptions pso = new PromptSelectionOptions();
    pso.MessageForAdding = "\nSelect MText annotative objects";
    PromptSelectionResult psr = ed.GetSelection(pso);
    if (psr.Status != PromptStatus.OK) return;

    var dbAnnoScale = db.Cannoscale;
    try
    {
        using (Transaction tr = db.TransactionManager.StartTransaction())
        {           
            ObjectContext objectContextToMove = occ.GetContext(contextNameToMove);
            foreach (SelectedObject so in psr.Value)
            {
                MText mt = tr.GetObject(so.ObjectId, OpenMode.ForRead) as MText;

                if (mt != null && mt.Annotative == AnnotativeStates.True && mt.HasContext(objectContextToMove))
                {
                    AnnotationScale annoScaleToMove = objectContextToMove as AnnotationScale;
                    Point3d pos = mt.Location;
                    db.Cannoscale = annoScaleToMove;                    
                    mt.UpgradeOpen();
                    mt.Location = pos + Vector3d.XAxis * mt.TextHeight + Vector3d.YAxis * mt.TextHeight;
                }
            }                    
            tr.Commit();
        }                
    }
    finally
    {
        db.Cannoscale = dbAnnoScale;
    }
}
0 Likes