當前位置:編程學習大全網 - 編程語言 - 如何編程隱藏Revit 中的組Group

如何編程隱藏Revit 中的組Group

可以分別隱藏組中的對象,達到對這個組進行隱藏的目的。

Through Revit UI

command, we can hide group by picking it and click the hide command like

other elements. Howerver I cannot hide group via API.

Here is the DevelopSharp code I used.

public void hidegroup()

{

Document doc = this.ActiveUIDocument.Document;

Selection sel = this.ActiveUIDocument.Selection;

Reference ref1 = sel.PickObject(ObjectType.Element,"Please pick a group");

Element elem = doc.GetElement(ref1);

IList<ElementId> lists = new List<ElementId>();

lists.Add(elem.Id);

Transaction trans = new Transaction(doc);

trans.Start("hidegroup");

doc.ActiveView.HideElements(lists);

trans.Commit ();

}

Launch the command, pick any group, error occurs. The error message is :

Revit failed to execute hidegroup.

A problem has been detected.

Then how can we hide a group? Any tricks?

Solution

Groups

cannot be hidden or overridde like ordinary elements. In order to hide a

group, we need to hide the element set in that group by HideElements()

method. The good aspect is that we can hide part of a group.

Here is the code to hide the whole group.

public void hidegroup()

{

Document doc = this.ActiveUIDocument.Document;

Selection sel = this.ActiveUIDocument.Selection;

Reference ref1 = sel.PickObject(ObjectType.Element,"Please pick a group");

Element elem = doc.GetElement(ref1);

IList<ElementId> lists = new List<ElementId>();

Group g = elem as Group;

IList<ElementId> ids = g.GetMemberIds();

Transaction trans = new Transaction(doc);

trans.Start("hidegroup");

this.ActiveUIDocument.ActiveView.HideElements(ids);

trans.Commit ();

}

原文鏈接: /joexiongjin/article/details/17915301

  • 上一篇:什麽電影中3D投影畫面?
  • 下一篇:步進電機不用控制器不用PLC,怎麽直接運轉?別人說可以!
  • copyright 2024編程學習大全網