Unable to select Object from the form

Unable to select Object from the form

Arciviz
Advocate Advocate
331 Views
2 Replies
Message 1 of 3

Unable to select Object from the form

Arciviz
Advocate
Advocate

Unable to select Object from "Click Button" in the form.

private void DrawBySelect_Click(object sender, EventArgs e)
    {
      IsolatedFootingDGVData = IsolatedFootingDGV;
      var sel = uiDoc.Selection;
      this.Hide();

      var selectionFilter = new KJF.FamilySelectionFilter(
        doc, BuiltInCategory.OST_StructuralFoundation, "Isolated RCC Footing 2022_BT");

      var elem = doc.GetElement(
       sel.PickObject(ObjectType.Element, selectionFilter)) as FamilyInstance;

      var design_ID = elem.get_Parameter(BuiltInParameter.ELEM_TYPE_PARAM).AsValueString();

      var row = IsolatedFootingDGV.Rows.Cast<DataGridViewRow>()
        .Where(r => r.Cells["DesignID"].Value.ToString().Equals(design_ID)).First();
      this.Show();
      
    }

 

0 Likes
Accepted solutions (1)
332 Views
2 Replies
Replies (2)
Message 2 of 3

Arciviz
Advocate
Advocate
Accepted solution
0 Likes
Message 3 of 3

RPTHOMAS108
Mentor
Mentor

The alternative depending on the complexity of your form would be to close the form after saving it's state carry out the selection operation and then reshow the form with values reinstated.

 

  1. Save values from form
  2. Call Form.Close
  3. Carry out Revit selection operation
  4. Create new Form adding values back from (1)
  5. ShowDialog

 

For a simple modal dialogue this is often more straightforward than external event.

 

If your form is modeless then external event is the way to do.