此处设置为只能选择体量
/// <summary>
/// 设定选择只能是体量
/// </summary>
public class FormSelectionFilter : ISelectionFilter
{
public bool AllowElement(Element elem)
{
if (elem.Category.Name == "体量")
return true;
else return false;
}
public bool AllowReference(Reference reference, XYZ position)
{
return false;
}
}
private void button_ClickChoose(object sender, RoutedEventArgs e)
{
this.Hide();
Element ele;
try
{
Reference reference = uidoc.Selection.PickObject(ObjectType.Element, new FormSelectionFilter());
ele = doc.GetElement(reference) as Element;
this.Show();
textBoxOne.Text = ele.Category.Name;
}
catch (Exception ex)
{
TaskDialog.Show("选择错误", ex.Message);
}
finally
{
this.Show();
}
}