并集
typescript
// 准备颜色
const redColor = new Mx3dGeColor(MdGe.MxNameOfColor.Color_NOC_RED);
const blueColor = new Mx3dGeColor(MdGe.MxNameOfColor.Color_NOC_BLUE);
const greenColor = new Mx3dGeColor(MdGe.MxNameOfColor.Color_NOC_GREEN);
// 生成形状
const csysr = new Mx3dGeCSYSR();
csysr.SetLocation(650, 0, 0);
const box = new Mx3dMkBox(csysr, 20, 20, 20);
const boxShape = box.Shape();
csysr.SetLocation(670, 20, 20);
const sphere = new Mx3dMkSphere(csysr, 10);
const sphereShape = sphere.Shape();
const fuseShape = sphereShape.fuse(boxShape);
fuseShape.TranslateByVec(new Mx3dGeVec(0, 50, 0));
// 形状颜色添加至文档
addShapeToDoc(boxShape, redColor);
addShapeToDoc(sphereShape, greenColor);
addShapeToDoc(fuseShape, blueColor);
// 更新显示(会更新canvas中显示的模型)
mxcad3d.update();
差集
typescript
// 准备颜色
const redColor = new Mx3dGeColor(MdGe.MxNameOfColor.Color_NOC_RED);
const blueColor = new Mx3dGeColor(MdGe.MxNameOfColor.Color_NOC_BLUE);
const greenColor = new Mx3dGeColor(MdGe.MxNameOfColor.Color_NOC_GREEN);
// 生成形状
const csysr = new Mx3dGeCSYSR();
csysr.SetLocation(700, 0, 0);
const box = new Mx3dMkBox(csysr, 20, 20, 20);
const boxShape = box.Shape();
csysr.SetLocation(720, 20, 20);
const sphere = new Mx3dMkSphere(csysr, 10);
const sphereShape = sphere.Shape();
const cutShape = boxShape.cut(sphereShape);
cutShape.TranslateByVec(new Mx3dGeVec(0, 50, 0));
// 形状颜色添加至文档
addShapeToDoc(boxShape, redColor);
addShapeToDoc(sphereShape, greenColor);
addShapeToDoc(cutShape, blueColor);
// 更新显示(会更新canvas中显示的模型)
mxcad3d.update();
交集
typescript
// 准备颜色
const redColor = new Mx3dGeColor(MdGe.MxNameOfColor.Color_NOC_RED);
const blueColor = new Mx3dGeColor(MdGe.MxNameOfColor.Color_NOC_BLUE);
const greenColor = new Mx3dGeColor(MdGe.MxNameOfColor.Color_NOC_GREEN);
// 生成形状
const csysr = new Mx3dGeCSYSR();
csysr.SetLocation(750, 0, 0);
const box = new Mx3dMkBox(csysr, 20, 20, 20);
const boxShape = box.Shape();
csysr.SetLocation(770, 20, 20);
const sphere = new Mx3dMkSphere(csysr, 10);
const sphereShape = sphere.Shape();
const commonShape = boxShape.common(sphereShape);
commonShape.TranslateByVec(new Mx3dGeVec(0, 50, 0));
// 形状颜色添加至文档
addShapeToDoc(boxShape, redColor);
addShapeToDoc(sphereShape, greenColor);
addShapeToDoc(commonShape, blueColor);
// 更新显示(会更新canvas中显示的模型)
mxcad3d.update();
相交轮廓
typescript
// 准备颜色
const redColor = new Mx3dGeColor(MdGe.MxNameOfColor.Color_NOC_RED);
const blueColor = new Mx3dGeColor(MdGe.MxNameOfColor.Color_NOC_BLUE);
const greenColor = new Mx3dGeColor(MdGe.MxNameOfColor.Color_NOC_GREEN);
// 生成形状
const csysr = new Mx3dGeCSYSR();
csysr.SetLocation(800, 0, 0);
const box = new Mx3dMkBox(csysr, 20, 20, 20);
const boxShape = box.Shape();
csysr.SetLocation(820, 20, 20);
const sphere = new Mx3dMkSphere(csysr, 10);
const sphereShape = sphere.Shape();
const sectionShape = boxShape.section(sphereShape);
sectionShape.TranslateByVec(new Mx3dGeVec(0, 50, 0));
// 形状颜色添加至文档
addShapeToDoc(boxShape, redColor);
addShapeToDoc(sphereShape, greenColor);
addShapeToDoc(sectionShape, blueColor);
// 更新显示(会更新canvas中显示的模型)
mxcad3d.update();