Skip to content

Commit

Permalink
fix(skymask): Add fixes for Rhino 7
Browse files Browse the repository at this point in the history
  • Loading branch information
chriswmackey committed Jan 21, 2021
1 parent 692846f commit d90db02
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/Ladybug_Shading Mask.py
Expand Up @@ -55,7 +55,7 @@

ghenv.Component.Name = "Ladybug_Shading Mask"
ghenv.Component.NickName = 'shadingMask'
ghenv.Component.Message = 'VER 0.0.69\nJUL_07_2020'
ghenv.Component.Message = 'VER 0.0.69\nJAN_20_2021'
ghenv.Component.IconDisplayMode = ghenv.Component.IconDisplayMode.application
ghenv.Component.Category = "LB-Legacy"
ghenv.Component.SubCategory = "3 | EnvironmentalAnalysis"
Expand Down Expand Up @@ -284,7 +284,8 @@ def intersect(i):
try:
ray = rays[i]
# run the intersection
if rc.Geometry.Intersect.Intersection.MeshRay(joinedContext, ray) >= 0.0:
if joinedContext.IsValid and \
rc.Geometry.Intersect.Intersection.MeshRay(joinedContext, ray) >= 0.0:
masked[i] = -1
unmasked[i] = i
else:
Expand Down Expand Up @@ -325,7 +326,9 @@ def main(viewMethod, testPt, viewPlane, skyDensity, contextMesh, scale, projecti
sphere = rc.Geometry.Sphere(testPt,scale)
meshSphere = rc.Geometry.Mesh.CreateFromSphere(sphere,int(skyDensity),int(skyDensity))
groundPlane = rc.Geometry.Plane(testPt, rc.Geometry.Vector3d.ZAxis)
hemisphere = rc.Geometry.Mesh.Split(meshSphere,groundPlane)[0]
hemisphere = rc.Geometry.Mesh.Split(meshSphere,groundPlane)[-1] \
if str(rc.RhinoApp.Version).startswith('7') else \
rc.Geometry.Mesh.Split(meshSphere,groundPlane)[0]

# Generate the rays and take out those that are not within the viewPlane.
fullRays = Rays(testPt, hemisphere)
Expand Down
Binary file modified userObjects/Ladybug_Shading Mask.ghuser
Binary file not shown.

0 comments on commit d90db02

Please sign in to comment.