I think I may have discovered a regression from Rhino 7 to Rhino 8 in regard to the Contour command when setting GroupObjectsByContourPlane to yes.
In version 7, even single objects in a plane are added to a group (which I rely on for one of my scripts), however this doesn’t appear to be the case in version 8.
To demonstrate, here’s a simple python script to build a contour with the GroupObjectsByContourPlane option set to yes, and then output the groups for each of the objects generated.
import rhinoscriptsyntax as rs
import scriptcontext as sc
import System
import System.Collections.Generic
import Rhino
current_doc = Rhino.RhinoDoc.ActiveDoc
# Build the actual contour lines
rs.Command('_Contour g=yes')
contour_curves = rs.LastCreatedObjects()
for contour_curve in contour_curves:
print(rs.ObjectGroups(contour_curve))
The output (for the same object I’m contouring) in v7:
Hi Jason, I see that - I can’t say if it is a design decision or not - it would make some sense after all , but I’ll ask.
Here’s a quick fix so, hopefully, you don’t have to care:
for contour_curve in contour_curves:
if len(rs.ObjectGroups(contour_curve)) == 0:
g = rs.AddGroup()
rs.AddObjectToGroup(contour_curve, g)
print(rs.ObjectGroups(contour_curve))
But the rub is that the group names are important, as they’re used for determining order, and the objects in the list don’t come back ordered as can be seen from the output (Group33, then 36, then 35).
To give you an idea, here’s what’ the script does in v7 (it contours and then creates emission pipes from a BREP):
Hi Jason - I see - probably, since you are scripting, the more robust way to do this is not to group at all, and make a function that sorts the curves into lists by Z value (assuming horzontal sections) of the curve bounding box center. Then you can maintain control of things independently of what the top level command puts out.