.NET

Reply
Active Member
10 Posts
0 Kudos
Registered: ‎10-29-2013
Post 1 of 2

How to keep selection ?

138 Views, 1 Replies
11-27-2013 01:50 AM

 

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

 

*Expert Elite*
2,140 Posts
253 Kudos
Registered: ‎04-29-2006
Post 2 of 2

Re : How to keep selection ?

11-27-2013 02:20 AM in reply to: JuramemO

Hi,

 

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

edt.SetImpliedSelection(sel.Value);

 

Gilles Chanteau
Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Are you interested in helping shape the future of the Autodesk Community? To participate in this brief usability study, please click here. Your time and input is greatly appreciated!