Revit二次开发“创建组遍历组Group”
group 就是吧一些有关系的对象放在一个组里面
from:http://revit.5d6d.com/thread-1216-1-1.html
[Transaction(TransactionMode.Manual)]
[Regeneration(RegenerationOption.Manual)]
//[Journaling(JournalingMode.NoCommandData)]
public class cmdGroup : IExternalCommand
{
public Result Execute(ExternalCommandData cmdData, ref string message, ElementSet elements)
{
UIDocument uiDoc = cmdData.Application.ActiveUIDocument;
Selection selection = uiDoc.Selection;
Transaction ts = new Transaction(uiDoc.Document, "group");
ts.Start();
Group group = null;
ElementSet selections = uiDoc.Selection.Elements;
if (selections.Size > 0)
{
group = uiDoc.Document.Create.NewGroup(selections);
}
group.GroupType.Name = "firstGroup";
//遍历一下group
FilteredElementCollector collector = new FilteredElementCollector(uiDoc.Document);
ICollection<Element> collection = collector.OfClass(typeof(Group)).ToElements();
foreach (Element el in collection)
{
TaskDialog.Show("group", el.Name);
}
ts.Commit();
return Result.Succeeded;
}
}
[Regeneration(RegenerationOption.Manual)]
//[Journaling(JournalingMode.NoCommandData)]
public class cmdGroup : IExternalCommand
{
public Result Execute(ExternalCommandData cmdData, ref string message, ElementSet elements)
{
UIDocument uiDoc = cmdData.Application.ActiveUIDocument;
Selection selection = uiDoc.Selection;
Transaction ts = new Transaction(uiDoc.Document, "group");
ts.Start();
Group group = null;
ElementSet selections = uiDoc.Selection.Elements;
if (selections.Size > 0)
{
group = uiDoc.Document.Create.NewGroup(selections);
}
group.GroupType.Name = "firstGroup";
//遍历一下group
FilteredElementCollector collector = new FilteredElementCollector(uiDoc.Document);
ICollection<Element> collection = collector.OfClass(typeof(Group)).ToElements();
foreach (Element el in collection)
{
TaskDialog.Show("group", el.Name);
}
ts.Commit();
return Result.Succeeded;
}
}
我这个博客废弃不用了,今天想寻找外链的时候,突然想到这个博客权重很高。
有需要免费外链的,留言即可,我准备把这个博客变成免费的友情链接站点。

浙公网安备 33010602011771号