#https://help.alibre.com/articles/#!alibre-help-v28/slice-a-part# open part, replace with your own pathP = Part(r'C:\Users\Brian\Desktop\ScriptDir', 'New2')# get bounding box of part - eight points, one for each corner# of the bounding boxBounds = P.GetBoundingBox()# get the plane that the part will be sliced onSlicePlane = P.GetPlane('Slice')# create a sketch on the slicing planeS = P.AddSketch('SliceSketch', SlicePlane)# empty listProj = []# for each corner of the part bounding box, map that 3D point into# a 2D point on the sketch# this doesn't create the points in the sketch, but is only a mathematical# operationfor i in range(0, 8): Proj.append(S.GlobaltoPoint(Bounds[i][0], Bounds[i][1], Bounds[i][2]))# go through the eight 2D points and find the maximum and minimum# X and Y valuesMaxX = Proj[0][0]for i in range (0, 8): if Proj[i][0] >= MaxX : MaxX = Proj[i][0]MaxY = Proj[0][1]for i in range (0, 8): if Proj[i][1] >= MaxY : MaxY = Proj[i][1]MinX = Proj[0][0]for i in range (0, 8): if Proj[i][0] < MinX : MinX = Proj[i][0]MinY = Proj[0][1]for i in range (0, 8): if Proj[i][1] < MinY : MinY = Proj[i][1]# draw a rectangle on the sketch which will cover the entire part when viewed# perpendicular to the slicing planeS.AddRectangle(MinX, MinY, MaxX, MaxY, False)# cut the part using the rectangleP.AddExtrudeCut('Cut', S, 100, False)