Rs.ObjectsByType - incorrect for clipping planes

Non-visible clipping planes are not being reported correctly. The test file attached has 5 clipping planes, named CP1 to 5. One is selectable, the others are either locked, hidden, or on locked or off layers.

State=0 is clearly wrong:
It should report all 5, but it only does 3 - the hidden plane and the one on the off layer aren’t counted.

Should State=2 find objects on locked layers (not just locked by object)?
Should State=4 find objects on off layers (not just hidden by object)?

The vb rhinoscript equivalent seems to work correctly in this regard.

Test script (use with test file):

import rhinoscriptsyntax as rs
"""
state
Optional.  Number.  The object state (normal, locked, and hidden).
Object states can be added together
to filter several different states of geometry.

Value Description
0     All objects
1     Normal Objects
2     Locked Objects
4     Hidden Objects
"""

states=[0,1,2,4]
for s in states:
    names=""
    objs=rs.ObjectsByType(536870912,state=s)
    for obj in objs: names+=rs.ObjectName(obj)+" "
    print "State {}: found {} clipping planes: {}".format(s,len(objs),names)

Results:
State 0: found 3 clipping planes: CP5 CP3 CP2
State 1: found 1 clipping planes: CP5
State 2: found 1 clipping planes: CP2
State 4: found 1 clipping planes: CP4

Thanks, --Mitch

ClipPlaneScriptTest.3dm (76.3 KB)

@Alain can you look into this?

Hi @dale and @Helvetosaur,

This is mostly fixed.

Please see my notes and let me know if I missed anything.

Hmmm…

Hmmmmm … it is marked public.

Yeah, I have been having different types of permissions issues with youtrack - I reported it here under Meta, but nobody seems to think that was appropriate…

Searching for issue rh-29291 also yields nothing…

–Mitch

Strange. Do you know if others are having similar problems?

Here are the notes from the link:

Fixed bug but there still remains an issue (last paragraph).

The way it works in RhinoScript is that the state (0, 1, 2, 4) passed to the ObjectsByType function is the state of the object regardless of the state of the layer it’s on, i.e., an object that is locked or hidden only because it is on a locked or hidden layer is not considered locked or hidden by this function.

Python’s RhinoScriptSyntax has been changed to duplicate RhinoScript except in one case:
if “state=1” (normal objects) is passed to rs.ObjectsByType objects locked or hidden by a layer are not returned (even though “state=2 or state=4” (locked or hidden) doesn’t return the objects either). Fixing this requires making changes in the core native code and is more involved.

I don’t know, I reported similar problems inside youtrack here a couple of weeks ago (someone changed the category to Windows Rhino, it was originally in Meta…). Who else outside McNeel is active using/tracking the system?

–Mitch

I wouldn’t say active but I go there once in a while. This particular issue is also locked for me.

It was Dale that changed the category to windows. Andy suggests to take it up with the JetBrains people but clicking on the Feedback link at the bottom of a YT issue gets me to a page with no access… :warning:

The vb Rhinoscript is also wrong IMO…

Definition of “NormalObjects()” according to the Help (both vb and python):

Returns the identifiers of all objects that are neither hidden nor locked in 
the document, including reference objects.  Normal objects are visible, can be 
snapped to, and are independent of selection state.

"""Both the object's hidden and locked status, as well as the object layer's 
hidden and locked status, are used to determine whether or not the object is 
returned."""

So, according to that definition, state=1 should NOT get objects that are on locked or off layers. In that case, the Python implementation is correct and the VB Rhinoscript implementation is wrong.

The tricky part is to get the objects on locked or off layers… You need to first get all normal objects of that type, then I guess check each object with IsObjectLocked(), IsObjectHidden() as well as the status of the layer it’s on…

–Mitch

As a rule I try to duplicate what rhinoscript does but like you say it looks like it was also wrong. If @dale agrees I’ll make the changes.

Thanks

The issue was not marked as piublicly viewable. It is now, so you gyys should all be able to see it.

I see … there’s a 2nd setting. I thought “Public View -> Permitted” was enough. Doh!
Thanks

In the past, the ObjectsByType method received some flack because the objects that it returned did not pass the object tests (e.g. IsObjectHidden, IsObjectLocked, IsObjectNormal) that correspond with the state flag parameter. As you all know, it is possible for an object to be normal but its layer to be either locked or hidden.

Here is one such complaint;

http://mcneel.myjetbrains.com/youtrack/issue/RH-21527

Thus, ObjectsByType strictly returns objects by their state, ignoring any layer state. If you want to apply the layer state, then you can use methods such as IsObjectSelectable or use one of the many layer methods.

Not sure this helps…

For the python version I could add a consider_layer_state=False optional argument:

def ObjectsByType(geometry_type, select=False, state=0, consider_layer_state=False):

Would that be useful?

Well, I think this is going in the right direction… For me the primary considerations are:

  • Python rhinoscriptsyntax and vb Rhinoscript syntax are as “parallel” as possible.
  • The definition of “normal” objects needs to be unified. It looks like the vb side has been changed at some point, whereas the python side is different…

vb - IsObjectNormal:

Verifies that an object is normal. Normal objects are objects that are
neither hidden nor locked. Normal objects are visible, can be snapped to, and
can be selected.

It is possible for an object to be normal but reside on a layer that is
either hidden or lock (sic). In such case, the object will report as normal.

vb: NormalObjects

Returns the identifiers of all objects that are neither hidden nor locked in
the document, including reference objects. Normal objects are visible, can be
snapped to, and are independent of selection state.

Both the object’s hidden and locked status, as well as the object layer’s
hidden and locked status, are used to determine whether or not the object is
returned.

python IsObjectNorma()l:

Verifies that an object is normal. Normal objects are visible, can be snapped
to, and can be selected.

python NormalObjects():

Returns the identifiers of all normal objects in the document. Normal objects
are visible, can be snapped to, and are independent of selection state.

  • Any function with state=normal returns the same objects as a check with IsObjectNormal.
  • Helper arguments for finding “normal” objects that are on off or locked layers would then make a lot of sense. They should be added to both python rhinoscriptsyntax and vb rhinoscript.

–Mitch

1 Like

Thanks for the post Mitch. I had a look at the problem more deeply and fixed ObjectsByType (like @dale suggested) and HiddenObjects. I also added LockedObjects which was missing. See my comments for more details. The functions should match RhinoScript and hopefully give you what you need.