I’m pretty sure Archi-lab package has node that controls hiding.
Imho it’s way better to add filter to view template (manually or by dynamo) instead of hiding.
I’m pretty sure Archi-lab package has node that controls hiding.
I think archilab and clockwork have nodes for this.
Thanks for the response. My purpouse is to hide the area reinforcement of a wall in a section view, and keep only de wall corner/edge rebars visible in view.
So, if I set a filter, it will affect all the rebars in the view. Not exactly what I need.
Hi @Konrad_K_Sobon, quick question. There is a node for hiding elements in view in archi.lab or clockwork?
Thanks in advance!
Here you go he has made this as a node archi-lab
Confirmed it myself - there is a View.HideElements node in Archi-Lab which will do what you’re looking for. Feed in a list of views, an Element and a true bool.
There is a temporary hide in clockwork, which can be made permanent, but you’re looking for permanent so run the archilab one instead.
No probs…you have enough python examples on that post so you can learn on your spare time and apply what you learn to future custom scripts. All konrads python code are like a fountain of knowledge as it was written focusing for others to pickup and learn.
Thanks for the info!
It might be an off topic comment but I reckon just because you can do this with Dynamo it doesn’t mean it’s a good practice.
I would push a parameter or a comment to those families created using Dynamo and then do the hiding with view template using either uncheking model element visibility in view or filters. Hiding using “hide element in view” generally is not considered a good practice because of the hassle it can bring when you try to unhide things. You might find some of the things you don’t want will get unhidden accidentally by user etc…
I can’t get arch-lab’s View.HideElements to work.
Comes up with error saying object has no atttribute ‘IsHidden’.
Surely floors can be hidden?
List of Views doesn’t match list of floors.
Hi, try putting a “Flatten” after the AllElementsOnLevelByCategory.
Konrad, not sure what you mean:
Element 613030 is visible (within section box) of view 3D of Ground
Element 613038 is visible (within section box) of view 3D of Level 1
Element 613046 is visible (within section box) of view 3D of Level 2
Element 613054 is visible (within section box) of view 3D of Level 3
Tried that. Same error. Also not what I want, there could be multiple elements to hide per view.
Just to be clear what I am attempting to do:
I have a list of views, and a list of elements I want to hide in each view.
view hide elements (where elements[n] is a list of elements)
view hide elements
Since the node can take lists of views I thought it would be able to do this.
Thinking about it maybe the node hides the same elements in multiple views.
So I thought maybe adding a loop to go through list of views might work.
try: errorReport = None TransactionManager.Instance.EnsureInTransaction(doc) #loop through list of views count = 0 if count < len(views): ProcessListArg(HideElements, views[count], elements[count]) count = count+1 TransactionManager.Instance.TransactionTaskDone() except: # if error accurs anywhere in the process catch it import traceback errorReport = traceback.format_exc()
But that just completely killed it. Not that I really knew what I was doing.
The subfunction called is:
def HideElements(v, elements): ids = List[ElementId]() for i in elements: if not i.IsHidden(v) and i.CanBeHidden(v): ids.Add(i.Id) v.HideElements(ids) return None
The error I get is:
I can’t see why is doesn’t work, it is being fed a list.
Did you fixed your error? By just looking at the images above maybe adding a flatten node after your elements list will help? Also is your active/current view on 3D…? If not try it after adding a flatten node. Tnx
I think there is an error in the code i posted - should be while not if.
But still couldn’t get it to work, so I tried a simpler bit of code. But it doesn’t work either, just returns null so I assume the code falls over somewhere in python.
2 lists are fed to it, one a list of views, the other a list of lists of elements.
The fact my counting variable cnt comes back null suggests it fails early on. Although i don’t know because python makes no sense to me.
Python code is:
import clr clr.AddReference('RevitAPI') from Autodesk.Revit.DB import * from System.Collections.Generic import * clr.AddReference("RevitServices") import RevitServices from RevitServices.Persistence import DocumentManager from RevitServices.Transactions import TransactionManager doc = DocumentManager.Instance.CurrentDBDocument view = UnwrapElement(IN) elements = UnwrapElement(IN) TransactionManager.Instance.EnsureInTransaction(doc) cnt = 0 while cnt < len(view): v = view[cnt] ids = list() helements = list() for i in elements[cnt]: if not i.IsHidden(v) and i.CanBeHidden(v): ids.append(i.Id) helements = List[ElementId](ids) v.HideElements(helements) cnt = cnt+1 TransactionManager.Instance.TransactionTaskDone() OUT = (view,elements,cnt)
I can’t see anything wrong with the logic, I can only surmise is has something to do with the way python works. Is UnwrapElement wrong because it is applied to a list and/or a list of lists?
Am I missing an import?
After much forensic effort finally cracked it.
Python is a bitch to code in, one tab or space in the wrong place and caboom.
Also, by trial and error, I discovered List (with a capital) is not the same as list, and Add (also with a capital) is not the same as append. They must be defined in one of the imports.
Anyway here it is:
## 2017/07/20 Antony McPhee ## Hide list of elements per view. Accepts list of views and list of list of elements. ## for view[n] hide things listed in elements[n] import clr # Import Element wrapper extension methods clr.AddReference("RevitNodes") import Revit clr.ImportExtensions(Revit.Elements) # Import DocumentManager and TransactionManager clr.AddReference("RevitServices") import RevitServices from RevitServices.Persistence import DocumentManager from RevitServices.Transactions import TransactionManager # Import RevitAPI clr.AddReference("RevitAPI") import Autodesk from Autodesk.Revit.DB import * import System from System.Collections.Generic import * doc = DocumentManager.Instance.CurrentDBDocument views = UnwrapElement(IN) elements = UnwrapElement(IN) TransactionManager.Instance.EnsureInTransaction(doc) v = list() cnt = 0 while cnt < len(views): v = views[cnt] ids = List[ElementId]() for i in elements[cnt]: if not i.IsHidden(v) and i.CanBeHidden(v): ids.Add(i.Id) v.HideElements(ids) cnt = cnt+1 TransactionManager.Instance.TransactionTaskDone() OUT = views,elements
A bit more to clarify the difference btw List and list in current context.
List is available after
import System and
from System.Collections.Generic import *. Essentially it is a ironPython .NET integration. Check this out. Why we need it? Because
v.HideElements() needs an ICollection input argument. See documentation here.
list is a built-in ironPython data type. list(x) function constructs a list based on an iterable x. There are other ways of use list too. I personally like list literal and list comprehension.
I could use a little help with this one as well. I am trying to create a script that will hide groups on a drafting view/sheet. My intention is to filter groups on a drafting view by the key word “Pm notes” within the group type name. I seem to have the filtering for the groups and the drafting views coordinated however I am getting an error within the archi-lab view.hide elements node. Can you guys help. One post mentioned something about feeding it a list of names so I tried feeding it elementId’s and that didn’t work. This latest iteration is intended to combine element Id with type name prior to filtering but no luck. I also just tried feeding it 1 element Id via the element select node and one view also. It always gives me this same error.