Wish: extract clippingplane clipping info into curves (and hatches)

When working with large files and referenced files it would be great to quickly extract the clipping info from a clippingplane.

I know that a clippingplane works on the rendermesh but that is totally OK in a lot of scenarios.

And if you guys have a good workaround for this then I am happy to hear!

Thanks!

Second this wish

Yes, that would be helpful quite often. +1

+1 too!

I added some functions that give you the fill geometry - is that something you could work with?

Let me dig.

I dug:

https://developer.rhino3d.com/api/RhinoCommon/html/Overload_Rhino_DocObjects_RhinoObject_GetFillSurfaces.htm

What does that mean?
The actual geometry or something else?

I think section tools can be used to get the geometry.

Nathan can you give a simple example using your method?

One object and one clipping plane. I’d love to test this with my clipping box script.

Thanks in advance.

It is quite simple really:

import Rhino
import Rhino.DocObjects as rdob
import scriptcontext as sc

cps = [ob for ob in sc.doc.Objects if ob.ObjectType == rdob.ObjectType.ClipPlane]
selob = [ob for ob in sc.doc.Objects if ob.IsSelected(False)>0]

Rhino.RhinoApp.RunScript("_SelNone", False)

if len(selob)==1 and len(cps)>0:
	srfs = rdob.RhinoObject.GetFillSurfaces(selob[0], cps)
	print(srfs)
	for srf in srfs:
		print(srf)
		id = sc.doc.Objects.AddBrep(srf)
		sob = sc.doc.Objects.FindId(id)
		print(id, sob)
		sob.Select(True, True)
	
	sc.doc.Views.Redraw()

With file demo_getfillsurfaces.3dm (204.4 KB)

Select the torus before running the script. It adds a bunch of breps as the filling faces. Disable to clipping planes and hide the torus to see.

2 Likes

Thanks Nathan,

Is it mandatory that the object you clip is a closed solid?

Because neither your script, nor what I came up with results with success:

import rhinoscriptsyntax as rs
import scriptcontext as sc
import Rhino


def obj():
    rc,obj_ref = Rhino.Input.RhinoGet.GetOneObject("Select object", False, Rhino.DocObjects.ObjectType.AnyObject)
    if rc != Rhino.Commands.Result.Success:
        return rc
    rhino_object = obj_ref.Object()
    print rc, obj_ref
    return rhino_object

def clip():
    rc,obj_ref = Rhino.Input.RhinoGet.GetOneObject("Select object", False, Rhino.DocObjects.ObjectType.ClipPlane)
    if rc != Rhino.Commands.Result.Success:
        return rc
    rhino_clip = obj_ref.Object()
    print rc, obj_ref
    return rhino_clip

if __name__=="__main__":
    print obj()
    print clip()
    section_geometry = Rhino.DocObjects.RhinoObject.GetFillSurfaces(obj(),clip())
    print type(section_geometry)

Ah, I see my mistake didn’t add the objects to the document

import rhinoscriptsyntax as rs
import scriptcontext as sc
import Rhino


def obj():
    rc,obj_ref = Rhino.Input.RhinoGet.GetOneObject("Select object", False, Rhino.DocObjects.ObjectType.AnyObject)
    if rc != Rhino.Commands.Result.Success:
        return rc
    rhino_object = obj_ref.Object()
    print rc, obj_ref
    return rhino_object

def clip():
    rc,obj_ref = Rhino.Input.RhinoGet.GetOneObject("Select object", False, Rhino.DocObjects.ObjectType.ClipPlane)
    if rc != Rhino.Commands.Result.Success:
        return rc
    rhino_clip = obj_ref.Object()
    print rc, obj_ref
    return rhino_clip

if __name__=="__main__":
    print obj()
    print clip()
    section_geometry = Rhino.DocObjects.RhinoObject.GetFillSurfaces(obj(),clip())
    id = sc.doc.Objects.AddBrep(section_geometry)
    print type(id)

Wicked…
That’s an amazing step in the right direction!

So to whom it may concern:
Please add that to the clippingplane option panel (extract clipping Fill data)
((and also make sure the clipping plane is showing what is ON the plane (old wish) :slight_smile: ))

I looked to see if there was a GetFillCurves too, but I could not find it. Is there a function for that as well?
Which is what is also often needed as much geometry isn’t solids. (scan data, unfinished or bad models etc)

1 Like

For that you just get the intersection curves of your data with the clipping plane geometry.

1 Like

Ok, that is something I can calculate.
I just thought it could be possible to extract if it was already done :slight_smile:
Thanks!

The GetFillSurfaces function really just gets the plane from the clipping planes and does some intersection stuff, builds the breps from those, throws away parts no longer needed.

You should be able to use https://developer.rhino3d.com/api/RhinoCommon/html/T_Rhino_Geometry_Intersect_Intersection.htm for your curve finding needs.

FWIW, if you put in the script I posted a _Join followed by a _DupBorder you can get curves for the surfaces. Possibly useful (:

ps. I added the GetFillSurfaces function for usage in Raytraced for clipping plane support. I hope to get back to that at some point.

1 Like

its been awhile since I’ve done this kind of script thing. Can you give me a straightforward way to get this into my rhino? much appreciated. @nathanletwory

The first script I posted should give you the fill surfaces for closed objects.

As the script currently stands it wants you to select the object(s) you want to get those fill surfaces for first before running it.