Is this a glitch in Dynamo or in my Python?

In Revit I draw a shape using property lines and import it into Dynamo.

Then using Python I draw a line between two random points (making sure this is all within my shape.)

Then I want to find the apexes of my shape that lie between the ends of my random line (if I drew perpendicular lines up and down from the random lines start and end points to intersect with the shape)

It works about 90% of the time… But I can’t work out why on earth sometimes I get an empty list returned.

The image below shows:
Red - the shape before I rotated it all to make the baseline horizontal (this makes the maths way easier)
Blue shape + points = rotated shape + its apexes
Blue line (my rotated random line)
vertical blue lines - every point between these I want my script to find… I’ve circled them in green.


You can see in this instance my list is empty instead of being a list of the green circled points:

Everything seems to work until line 75

FORUM.dyn (64.3 KB)

Dyn attached.

Can anyone shed any light on this please?

Which line in the diagram above represents the baseline? The blue line? Is it possible that the baseline is vertical or close to it? Keep in mind as you rotate the baseline, the distance between the horizontal extents gets smaller since you’re not measuring perpendicular to the rotated line.

The horizontal blue line is the rotated baseline. The shape rotates with the baseline. The rotated baseline is always horizontal.

Seem to have repeated myself there… but don’t think that should make a difference?

Ah, I see. I had it backwards then. Can you show us the outputs for the baseline extents (P1_X and P2_X) as well as the individual X values for the RotatedApexes?

When it messes up… i[8] (x point for rotated point2) reads the same as i[5] (x point for point1)…

No idea why though!

The baseline is random - so the figures change each time I run it.

Screen grab of one that’s not working:


These are the apexes above…
Below is:
[4] this is meant to be the apexes with X values between the line endpoint X values
[5] P1 _X
[6] P1 _Y
[7] Point 1
[8] this is meant to be rotated P2_X
[9] Rotated P2
[10] Original P2


So the issue is that sometimes P2r_X is giving a false reading… but I have no idea why!

Well, I’ve gone and changed a few names and it works.

I must have mistyped something somewhere and been asking for the wrong value. Although WHY it was right most of the time is still confusing. :expressionless:

Seems to be working now.

Yup that’s exactly where I noticed your issue. Previously, you get P2r_X from the original rotated location, but then you reorder P1 and P2r to ensure the P1 is always the leftmost point. You don’t update P2r_X at this point, so you potentially have P1 and P2r_X being the same points.

Now you’re updating it after checking base extents so you always have both values.

1 Like

Yep, as usual the issue is between my chair and keyboard :laughing: