Dynamo script works with PickObject but fails with multiple curtain panel selection


Hello everyone,

I’m having an issue with a Dynamo script and would greatly appreciate any help.

I’m working in Revit 2024 with curtain walls whose panels are parametric families (Curtain Panel Families).

Objective

I need to automatically place a face-based Generic Model family on each curtain wall panel.
The placement should depend on:

  • the exterior face of the panel

  • and its position (top and right side)

Problem

I have developed a script that works correctly when I use PickObject, meaning I manually select a panel and a face.

However, when I try to:

  • select multiple panels at once

  • or collect all curtain wall panels automatically (by category or type)

:backhand_index_pointing_right: the script stops working.

What I’ve tried

  • Manual selection (works, but not feasible due to the number of elements)

  • Multiple selection / All Elements of Category (does not work)

Thanks in advance for your help! :folded_hands:

Homemm MANOZO.dyn (33.6 KB)
Good reference:

Not good script

@sovitek , maybe you can help me? :slight_smile: Please!

Your graph image exports are illegible - zoom in so that node names are visible and then run the export tool - it’ll catch all nodes at the zoomed in resolution even those which are offscreen.

That said if you need to ‘automatically place a face-based Generic Model family on each curtain wall panel’ then you shouldn’t be ‘picking’ anything. Assuming all your panels are planar, this method should work well:

  1. Get all the curtain panels using your method of choice.
  2. Get the boundary curves of each panel using the CurtainPanel.Boundaries node.
  3. Get the normal of the boundary loop using the Curve.Normal node.
  4. Get the faces from the panels using the Element.Faces node.
  5. Extract the normal of the faces using the Surface.NormalAtParameter node.
  6. Get the angle from each curve normal to the associated surface normal using a Vector.AngleWithVector node.
  7. Sort the surfaces in each sublist (step 4) by the angles (step 6) using a List.SortByKey node. Watch your list levels (should both be @L2<1>).
  8. Depending on how your curtain panel is built, get the largest angle from the normal using List.LastItem or first item using List.FirstItem (One will be the inside face and one the outside face). Watch your lacing and list levels (likely @L2<1> is the fix)
  9. Get the BoundingBox by minimum volume for each surface - again watch your list levels (@L1<1> is likley correct here).
  10. Draw a line from the min point of each bounding box to the max point of each bounding box (or vice versa - depending on how your linear family is set up).
  11. Create the family instances using the family type (select it in the drop down node Family Types), the faces (from step 8), and the lines (from step 10).

Hi @huret-molano yeah sure if i can…maybe something if i understand

DYNAMO.dyn (31.0 KB)

Hello, thank you very much for your help :grinning_face: .
I followed the steps you indicated up to step 8, and everything was going perfectly. However,:smiling_face_with_tear:

suddenly all the nodes started showing errors, whereas before there were no errors when I ran the script.

Do you know why this error is happening?

Thank you very much for your help!

One of your elements isn’t returning a valid surface for a face. Could even be many faces or many elements. Try setting the list level to @L1 and see if that narrows down which element is failing.

Thank you very much for your reply and for your help. @jacob.small , @sovitek

I’m not sure what’s currently happening with Dynamo, but I’m getting errors that don’t seem normal. I’ve already tried switching projects and restarting my computer, but the error still persists.

I’ve also tried changing the list levels and selecting only a single element, but it still doesn’t work.:face_with_bags_under_eyes: :anxious_face_with_sweat:

try select the wall itself and get the panels from there

Home.dyn (24.6 KB)

I have this messages. :distorted_face:

ok are you sure these 3 walls you select is curtain wall or is some of them "normal wall

yoy are welcome to share a sample rvt and we can take a look


Yes is a Curtain Wall!
the model is in this URL: Unique Download Link | WeTransfer

your blue curtain panel isnt curtain panel categori , but security devices


The curtain wall is composed of curtain panels. In turn, these panels are made up of curtain wall families.

Curtain panel families contain nested families from different categories, such as: generic models, structure, and safety devices.

In this project image, I turned off the visibility of view of the safety devices and kept only the curtain wall panel without the nested families.

Is geometry scaling set to medium?

The curtain wall panel family is composed of:

allright not really sure what goin on here, but you could try clean it up…thes 7 security devices or whatever have 3180 surfaces, not sure if it could work for you, if not i can try go deeper tomorrow, not at dyn more today…now there are Champions League, in telly :wink:

No, the geometry was not set to Medium, it was set to Large.
I changed it to Medium… the script works a bit better after changing the setting, but it still doesn’t work properly. I’ve also tried changing the list levels, but I still can’t find the problem.

Do you have any idea what could be causing this?

Ok, don’t worry, take your time :slightly_smiling_face: Thank you very much for your help.
Profitez bien!

So, that setting should always remain on medium. The issues partially going away is a good sign though. Try to identify which panel has the self intersecting face in medium (it would have a ‘null’ in the list of surfaces), take that out of the list or use SelectModelElement to work with just the one instance, and adjust geometry scaling a few more times to see if there is a scale at which it works. Also check if there is something off with the instance in Revit - a face with no geometry as the cutting object is flush with the face, or a geometry with no volume, or other issues.

Hello,
Your problematic panel is the one with ID 255449.

Why?

I don’t know.

Here’s a way to retrieve the face geometry:

The code to retrieve the geometry is by Mr. Poupin.

You’ll need to adapt it if you’re sending a list or a list of lists.

Have a good day.
Sincerely,
Christian Stan

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

clr.AddReference('RevitNodes')
import Revit
clr.ImportExtensions(Revit.GeometryConversion)

cp=UnwrapElement(IN[0])

def getSolidfromGeo(elem):
	opt = Options()
	opt.ComputeReferences = True
	opt.IncludeNonVisibleObjects = True
	geoSet = elem.get_Geometry(opt)
	#
	for geo in geoSet:
		if isinstance(geo,Solid) and geo.Volume > 0 :	
			return geo, "Geometry"
	for geo in geoSet:
		if isinstance(geo, GeometryInstance):	
			outSolid = []
			geoSetInst = geo.GetInstanceGeometry()
			for geoI in geoSetInst:
				if isinstance(geoI,Solid) and geoI.Volume > 0:
					outSolid.append(geoI)
			# Order the list by ascending volume
			outSolid.sort(key = lambda x : x.Volume )
			print(len(outSolid))
			#Retrieve the Revit faces of the largest [-1] of the volumes
			lfr=outSolid[-1].Faces
			#Transform the Revit faces To Faces Dynamo
			lfd=[f.ToProtoType()[0] for f in lfr]
			return lfr,lfd, "GeometryInstance",geoSetInst
	return None, None


OUT = getSolidfromGeo(cp)