csWorkPlane v1.52 - Align Workplane to FaceSelection

This script only works on Mesh Faces. How to add Poly Faces? Unfortunately, I don’t know coding, I will be grateful if you could help me. Thank you! <br/><br/>macroScript AlignWorkplaneToFaceSelection category:"csTools" tooltip:"AlignWorkplaneToFaceSelection" ( macros.run "csTools" "RemoveWorkPlane" fn placeGridOnSelectedFace = ( local o = selection[1] local omesh = o.mesh local totalPos = [0,0,0] local totalNormal = [0,0,0] local selFaces = omesh.selectedFaces if selFaces.count > 0 then ( for fc in selFaces do ( totalPos = totalPos + (meshop.getFaceCenter omesh fc.index) totalNormal = totalNormal + (meshop.getFaceRNormals omesh fc.index)[1] ) local center = totalPos/selFaces.count local normal = totalNormal/selFaces.count local selVerts = ((meshop.GetVertsUsingFace omesh selFaces) as array) local firstEdge = normalize((meshop.getVert omesh selVerts[2]) - (meshop.getVert omesh selVerts[1])) local xaxis = cross normal firstEdge local yaxis = cross normal xaxis local gridTm = (matrix3 (normalize xaxis) (normalize yaxis) normal center) local worldTM = gridTm*o.transform global workplane = (grid name:"workPlane" grid:10.0) format "-- Genrating WorkPlane.\n" workplane.width = workplane.length = (distance o.min o.max) workplane.transform = worldTM local tmpSelection = (selection as array) select workplane max activate grid object select tmpSelection toolmode.commandmode = #ROTATE toolMode.coordsys #grid toolmode.commandmode = #USCALE toolMode.coordsys #grid toolmode.commandmode = #MOVE toolMode.coordsys #grid ) else( messagebox "Select face(s) on an object" ) ) if selection.count == 1 and (canConvertTo selection[1] editable_mesh) == true then ( placeGridOnSelectedFace() ) else( messagebox "Select a Face on a Mesh" ) )

I think should change these pieces to “Poly.” but … not working confused polyOp/opoly
local omesh = o.mesh
(meshop.getFaceCenter omesh fc.index)
(meshop.getFaceRNormals omesh fc.index)[1]
((meshop.GetVertsUsingFace omesh selFaces) as array)
normalize((meshop.getVert omesh selVerts[2]) - (meshop.getVert omesh selVerts[1]))
(canConvertTo selection[1] editable_mesh)


Sign In or Register to comment.