You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
"code": "\nimport math\n\ntry:\n from ladybug_geometry.geometry2d import Vector2D\n from ladybug_geometry.geometry3d import Vector3D\nexcept ImportError as e:\n raise ImportError('\\nFailed to import ladybug_geometry:\\n\\t{}'.format(e))\n\ntry:\n from ladybug_{{cad}}.togeometry import to_face3d, to_vector2d, to_point3d\n from ladybug_{{cad}}.fromgeometry import from_face3d\n from ladybug_{{cad}}.{{plugin}} import all_required_inputs\nexcept ImportError as e:\n raise ImportError('\\nFailed to import ladybug_{{cad}}:\\n\\t{}'.format(e))\n\nORIENT_MAP = {\n 'N': 0,\n 'NE': 45,\n 'E': 90,\n 'SE': 135,\n 'S': 180,\n 'SW': 225,\n 'W': 270,\n 'NW': 315,\n 'NORTH': 0,\n 'NORTHEAST': 45,\n 'EAST': 90,\n 'SOUTHEAST': 135,\n 'SOUTH': 180,\n 'SOUTHWEST': 225,\n 'WEST': 270,\n 'NORTHWEST': 315,\n 'UP': 'UP',\n 'DOWN': 'DOWN',\n 'UPWARDS': 'UP',\n 'DOWNWARDS': 'DOWN'\n}\n\n\nif all_required_inputs(ghenv.Component):\n # process all of the global inputs\n if north_ is not None: # process the north_\n try:\n north_ = to_vector2d(north_).angle_clockwise(Vector2D(0, 1))\n except AttributeError: # north angle instead of vector\n north_ = math.radians(float(north_))\n else:\n north_ = 0\n up_angle = math.radians(_up_angle_) if _up_angle_ is not None else math.radians(30)\n down_angle = math.radians(_down_angle_) if _down_angle_ is not None else math.radians(30)\n horiz_angle = math.radians(_horiz_angle_) if _horiz_angle_ is not None else math.radians(23)\n up_vec, down_vec = Vector3D(0, 0, 1), Vector3D(0, 0, -1)\n\n # process the geometry and the orientation\n try:\n all_geo = [f for geo in _geometry for f in to_face3d(geo, non_planar_quads=True)]\n except TypeError: # older version of the core libraries\n all_geo = [f for geo in _geometry for f in to_face3d(geo)]\n try:\n orient = ORIENT_MAP[_orientation.upper()]\n except KeyError:\n try:\n orient = float(_orientation)\n except Exception:\n msg = 'Orientation must be text (eg. N, E, S W) or a number for the\\n' \\\n 'azimuth of the geometry. Got {}.'.format(_orientation)\n raise TypeError(msg)\n\n # filter the geometry by the orientation\n if orient == 'UP':\n sel_geo = [f for f in all_geo if f.normal.angle(up_vec) < up_angle]\n elif orient == 'DOWN':\n sel_geo = [f for f in all_geo if f.normal.angle(down_vec) < down_angle]\n else:\n sel_geo = []\n dir_vec = Vector2D(0, 1).rotate(north_).rotate(-math.radians(orient))\n full_down_ang = math.pi - down_angle\n for f in all_geo:\n if up_angle <= f.normal.angle(up_vec) <= full_down_ang:\n norm_2d = Vector2D(f.normal.x, f.normal.y)\n if -horiz_angle <= norm_2d.angle(dir_vec) <= horiz_angle:\n sel_geo.append(f)\n\n # translate the Face3D back to {{Cad}} geometry\n sel_geo = [from_face3d(f) for f in sel_geo]\n",
3
+
"subcategory": "4 :: Extra",
4
+
"version": "1.8.2",
4
5
"outputs": [
5
6
[
6
7
{
7
8
"access": "None",
8
-
"name": "sel_geo",
9
9
"description": "Selected faces of the input geometry that are facing the direction\ncorresponding to the input criteria.",
10
+
"default": null,
10
11
"type": null,
11
-
"default": null
12
+
"name": "sel_geo"
12
13
}
13
14
]
14
15
],
16
+
"name": "LB Filter by Normal",
17
+
"nickname": "FilterNormal",
18
+
"description": "Filter or select faces of geometry based on their orientation.",
15
19
"inputs": [
16
20
{
17
21
"access": "item",
18
-
"name": "north_",
19
22
"description": "A number between -360 and 360 for the counterclockwise difference between\nthe North and the positive Y-axis in degrees. 90 is West and 270\nis East. This can also be Vector for the direction to North. (Default: 0)",
23
+
"default": null,
20
24
"type": "System.Object",
21
-
"default": null
25
+
"name": "north_"
22
26
},
23
27
{
24
28
"access": "list",
25
-
"name": "_geometry",
26
29
"description": "Rhino Breps and/or Rhino Meshes which will be broken down into individual\nplanar faces and filtered based on the direction they face.",
30
+
"default": null,
27
31
"type": "GeometryBase",
28
-
"default": null
32
+
"name": "_geometry"
29
33
},
30
34
{
31
35
"access": "item",
32
-
"name": "_orientation",
33
36
"description": "Text for the direction that the geometry is facing. This can also be\na number between 0 and 360 for the azimuth (clockwise horizontal\ndegrees from North) that the geometry should face. Choose from\nthe following:\n_\n* N = North\n* NE = Northeast\n* E = East\n* SE = Southeast\n* S = South\n* SW = Southwest\n* W = West\n* NW = Northwest\n* Up = Upwards\n* Down = Downwards",
37
+
"default": null,
34
38
"type": "string",
35
-
"default": null
39
+
"name": "_orientation"
36
40
},
37
41
{
38
42
"access": "item",
39
-
"name": "_up_angle_",
40
43
"description": "A number in degrees for the maximum declination angle from the positive\nZ Axis that is considerd up. This should be between 0 and 90 for\nthe results to be practical. (Default: 30).",
44
+
"default": null,
41
45
"type": "double",
42
-
"default": null
46
+
"name": "_up_angle_"
43
47
},
44
48
{
45
49
"access": "item",
46
-
"name": "_down_angle_",
47
50
"description": "A number in degrees for the maximum angle difference from the newative\nZ Axis that is considerd down. This should be between 0 and 90 for\nthe results to be practical. (Default: 30).",
51
+
"default": null,
48
52
"type": "double",
49
-
"default": null
53
+
"name": "_down_angle_"
50
54
},
51
55
{
52
56
"access": "item",
53
-
"name": "_horiz_angle_",
54
57
"description": "Angle in degrees for the horizontal deviation from _orientation\nthat is still considered to face that orientation. This should be\nbetween 0 and 90 for the results to be practical. Note that this input\nhas no effect when the input orientation is \"Up\" or \"Down\". (Default: 23).",
58
+
"default": null,
55
59
"type": "double",
56
-
"default": null
60
+
"name": "_horiz_angle_"
57
61
}
58
62
],
59
-
"subcategory": "4 :: Extra",
60
-
"code": "\nimport math\n\ntry:\n from ladybug_geometry.geometry2d import Vector2D\n from ladybug_geometry.geometry3d import Vector3D\nexcept ImportError as e:\n raise ImportError('\\nFailed to import ladybug_geometry:\\n\\t{}'.format(e))\n\ntry:\n from ladybug_{{cad}}.togeometry import to_face3d, to_vector2d\n from ladybug_{{cad}}.fromgeometry import from_face3d\n from ladybug_{{cad}}.{{plugin}} import all_required_inputs\nexcept ImportError as e:\n raise ImportError('\\nFailed to import ladybug_{{cad}}:\\n\\t{}'.format(e))\n\nORIENT_MAP = {\n 'N': 0,\n 'NE': 45,\n 'E': 90,\n 'SE': 135,\n 'S': 180,\n 'SW': 225,\n 'W': 270,\n 'NW': 315,\n 'NORTH': 0,\n 'NORTHEAST': 45,\n 'EAST': 90,\n 'SOUTHEAST': 135,\n 'SOUTH': 180,\n 'SOUTHWEST': 225,\n 'WEST': 270,\n 'NORTHWEST': 315,\n 'UP': 'UP',\n 'DOWN': 'DOWN',\n 'UPWARDS': 'UP',\n 'DOWNWARDS': 'DOWN'\n}\n\n\nif all_required_inputs(ghenv.Component):\n # process all of the global inputs\n if north_ is not None: # process the north_\n try:\n north_ = to_vector2d(north_).angle_clockwise(Vector2D(0, 1))\n except AttributeError: # north angle instead of vector\n north_ = math.radians(float(north_))\n else:\n north_ = 0\n up_angle = math.radians(_up_angle_) if _up_angle_ is not None else math.radians(30)\n down_angle = math.radians(_down_angle_) if _down_angle_ is not None else math.radians(30)\n horiz_angle = math.radians(_horiz_angle_) if _horiz_angle_ is not None else math.radians(23)\n up_vec, down_vec = Vector3D(0, 0, 1), Vector3D(0, 0, -1)\n\n # process the geometry and the orientation\n all_geo = [f for geo in _geometry for f in to_face3d(geo)]\n try:\n orient = ORIENT_MAP[_orientation.upper()]\n except KeyError:\n try:\n orient = float(_orientation)\n except Exception:\n msg = 'Orientation must be text (eg. N, E, S W) or a number for the\\n' \\\n 'azimuth of the geometry. Got {}.'.format(_orientation)\n raise TypeError(msg)\n\n # filter the geometry by the orientation\n if orient == 'UP':\n sel_geo = [f for f in all_geo if f.normal.angle(up_vec) < up_angle]\n elif orient == 'DOWN':\n sel_geo = [f for f in all_geo if f.normal.angle(down_vec) < down_angle]\n else:\n sel_geo = []\n dir_vec = Vector2D(0, 1).rotate(north_).rotate(-math.radians(orient))\n full_down_ang = math.pi - down_angle\n for f in all_geo:\n if up_angle <= f.normal.angle(up_vec) <= full_down_ang:\n norm_2d = Vector2D(f.normal.x, f.normal.y)\n if -horiz_angle <= norm_2d.angle(dir_vec) <= horiz_angle:\n sel_geo.append(f)\n\n # translate the Face3D back to {{Cad}} geometry\n sel_geo = [from_face3d(f) for f in sel_geo]\n",
61
-
"category": "Ladybug",
62
-
"name": "LB Filter by Normal",
63
-
"description": "Filter or select faces of geometry based on their orientation."
0 commit comments