Hide in view

Hi,

I’m looking for a node that can hide elements in a selected view.

So, create a list of elements (query) and hide them in view.

Probably a silly question.

Any tips?

Marcel

 

Marcel, try this, I set it for the active view but you could pipe in a list pretty easily.

import clr
clr.AddReference(‘ProtoGeometry’)
from Autodesk.DesignScript.Geometry import *

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 *

doc = DocumentManager.Instance.CurrentDBDocument
uiapp = DocumentManager.Instance.CurrentUIApplication
app = uiapp.Application

from System.Collections.Generic import *

doc = DocumentManager.Instance.CurrentDBDocument
ActiveView = doc.ActiveView

elements = []
for i in IN[0]:
elements.append(UnwrapElement(i))

idsToHide = ListAutodesk.Revit.DB.ElementId
for i in elements:
idsToHide.Add(i.Id)
TransactionManager.Instance.EnsureInTransaction(doc)
ActiveView.HideElements(idsToHide)
TransactionManager.Instance.TransactionTaskDone()
OUT = idsToHide

Hi,

I am a little lost here but i think i have to change the line that says “ActiveView=doc.ActiveView” into something else.

I havent done any pythoncode yet, i just copied some pieces from other people here in the forum.

Can somebody elaborate on what is needed here?

 

Marcel

Marcel,

Based on the example above I made two nodes for you. One to hide elements in a current view and one to unhide them. Here’s how to hide:

Capture

 

 

Here’s how to hide them:

Capture1

 

Now, the only difference is that I added a check for whether elements are already hidden in the view so that Revit doesn’t throw an error.

Those nodes should have two inputs and second one is a boolean:

Hello Konrad,

Yhank you so very much!

However, what i was looking for was to alter the behavior of the node to process a list of views.

I should have been more clear.

The end result would be to hide certain sections in views that do not comply to a rule.

I have tried but a filter can not do what i want it to do.

 

Marcel

 

Well that shouldn’t be too hard:

 

 

Thank you Konrad !

I retyping everything in a Pythonnode.

Hope i dont make any typo’s

Can you post the code in something i can download?

Marcel

Marcel,

Normally I don’t share code as images, but this forum is an abomination to all technology forums and as long as there isn’t a decent syntax highlighting implemented I refuse to use it.

Ps. I also believe that you will benefit from re-typing it. Who knows, maybe you will learn a thing or two about Python and won’t have to rely on others to provide ready samples next time.

Good luck!

Konrad/Danny Thanks for this! Its helped me understand a bit more of Python writing it out like this :slight_smile: As tedious as it was :stuck_out_tongue: Im trying to do something similar but cant seem to get it to play nice! I have a Plan view with an Elevation marker in the middle of a room, i only want this elevation marker visible in this one view. I dont want to turn off the visibility off in the VG as i need to see other elevation markers in other views, and i cant get the elevation circle to disappear using filters (i can get the wee black triangles to work via filters, just not the circle) So i was using this to select the elevation marker > Get a list of all plans, filter out the plan i want to keep it in > then feed this into your above solution but it does not seem to do anything. See attached definition. Any help would be greatly appreciated Hide in View <-----

 

EDIT:: Managed to get the outout i needed using filters, i was being stupid haha. But i would still like to know how i would do this using Dynamo. Thanks :slight_smile:

1 Like

Hi,

Im wondering if this is an issue concerning revit 2015 R2.

Im using Revit 2015 UR8, and nothing is happening using this Python script.

I tried and tried again.

What could be wrong here?

Marcel

 

Hi Konrad.

I’m getting the following error message in both Pyton scripts when i set boolean to true:

“Advertencia: IronPythonEvaluator.Error en la operación EvaluateIronPythonScript.
Traceback (most recent call last):
File “<string>”, line 67, in <module>
ImportError: No module named traceback”

I’ve checked several times the code looking for any typing mistake but it’s ok.

Maybe because Dynamo’s instalation is in spanish language?

I’m using other projects and they work fine.

Hi Manuel,

here is a node for this now, saw it in the latest Archi-lab package.

Thanks to Konrad.

Marcel

Thank you very much. It now works properly.

@Konrad_K_Sobon
I’ve been trying to eddit the node so that the output contains the elements that were hidden in the FloorPlans for review purposes. Since I’m posting, it is without success.

Goal is to check multiple floorplans for hidden elements. Can this node be used for this goal and if so, what is the part thats need to be eddited?

Hope to hear from u