How to hide elements in view?

Hi All,

I’m trying to hide some elements created from a script in a set of views but to show them in others.

for ex. In section views hide the beam elements and in the 3D view show all.

Thanks in advance

3 Likes

Are you referring to visibility graphics or apply view template?

1 Like

I’m referring to thye option “Hide Element in View”:

Hi i am not on a pc to add this on my graph and it will be tomorrow before i can hold of a pc. Ive looked up revit api and it looks like below is your answer

http://www.revitapidocs.com/2016/6b0ae8d1-776a-ad0d-577d-ffdc11673019.htm

Someone else may help in the meantime otherwise i will post tomorrow.

1 Like

Thanks @4bimfercesp. I’m quite new in Revit API, so if you could help/guide me how to implement this in a python node I’d appreciate it.

Thanks in advance for your time!

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.

2 Likes

I think archilab and clockwork have nodes for this.

1 Like

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.

suggestions?

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

1 Like

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.

1 Like

Thanks @jacob.small and @4bimfercesp. Just what I needed!.

1 Like

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.

2 Likes

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…

Cheers.

2 Likes

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.

1 Like

Hi, try putting a “Flatten” after the AllElementsOnLevelByCategory.

Cheers

2 Likes

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[0] hide elements[0] (where elements[n] is a list of elements)
view[1] hide elements[1]
etc…

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.