Script which checks the distance between cable trays and air ducts help

Hello everyone!

Could you please p

I’m a new to Dynamo but trying to do my best in understanding Dynamo logic.

I’m trying to create a script which checks the distance between cable trays and air ducts.
If the distance between cable trays and air ducts is less than 40 mm then the script should inform about this.

I have 2 questions:

  1. Why there is a problem with “Point Z” node when I’m trying to connect it to “Element.Get location”? Are there any other ways to get Z coordinates of every cable trays category?
  2. How can I set the value of 40 mm in Python script node to satisfy the condition. In other words how to let know Dynamo that I need 40 mm for “a” variable?

My Python script node:

Load the Python Standard and DesignScript Libraries

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

a = IN[0]

if a < 40:

b = 'false'

else:
b = ‘true’

OUT = b

Thank very much for your help

When you get the location of an object, internally this is either a LocationPoint (typical for family instances) or a LocationCurve (typical for curve-based families like pipes, cable trays, walls, etc.). Because your cable tray has a LocationCurve as its location, it is not a point. Therefore, you cannot use Point.Z with your cable tray.

The exact steps you should take depend on exactly what you consider the location of the cable tray to be. For horizontal cable trays, you can get either the endpoint or the startpoint and from there you can get the Z value. However, I believe the cable tray’s curve is located at the base of the cable tray, so you may be better off getting the bounding box of both the cable tray and the duct since the location will be identical regardless of the size of the tray or duct.

1 Like