Quantcast
Channel: Scripting - McNeel Forum
Viewing all articles
Browse latest Browse all 5938

Scripting SubSurface selection and using Alias?

$
0
0

I have a small Python script that selects the highest SubSurface of a Polysurface.
When I run it from Script Editor it works as expected, my SubSurface is selected.

But I assigned an alias for this script using -RunPythonScript() and I notice that my selection gets deselected in this case, when the script ends.

How to keep a sub-object selection done by a script, when that script is run with an alias?

Here’s the script for testing:

import rhinoscriptsyntax as rs
import scriptcontext as sc
import Rhino

obj_id = rs.GetObject("Pick polysurface", rs.filter.polysurface)
brep = rs.coercebrep(obj_id)

max_i = max(range(brep.Faces.Count),key=lambda i: Rhino.Geometry.AreaMassProperties.Compute(brep.Faces[i]).Centroid.Z)

rs.UnselectAllObjects()

rhobj = sc.doc.Objects.FindId(obj_id)
ci = Rhino.Geometry.ComponentIndex(Rhino.Geometry.ComponentIndexType.BrepFace, max_i)
rhobj.SelectSubObject(ci, True, True) #Sub-surface selection
sc.doc.Views.Redraw()

2 posts - 1 participant

Read full topic


Viewing all articles
Browse latest Browse all 5938

Trending Articles