public static void ViewContourElevation() { var pt1 = Interaction.GetPoint("\n截线起点"); if (pt1.IsNull()) { return; } var pt2 = Interaction.GetLineEndPoint("\n截线终点", pt1); if (pt2.IsNull()) { return; } var line = NoDraw.Line(pt1, pt2); var ids = QuickSelection.SelectAll().QWhere(x => x.GetCode() == "730101" || x.GetCode() == "730102").ToList(); var temps = new List <ObjectId>(); ids.QForEach <Curve>(cv => { if (cv != null) { var points = new Point3dCollection(); Algorithms.IntersectWith3264(line, cv, Intersect.OnBothOperands, points); var text = cv.ObjectId.GetData(DictName.CmDrawing, KeyName.Elevation); points.Cast <Point3d>().ForEach(p => { temps.Add(Draw.Text(text, 2.5, p)); }); } }); Interaction.GetString("\n按ESC退出"); temps.QForEach(x => x.Erase()); }
public static ObjectId[] CreateMeasurementPoint(Point3d point) => App.LockAndExecute(() => { int radius = 10; var curves = new Curve[] { NoDraw.Line(new Point3d(point.X - radius, point.Y, 0), new Point3d(point.X + radius, point.Y, 0)), NoDraw.Line(new Point3d(point.X, point.Y - radius, 0), new Point3d(point.X, point.Y + radius, 0)), NoDraw.Circle(point, radius) }; var layerId = GetExtraObjectsLayerId(); curves.Select(p => { p.LayerId = layerId; return(p); }).AddToCurrentSpace(); return(Array.ConvertAll(curves, p => p.ObjectId)); });
public static ObjectId[] CreateOriginObject(Point3d point) { int length = 100; var curves = new Curve[] { NoDraw.Line(point, point + Vector3d.XAxis * length), NoDraw.Line(point, point + Vector3d.YAxis * length), NoDraw.Rectang(new Point3d(point.X - length / 10, point.Y - length / 10, 0), new Point3d(point.X + length / 10, point.Y + length / 10, 0)) }; var layerId = GetExtraObjectsLayerId(); App.LockAndExecute(() => curves.Select(p => { p.LayerId = layerId; return(p); }).AddToCurrentSpace()); return(Array.ConvertAll(curves, p => p.ObjectId)); }
public void GCommand(string name, int gCode, string paramsString = null, Point3d?point = null, double?x = null, double?y = null, double?z = null, double?angleC = null, double?angleA = null, Curve curve = null, int?feed = null, Point2d?center = null) { var command = new ProcessCommand { Name = name }; if (point == null) { point = new Point3d(x ?? ToolLocation.Point.X, y ?? ToolLocation.Point.Y, z ?? ToolLocation.Point.Z); } command.Text = GCommandText(gCode, paramsString, point.Value, curve, angleC, angleA, feed, center); if (ToolLocation.IsDefined) { if (curve == null && ToolLocation.Point.DistanceTo(point.Value) > 1) { curve = NoDraw.Line(ToolLocation.Point, point.Value); } double length = 0; if (curve != null && curve.IsNewObject) { if (Colors.ContainsKey(name)) { curve.Color = Colors[name]; } curve.LayerId = _layerId; _currentSpace.AppendEntity(curve); _transaction.AddNewlyCreatedDBObject(curve, true); length = curve.Length(); } command.ToolpathObjectId = curve?.ObjectId; if ((feed ?? _feed) != 0) { command.Duration = (curve != null ? length : ToolLocation.Point.DistanceTo(point.Value)) / (gCode == 0 ? 10000 : feed ?? _feed) * 60; } } _GCode = gCode; ToolLocation.Set(point.Value, angleC, angleA); _feed = feed ?? _feed; command.HasTool = _hasTool; command.ToolLocation = ToolLocation.Clone(); _commands.Add(command); }
public static void Test() { ObjectId[] objectId = Interaction.GetSelection("\n选择多段线", "LWPOLYLINE");//选择多段线 if (objectId.Length == 0) { return; //一个都没选的情况下退出操作 } objectId.QForEach <Polyline>(polyline => { int length = (int)polyline.EndParam; for (int i = 0; i <= length; i++) { Line l1 = NoDraw.Line(polyline.GetPointAtParam(i), polyline.GetPreviousPointAtParam(i)); Line l2 = NoDraw.Line(polyline.GetPointAtParam(i), polyline.GetNextPointAtParam(i)); // Checks if lines intersect Plane plane; Line3d line1 = new Line3d(l1.StartPoint, l1.EndPoint); Line3d line2 = new Line3d(l2.StartPoint, l2.EndPoint); if (!line1.IsCoplanarWith(line2, out plane) || line1.IsParallelTo(line2)) { return; } // Calculates the bisector Point3d inters = line1.IntersectWith(line2)[0]; Vector3d vec1 = line1.Direction; Vector3d vec2 = line2.Direction; Vector3d bisectDir = ((vec1 + vec2) / 2.0).Negate(); var angle = bisectDir.GetAngleTo(Vector3d.XAxis); Xline xline = new Xline(); xline.UnitDir = bisectDir.GetNormal(); xline.BasePoint = inters; Draw.Text((i + 1).ToString(), 2, xline.GetPointAtDist(1)); Draw.Circle(polyline.GetPointAtParam(i), 0.5); } }); }
public void Cutting(Point3d startPoint, Vector3d delta, double[] zArray, int cuttingFeed, int smallFeed, Side engineSide = Side.None, double?angleC = null, double?angleA = null) { using (var line = NoDraw.Line(startPoint, startPoint + delta)) Cutting(line, zArray, cuttingFeed, smallFeed, engineSide, angleC, angleA); }
/// <summary> /// Рез между точками /// </summary> public void Cutting(Point3d startPoint, Point3d endPoint, int cuttingFeed, int transitionFeed, double?angleA = null) => Cutting(NoDraw.Line(startPoint, endPoint), cuttingFeed, transitionFeed, angleA: angleA);
/// <summary> /// Рез между точками /// </summary> public void Cutting(Point3d startPoint, Point3d endPoint, int cuttingFeed, int transitionFeed) => Cutting(NoDraw.Line(startPoint, endPoint), cuttingFeed, transitionFeed);