.rs.SurfaceFrame is resetting the UV direction of a surface


#1

Hello lovely Python user,

I want to swap the UV directions of a surface according to its dime nsion and get its SurfaceFrame. However the SurfaceFrame does not swap its X and Y axis with the swaped UV directions. As far i cant see any reason for this, especially when the SurfaceFrame says:

Returns a plane based on the normal, u, and v directions at a given surface U,V parameter.

The .py file is attached. swapUV.py (1.1 KB)

Hopefully one of you has an idea why its not working the intended way.
Thank u for you help,

greetz Peter


#2

Maybe this image will help to get the issue. The X-axis of the SurfaceFrame doesnt change with swaped UV directions.


(Dale Fugier) #3

Hi Peter,

My apologies, but I cannot follow (in your code) what you really trying to do. Can you explain further the problem you are trying to solve?

Note, a larger domain in one direction does not necessarily mean the surface is longer in that direction…

– Dale


#4

Hello Dale,

thank you for your reply and sorry for my description. I shouldn’t make posts on a Friday afternoon. The problem i have isn’t very hard to explain, so here is second attempt.

The .py file i posted is a part of a longer script so i will try to break it a little bit down. I want to make a script that can terminate the position of points or rather objects to a reference surface. Therefor i get the surfaceframe of these reference surface. With a simple XformCPlaneToWorld i can transform any located point and see in witch Octant the point is located relative to that reference surface.
In my final script the reference surface will be one side of a cube-like polysurface. If i claim one surface of that cube as the reference surface, the script should allow me to identify the “right” and "left and "front (and so on…) - surface of that cube.

The only thing that has to be controlled is the orientation of the surfaceframe. The rotation around its Z-axis has to be controlled. Now as far as i understood rs.surfaceframe, the X-axis of this frame will be aligned with the U-direction of the surface.
I want to use these information to remap the UV-direction of the surface so that U will be aligned within the long axis of the surface (my objects are quite rectangular shape).

def alignUV(id):
if rs.IsSurface(id):
    domain_u = rs.SurfaceDomain(id, 0)
    domain_v = rs.SurfaceDomain(id, 1)
    if(domain_v[1] + domain_v[0])<(domain_u[1] + domain_u[0]): 
        rs.SelectObject(id)
        rs.Command ("-_Dir selid{0} _swapUV _enter".format(id))
        rs.UnselectObject(id)

I expected that the X-axis of the surfaceframe should be now always aligned to the longer dimension of the reference surface (even if that does not work for any domains like u already mentioned).
But the result work out a little bit different. The X-axis of the surfaceframe will be always aligned to the original U direction of the Surface, like it was created. Swapping the the UV directions in Rhino wont swap the X and Y-direction of the surfaceframe. Maybe u have any idea why its this way and how i can handle it,

greetz Peter