/// <summary> /// 创建直线 /// </summary> /// <param name="ske"><see cref="ISketchManager"/> Interface</param> /// <param name="centerPoint"><see cref="Vector3"/></param> /// <param name="pointOnCircle"><see cref="Vector3"/></param> /// <returns></returns> public static SketchSegment CreateLine(this ISketchManager ske, Vector3 centerPoint, Vector3 pointOnCircle) { return(ske.CreateLine(centerPoint.X, centerPoint.Y, centerPoint.Z, pointOnCircle.X, pointOnCircle.Y, pointOnCircle.Z)); }
/// <summary> /// 创建分流板主体,并关联ManiH全局变量 /// </summary> private void ManifoldBody() { ModelDoc2 swDoc = (ModelDoc2)swApp.ActiveDoc; ISketchManager ikm = swDoc.SketchManager; #region 1.创建临时Cube for (int i = 0; i < runnerSegments.Count; i++) { CreateRunnerCube(runnerSegments[i], i); } #endregion #region 2.得到边的几何数据,重新绘图 contourLine = GetManifoldEdge(); swDoc.ClearSelection2(true); bool boolstatus = swDoc.Extension.SelectByID2("前视基准面", "PLANE", 0, 0, 0, false, 0, null, 0); ikm.InsertSketch(true); for (int i = 0; i < contourLine.Count; i++) { ikm.CreateLine(contourLine[i].Start.X, contourLine[i].Start.Y, contourLine[i].Start.Z, contourLine[i].End.X, contourLine[i].End.Y, contourLine[i].End.Z); } #endregion #region 3.标注尺寸 Sketch thisSketch = ikm.ActiveSketch; Feature thisFet = (Feature)thisSketch; thisFet.Name = "ManifoldSketch"; //1. 分流板宽度 contourSegmentLine = thisSketch.GetSegmentLine(swApp); DimensionManiW(); swApp.SetFunction("ManiW", "\"ManiW2\" * 2"); #endregion #region 3.生成特征 boolstatus = swDoc.Extension.SelectByID2(thisFet.Name, "SKETCH", 0, 0, 0, false, 0, null, 0); Feature myFeature = swDoc.SingleEndExtrusion(maniH, false, true); myFeature.Name = "Manifold"; swApp.SetGlobalVariable("D1@Manifold", "ManiH"); #endregion #region 4.删除临时特征 for (int i = runnerSegments.Count - 1; i > -1; i--) { boolstatus = swDoc.Extension.SelectByID2("runnerCube" + i.ToString(), "BODYFEATURE", 0, 0, 0, false, 0, null, 0); swDoc.Extension.DeleteSelection2((int)swDeleteSelectionOptions_e.swDelete_Absorbed); } #endregion }