Create face normal

From Macros Wiki
Jump to navigationJump to search

! find the middle of each selected face and create
! a 3d line that is normal to the face at that point
! --------------------------------------------------

normal_length = 1 ! length of surface normal to create
 
get_selected_solid_list ! get list of selected solids
 
num_solids = number_of_solids
if num_solids<1 then stop "Please select at least 1 face"
 
num_points = 0
 
for i=1 to num_solids
sol_ref = next_solid_ref


get_solid_selected_face_list sol_ref
num_faces = number_of_faces


for j=1 to num_faces
face_ref = next_face_ref
get_solid_face_uv sol_ref, face_ref, u1, v1, u2, v2


uu = (u1 + u2)/2
vv = (v1 + v2)/2


get_solid_face_point sol_ref, face_ref, uu, vv, x1, y1, z1
get_solid_face_normal sol_ref, face_ref, uu, vv, vx, vy, vz


x2 = x1 + (vx * normal_length)
y2 = y1 + (vy * normal_length)
z2 = z1 + (vz * normal_length)


contour_3d [
start x1, y1, z1
line x2, y2, z2
]


next j
next i
 
redraw