How to filter horizontal and vertical elements

i tried facing orientation but the values chang if the element is rotated

Get the z component of the facing orientation, abs its value, hen set a threshold for what you count as vertical, e.g. if its 0.5 or more vertical, if its less than 0.5 horizontal.

ty for reply

i tried that but the issue is if that element is rotated, the Z changes in favour of X as seen below

Ignore the X and Y components of the vector and, look at just the Z component. Vector.Z is the need you’re missing.


ty
but as seen in pic, both instances are vertical but their z values are 1 and 0.45 (as it is rotated)

  1. Element.Geometry
  2. If it shows solids, expload it to recieve surfaces.
  3. Get the surface area, filter the surface with biggest area per each element
  4. Get the normal of biggest surface
  5. Vector. AngleWithVector, use Normal vector and Vector.ZAxis
  6. Sort or group elements by key

Probably it could be done even simplier, but for now it should work.

ye i like that
this would work on 99% of cases but would probably take too much time with 2000+ elements

Another option.

  1. Add model line in family, which will be simulating element normal.
  2. In dynamo collect such a line per each family instance and get it’s direction.
  3. Do the same Vector.AngleWithVector

The absolute value of the two Z values exceeds 0.4 so they would both be vertical.

Alternatively you can take the length of only the X and Y components (Math.SquareRoot(v.X * v.X + v.Y*v.Y)) and compare that to the length of the vertical component (if the vertical exceeds the horizontal it is vertically oriented), but 99/100 times exceeding 0.4 is sufficient.

ty boss
one last question
is there a way to tell if its not vertical or horizontal ? i mean with a slope

If Math.Abs(v.Z)%1 >0 then it is on some angle.