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

How to keep selection ?

1 REPLY 1
Reply
Message 1 of 2
JuramemO
359 Views, 1 Reply

How to keep selection ?

 

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

 

1 REPLY 1
Message 2 of 2
_gile
in reply to: JuramemO

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

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