Z orient problem - Is this a bug in Rhino?

Bump - I still have not succeeded in keeping this upright.

The attached file and script build a group of objects then orients them by 2 points. It works perfectly except when the 2 target points are in the exact reverse axis of the creation points. In that condition the object is inverted below the target points. A 1 degree rotation of the axis allows correct placement.

I have been playing around with cPlane and vectors but not succeeded in controlling this failure. I am very happy to maintain World axis. Final z placement height will vary.

Any ideas?
tia
Robb

Glob-Group-Orient-problem.py (2.3 KB) Glob_Z-Problem.3dm (1.6 MB)

No, this is not a bug. If you run the Orient command, you will get the same results.

If you want more consistent results, the specify 3 orientation points instead of two. If you don’t want to pick 3 points, then you can cook up the 3rd (y-axis) point like this:

tp1 = rs.GetPoint ("Locate Glob")
tp2 = rs.GetPoint("Orient Glob")
xaxis = rs.VectorUnitize(rs.VectorCreate(tp2, tp1))
zaxis = rs.ViewCPlane().ZAxis
yaxis = rs.VectorUnitize(rs.VectorCrossProduct(zaxis, xaxis))
tp3 = rs.PointAdd(tp1, yaxis)
target=[tp1, tp2, tp3]

Thanks Dale…
I see the same result with the orient command as you suggested. This surprised me as it seems an unexpected behavior that the command would invert when just that particular condition was met. In all other scenarios the object maintains the axis oriented according to the pick points.

I banged on your code suggestion and produced the same problematic result. I attempted to modify for the Zaxis to control rotation and still no joy… probably because I don’t understand the nuance of your suggestion. The following seemed like it should work for controlling the Zaxis

tp1 = rs.GetPoint ("Locate Glob")
tp2 = rs.GetPoint("Orient Glob")
xaxis = rs.VectorUnitize(rs.VectorCreate(tp2, tp1))
yaxis = rs.ViewCPlane().YAxis
zaxis = rs.VectorUnitize(rs.VectorCrossProduct(yaxis, xaxis))
tp3 = rs.PointAdd(tp1, zaxis)
target=[tp1, tp2, tp3]

Is there some simple rs.??? that would lock the Zaxis to the world system?

thanks again,
Robb

You can do this:

zaxis = [0, 0, 1]

That worked perfectly once I remembered to add tp3 into my real working script. I have been really well supported in my baby steps up the Python learning curve. I have little programming experience and find that this really is like learning a new language. I can read the dictionary for the word “eat” = masticating input with the mouth… but I don’t necessarily connect that to ending my hunger pangs.

Thanks a bunch…
Robb