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;
}
}