AEI script
How to set slice plane by 3 vertexs - Printable Version

+- AEI script (http://www.aei.pub)
+-- Forum: Discussion || 自由讨论区 (http://www.aei.pub/forumdisplay.php?fid=3)
+--- Forum: Parse the code || 代码解析 (http://www.aei.pub/forumdisplay.php?fid=6)
+--- Thread: How to set slice plane by 3 vertexs (/showthread.php?tid=2)



How to set slice plane by 3 vertexs - AEI - 12-20-2017

if $selection.count == 1 and classof $ == Editable_Poly and ($.EditablePoly.getSelection #Vertex as array ).count == 3 do --Get ready,only when selection is a polygon object and 3 vertexs ware selected .
(
    vertsel = $.EditablePoly.getSelection #Vertex as array  --save the vertex selection 
    vertsel[1] = polyop.getvert $ vertsel[1]  --save the vertext postion 
    vertsel[2] = polyop.getvert $ vertsel[2]
    vertsel[3] = polyop.getvert $ vertsel[3]
    vertsel[2] = vertsel[1] - vertsel[2]  -- get a vector 
    vertsel[3] = vertsel[1] - vertsel[3]  -- get another vector 
    if not polyop.inSlicePlaneMode $ do $.toggleCommandMode #SlicePlane  --set the sliceplanemode on
    polyop.setsliceplane $ (ray vertsel[1] (cross vertsel[2] vertsel[3])) 10  --set the sliceplane to target ,as the 2 vectors above defind a plane which was the target plane , but we can't set directly ,so we get cross product from them ,as the ray function could gave us the target , and it need two parameter , one is a vertex which on the target plane , another is the normal vector of the target plane which is the cross product .
)