.NET

Reply
Active Member
Posts: 10
Registered: ‎10-29-2013
Message 1 of 2 (100 Views)

How to keep selection ?

100 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*
Posts: 1,992
Registered: ‎04-29-2006
Message 2 of 2 (93 Views)

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

You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

Announcements
Are you interested in helping shape the Autodesk Community?
We’re looking at a few different ways to improve the “All Forums” landing page and need your feedback! If interested, please take a few minutes to fill out the following Usability Study. Thank you for your time!

Need installation help?

Start with some of our most frequented solutions to get help installing your software.

Ask the Community