uidoc.Selection.Elements.Add(element);
[Transaction(TransactionMode.Manual)]
[Regeneration(RegenerationOption.Manual)]
public class OpenDoc : IExternalCommand
{
public Result Execute(ExternalCommandData commandData, ref string messages, ElementSet elements)
{
UIDocument uidoc = commandData.Application.ActiveUIDocument;
//得到選擇的物件
//Selection selection = uidoc.Selection;
//ElementSet collection = selection.Elements;
//if (0 == collection.Size)
//{
// TaskDialog.Show("Revit", "You haven't selected any elements");
//}
//else
//{
// string info = "Ids of selected elements in the document are:";
// foreach (Element elem in collection)
// {
// info += "\n\t" + elem.Id.IntegerValue;
// }
// TaskDialog.Show("Revit", info);
//}
Element el = uidoc.Document.get_Element(new ElementId(506025));//得到物件
SelElementSet selElements = uidoc.Selection.Elements;//新增到選擇集裡
selElements.Add(el);
return Result.Succeeded;
}
}
[Regeneration(RegenerationOption.Manual)]
public class OpenDoc : IExternalCommand
{
public Result Execute(ExternalCommandData commandData, ref string messages, ElementSet elements)
{
UIDocument uidoc = commandData.Application.ActiveUIDocument;
//得到選擇的物件
//Selection selection = uidoc.Selection;
//ElementSet collection = selection.Elements;
//if (0 == collection.Size)
//{
// TaskDialog.Show("Revit", "You haven't selected any elements");
//}
//else
//{
// string info = "Ids of selected elements in the document are:";
// foreach (Element elem in collection)
// {
// info += "\n\t" + elem.Id.IntegerValue;
// }
// TaskDialog.Show("Revit", info);
//}
Element el = uidoc.Document.get_Element(new ElementId(506025));//得到物件
SelElementSet selElements = uidoc.Selection.Elements;//新增到選擇集裡
selElements.Add(el);
return Result.Succeeded;
}
}