Plate thickness

Good idea @pascal,

can you show an example I always wondered what these rays are used for?

User interaction is not allowed since there may be hundreds of solids. At least in my cases there are. But you can probably still make this work somehow.

I’ll have a try - probably not using rays though - it looks like there is only an intersection getter for rays with meshes.

-Pascal

Can’t we get the visualizaiton mesh out of the surface/polysurface?
Could that work?

I would guess it might well. but you’d be automatically introducing fuzz into the measurement at that point. Might as well be accurate.

@ivelin.peychev - RayShoot seems to work - quick and dirty test:


import scriptcontext as sc
import System
import Rhino
import rhinoscriptsyntax as rs


def test():
    tol = sc.doc.ModelAbsoluteTolerance
    while True:
        
        go = Rhino.Input.Custom.GetObject()
        go.GeometryFilter = Rhino.DocObjects.ObjectType.Surface
        go.DisablePreSelect()
        go.SubObjectSelect = True
        rc = go.Get()
        
        if go.CommandResult()!=Rhino.Commands.Result.Success:
                return go.CommandResult()
                
        oref = go.Object(0)
        brep = oref.Brep()
        pt = oref.SelectionPoint()
        
        f = oref.Face()

        rc, U, V = f.ClosestPoint(pt)

        n = f.NormalAt(U,V)
       
        if not brep.IsPointInside(pt +(n*tol*10), tol, True):
            n.Reverse()
            print "Flip"
        
        r = Rhino.Geometry.Ray3d(pt,n)
        
        hits = Rhino.Geometry.Intersect.Intersection.RayShoot(r,[brep], 1)
        
        dist = pt.DistanceTo(hits[0])
        
        print "Plate is " + str(round(dist,3)) + " units thick."
       
       
test()

-Pascal

2 Likes

Thanks @pascal

I assume this list contains info about all hits with all objects in the viewport.
If there are hundreds of objects won’t this cause more memory consumtion compared with the other two approaches above?

Are there any cases where using rays is not recommended?

Nope - the input is a ray and a list of breps, in this case just the one. A ray in that direction will only hit the opposite side.

-Pascal

1 Like