View element selected in dynamo

hey i want to know this stupid thing, when i select an element in dynamo and i click the green element id, it zooms in the element, but doesn’t highlight or mark the element which is selected.
is there a node which highlights or marks the element/bounding box/ coordinates in the model?!

image

Hi @uaftab.cem19 maybe try to get the element using “select by ID” command in revit with the green number or isolate element in view dynano node from clockwork. Cheers

1 Like

I think @Mostafa_El_Ayoubi did this. Did you mean colouring elements? Been awhile but you could figure it out with custom node probably

import clr
clr.AddReference('RevitAPI')
import Autodesk
from Autodesk.Revit.DB import *
clr.AddReference('RevitServices')
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

from System.Collections.Generic import *


doc = DocumentManager.Instance.CurrentDBDocument

def overridecolor(element, color, fillpatternid, view):
	gSettings = OverrideGraphicSettings()
	gSettings.SetProjectionFillColor(color)
	gSettings.SetProjectionFillPatternId(fillpatternid)
	gSettings.SetCutFillColor(color)
	gSettings.SetCutFillPatternId(fillpatternid)
	view.SetElementOverrides(element.Id, gSettings)
	return element

fillpatterns = FilteredElementCollector(doc).OfClass(FillPatternElement).ToElements()
solidfillid = [f.Id for f in fillpatterns if f.Name == '<Solid fill>'][0]

for j in IN[1]:
	for i in IN[2]:
		
		if isinstance(IN[0],list):
			color = UnwrapElement(IN[0])
		else:
			color = [UnwrapElement(IN[0])]
		
		adskcolor = [Autodesk.Revit.DB.Color(c.Red, c.Green, c.Blue) for c in color]
		view = UnwrapElement(j)
		elements = UnwrapElement(i)
		
		TransactionManager.Instance.EnsureInTransaction(doc)
		
		for e,c in zip(elements,adskcolor):
			overridecolor(e,c,solidfillid,view)
		
		TransactionManager.Instance.TransactionTaskDone()

OUT = elements
1 Like

Hi,

Use the SelectInRevit node from spring nodes package to highlight the elements.

2 Likes

Use this python code

import clr

clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
from System.Collections.Generic import List

clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *

def tolist(obj1):
	if hasattr(obj1,'__iter__'): return obj1
	else: return [obj1]

def flatten(x):
    result = []
    for el in x:
        if hasattr(el, "__iter__") and not isinstance(el, basestring):
            result.extend(flatten(el))
        else:
            result.append(el)
    return result

elements = UnwrapElement(flatten(tolist(IN[0])))

selected = []
Icollection = List[ElementId]()
for e in elements:
	try:
		Icollection.Add(e.Id)
		selected.append(e)
	except:
		pass
DocumentManager.Instance.CurrentUIApplication.ActiveUIDocument.Selection.SetElementIds(Icollection)

OUT = selected

In your case, just plug it in the Select Model Elements or Select Model Element node and it will select and highlight your desired elements in Revit when you hit run… If you’d need to override elements, to give them a color, a slight modification needs to be done in the script, if you need that, just let me know.

5 Likes

Is there a work around to use this for linked elements?

@saju_autodesk …dont think its possible to override linked element as far i know, its only possible to hide them…but you could create a filter i think :wink:

try using “select element by id” node

thanks!