How to keep selection ?

How to keep selection ?

Anonymous
Not applicable
486 Views
1 Reply
Message 1 of 2

How to keep selection ?

Anonymous
Not applicable

 

Hallo to all!

 

My code takes the selected entities and reads out all the text of the attributes.

If no blocks are selected, the code prompts for a selection.

 

Unfortunately, by ending the transaction, the entitis are deselected.

 

So how to keep the selection, because it will be handled in a follow-up step.

 

thank you for any suggestion.

 

below a shortened code for the procedure:

 

private void Get_Text()
{
  Autodesk.AutoCAD.Internal.Utils.SetFocusToDwgView(); 
  PromptSelectionResult sel = edt.SelectImplied();
  
  if (sel.Status == PromptStatus.Error)
  {
    TypedValue[] auswahl_typ = new TypedValue[] { new TypedValue((int)DxfCode.Start, "INSERT") };
    SelectionFilter auswahl_filtern = new SelectionFilter(auswahl_typ);
    PromptSelectionOptions pso = new PromptSelectionOptions();
    
    pso.MessageForAdding = "\nMake a selection";
    sel = edt.GetSelection(pso, auswahl_filtern);
    
    if (sel.Status != PromptStatus.OK)//
    {
      edt.WriteMessage("\nSelection failed");
      return;
    }//if
  }//if
//-------------------------------------------------------------------------------------
  try
  {
    using (Transaction tr = db.TransactionManager.StartTransaction()) 
    {
      using (DocumentLock dwg_lock = dwg.LockDocument())// Aktive Zeichnung wird wärend der Bearbeitung gesprerrt    
      {
		
		// Code for reading out the text form the choosen blocks
		
      }// using DocumentLock
    }// using Transaction
  }// try
  catch { edt.WriteMessage("\n#Error! Task failed"); }
}// void

 

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

_gile
Consultant
Consultant

Hi,

 

In the Get_Text method, at the end of the code, add:

edt.SetImpliedSelection(sel.Value);

 



Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub