A command like SelBackfaces would be really useful - a command that selects only objects facing away from the camera. In a model with a lot of such surfaces/mesh faces Flipping them all in one go might save some time.
In an example below backfaces are colored pink - they are all separate surfaces.
-runscript (
sub SelectByCentralNormal
Dim arrObjects, strObject
objs = Rhino.AllObjects
If IsArray(objs) Then
Rhino.UnselectAllObjects()
For Each obj In objs
' SURFACE CASE
if Rhino.IsSurface(obj) then
surf = obj
UV = Rhino.SurfaceParameter (surf , Array(0.5,0.5))
normal = Rhino.SurfaceNormal (surf , UV)
cameraLocs = Rhino.ViewCameraTarget()
vector = Rhino.VectorCreate(cameraLocs(1),cameraLocs(0))
angle = Rhino.VectorAngle(vector,normal)
if angle<90 then
Rhino.SelectObject(surf)
End If
End If
Next
Rhino.ZoomSelected()
End If
End sub
SelectByCentralNormal
Argh yet another one of Rhinoâs caveats. For instance sel color doesnât work even if you have a layer color assigned on an object, this only works if you have a material assigned first.
Thank you very much @maje90, I have just tried running the script, but I canât quite get it to work - it doesnât seem to select the backfaces for me (pink). Iâve tried running it both by copy pasting your code into the console and saving it as .rvb and running it via RunScript command - same results.
@3dsynergy hmm I havenât experienced this one yet, for example here are two cubes on two layers that take colors âByLayerâ with both layers turned to red. SelColor seems to pick both up?
It seems you need to swap the test, from >90 to <90, i made a mistake. I edited the code.
In your file there are only 2 surfaces, if you do that edit it will work.
Polysurfaces and other types are not handled.
Coding in the old rhinoscript is hard , I canât wait to work with RhinocodeâŚ
I think you need to use _-Loadscript and not _-Runscript. Plus you need to add a âCallâ statement at the top to launch the script once it has loaded.
Call SelectByCentralNormal()
Sub SelectByCentralNormal()
Iâm relatively late to the party here, I was traveling yesterday. While these are not selection scripts, they might be useful to automatically flip backfaces (i.e. no need to select and then run Flip)