I noticed that there seems to be an inconsistency with the direction of the Z axis when attaching the Cplane to an object. It seems to me that the Z axis should always point in the direction of the surface normal. But that’s not what I’m seeing. Take a look (the reddish surfaces are the backfaces, so the surface normals are facing in):
Am I wrong in saying that the Z axis pointing in the opposite direction of the surface normal is wrong?
Hi Dan - I guess what you are seeing here is that the U and V are what is used to align the CPlane directions - if a face has a ‘flipped’ flag, as it will quite often in order to set the normals consistently on adjacent faces, then it will appear ‘wrong’ becuse the face normal is not the natural normal of the underlying surface.
Anything that can be done through scripting to make this more predictable? I’m trying to create a tool that toggles all the surface normals outward (for 5-axis machining), and I thought I succeeded until I ran across this.
Thanks Tom, I will take a look.
Hi Dan - I guess the way is to check each face for a flipped status and if it is flipped, replace the underlying surface with one that has the U and V reversed.
Make a pile of faces this way and Join them into a new brep.
Actually, @DanBayn , Transpose lets you do this in place so it may be pretty simple. Not that I’ve done it…
I’ll take a look at this too. Thanks for the tip.
@DanBayn - this seems to work-
import scriptcontext as sc
import rhinoscriptsyntax as rs
ids = rs.GetObjects(filter = 8, preselect=True)
if not ids: return
for id in ids:
brep = rs.coercebrep(id)
face = brep.Faces
sc.doc.Objects.Replace( id, brep)
Thanks for this example. I notice it’s intended for polysurfaces (as you are filtering for that). After re-reading my original post I see I failed to mention that the object in the video is not a polysurface. Sorry about that. It’s individual surfaces. I’ll attach the file in case you want to take a look.
all normals outbound.3dm (295.6 KB)
The file will open with all surfaces toggled inward.
Yeah, that example is not very useful by itself - it gives back the untrimmed surface - I’ll poke some more.
Hm - looking at your file, the UVs are correct for an outward pointing natural normal on the ones I checked
… so really you want, in this case, to remove the flipped flag and not change the surface UV. Different thing than I was looking at before. @DanBayn - I simplifed the code above - it now makes sure all normals match the surface uv on individual surfaces - I think that is what you are after.
Thanks Pascal. I really appreciate your help.