Possible regression with Contour command in Rhino 8

Howdy!

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:

['Group47']
['Group48']
['Group49']
['Group50']
['Group51']
['Group52']
['Group53']
['Group54']
['Group55']
['Group56']
['Group57']
['Group58']
['Group59']
['Group60']
['Group61']
['Group62']
['Group63']
['Group64']
['Group65']
['Group66']
['Group66']
['Group67']
['Group67']
['Group68']
['Group68']
['Group69']
['Group69']

and the screenshot

For v8:

[]
[]
[]
[]
[]
[]
[]
[]
[]
[]
[]
[]
['Group33']
['Group33']
[]
[]
[]
[]
[]
[]
['Group36']
['Group36']
['Group35']
['Group35']
['Group34']
['Group34']
[]

and the screenshot:

-Jason

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))

-Pascal

Pascal,

Thanks for the thought - and I had the same idea.

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):

As you can see, it runs the color in order.

However, in v8 with manually creating the groups:

It’s just a dumb artsy type utility I cooked up, but it’d be nice to keep around :slight_smile:

For reference, I’ll attached the v8 script.
neoncontour.py (3.9 KB)

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.

See if this works at all-
neoncontour_Maybe.py (4.9 KB)

-Pascal

Yeah, that’s the kicker lol - dependent on a particular direction of the path perpendicular to the plane.

This would be a bit more difficult :slight_smile:

A cheap way out is to put an extra step for direction and feed the resulting points to Contour.

neoncontour_Maybe.py (5.2 KB)

@jgillmanjr - this does the right thing I think now. I left a bit out, last evening.

-Pascal

2 Likes

@pascal out of curiosity, did you find out if this actually was a regression, or if it was an intentional change?