internal SwSketchEntityCollection(ISwDocument doc, ISwSketchBase sketch) { m_Doc = doc; m_Sketch = sketch; m_SkMgr = doc.Model.SketchManager; m_Cache = new List <IXSketchEntity>(); }
public SwSketchEntityCollection(IModelDoc2 model, SwSketchBase sketch, ISketchManager skMgr) { m_Model = model; m_Sketch = sketch; m_SkMgr = skMgr; m_Cache = new List <IXSketchEntity>(); }
private void DimensionManiW() { ModelDoc2 swDoc = (ModelDoc2)swApp.ActiveDoc; ISketchManager ikm = swDoc.SketchManager; double tolerance = 0.05; List <SketchLine> contours = new List <SketchLine>(contourSegmentLine.ToArray()); List <SketchLine> runner = new List <SketchLine>(runnerSegments.ToArray()); for (int i = 0; i < contours.Count; i++) { for (int j = 0; j < runner.Count; j++) { if (!runner[j].isParallerTo(contours[i], tolerance)) { continue; } double distance = contours[i].DistanceTo(runner[j]); double d = Math.Abs(distance - maniW / 2); if (d > 0.0001) { continue; } contours[i].DimensionWith(runner[j], "ManiW2", swApp); } } }
/// <summary> /// 以不自动约束模式绘制草图 InferenceMode = false /// </summary> /// <param name="skeMgr"><see cref="ISketchManager"/> Interface</param> /// <param name="sketchAction">Action for Drawing SkechSegment</param> public static void SketchWithNoReference(this ISketchManager skeMgr, Action <ISketchManager> sketchAction, ISldWorks app) { app.WithToggleState(swUserPreferenceToggle_e.swSketchInference, false, () => { sketchAction.Invoke(skeMgr); } ); }
protected SwSketchSegment(ISwDocument doc, ISketchSegment seg, bool created) : base(doc, seg) { if (doc == null) { throw new ArgumentNullException(nameof(doc)); } m_SketchMgr = doc.Model.SketchManager; m_Creator = new ElementCreator <ISketchSegment>(CreateEntity, seg, created); }
/// <summary> /// 退出草图编辑状态 /// </summary> /// <param name="skeMgr"><see cref="ISketchManager"/> Interface</param> /// <param name="UpdateEditRebuild"></param> /// <returns><see cref="ISketch"/></returns> /// <remarks> /// 如果SolidWorks不在编辑状态,将会抛出 <see cref="InvalidOperationException"/> 异常 /// </remarks> public static ISketch ExitSketch(this ISketchManager skeMgr, bool UpdateEditRebuild = false) { var sketch = skeMgr.ActiveSketch; if (sketch == null) { throw new InvalidOperationException($"There is not a active skecth,so you cannot exit sketch"); } skeMgr.InsertSketch(UpdateEditRebuild); return(sketch); }
internal SwSketchPoint(ISwDocument doc, ISketchPoint pt, bool created) : base(doc, pt) { m_SketchMgr = doc.Model.SketchManager; m_Creator = new ElementCreator <ISketchPoint>(CreatePoint, pt, created); }
/// <summary> /// 获取建造对象 /// </summary> /// <param name="sketchManager"><see cref="ISketchManager"/> Interface</param> /// <returns> 使用 <see cref="SketchSeBuilder"/> 来绘制草图</returns> public static SketchSeBuilder GetBuilder(this ISketchManager sketchManager) { return(new SketchSeBuilder(sketchManager)); }
/// <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)); }
public static ISketchPoint CreatePoint(this ISketchManager ske, Vector3 point) { return(ske.CreatePoint(point.X, point.Y, point.Z)); }
public SketchSeBuilder(ISketchManager sketchManager) { skeMgr = sketchManager; }
public void Dispose() { skeMgr = null; builderActions.Clear(); SketchSegments.Clear(); }
private void getModelDoc() { swDoc = ((ModelDoc2)(swApp.ActiveDoc)); if (swDoc.GetType() == (int)swDocumentTypes_e.swDocASSEMBLY) { swAssembly = ((AssemblyDoc)(swDoc)); } swSelectionMgr = ((SelectionMgr)(swDoc.SelectionManager)); swConfMgr = ((ConfigurationManager)swDoc.ConfigurationManager); swConf = ((Configuration)swConfMgr.ActiveConfiguration); swSketchMgr = ((ISketchManager)swDoc.SketchManager); measure = swDoc.Extension.CreateMeasure(); measure.ArcOption = 1; // minimum distance mathUtils = swApp.IGetMathUtility(); swFeatureMgr = ((FeatureManager)swDoc.FeatureManager); mainBody = findComponent(swConf.GetRootComponent3(true), "body"); if (mainBody == null) { mainBody = findComponent(swConf.GetRootComponent3(true), "base"); if (mainBody == null) { Utilities.alert("we need a component with 'body' in its name to be the main body"); } } allSolidComponents = getAllComponents(); ourComponents = getAllOurComponents(); if (generatedMirrorExtrusions == null) { generatedMirrorExtrusions = new List <IFeature>(); } swAssembly.EditAssembly(); InstructionsGenerator.swApp = swApp; InstructionsGenerator.swDoc = swDoc; InstructionsGenerator.swAssembly = swAssembly; InstructionsGenerator.swSelectionMgr = swSelectionMgr; RayTracer.swApp = swApp; RayTracer.swDoc = swDoc; RayTracer.swAssembly = swAssembly; RayTracer.swSelectionMgr = swSelectionMgr; RayTracer.swSketchMgr = swSketchMgr; RayTracer.mathUtils = mathUtils; RayTracer.visualize = visualize.Checked; RayTracer.ourComponents = ourComponents; RayTracer.camera = camera; Simulator.swApp = swApp; Simulator.swDoc = swDoc; Simulator.swAssembly = swAssembly; Simulator.swFeatureMgr = swFeatureMgr; Simulator.mainBody = mainBody; Simulator.ourComponents = ourComponents; Utilities.swApp = swApp; Utilities.swDoc = swDoc; Utilities.swAssembly = swAssembly; Utilities.swSelectionMgr = swSelectionMgr; Utilities.swConfMgr = swConfMgr; Utilities.swConf = swConf; Utilities.swFeatureMgr = swFeatureMgr; Utilities.swSketchMgr = swSketchMgr; Utilities.measure = measure; Utilities.mathUtils = mathUtils; }
/// <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 }
public ISketchManagerObject(ISketchManager ISketchManagerinstance) { ISketchManagerInstance = ISketchManagerinstance; }
internal SwSketchPoint(ISketchPoint pt, ISwDocument doc, ISwApplication app, bool created) : base(pt, doc, app) { m_SketchMgr = doc.Model.SketchManager; m_Creator = new ElementCreator <ISketchPoint>(CreatePoint, pt, created); }