public loopSeg(SketchSegment iniSeg) { seg = iniSeg; type = seg.GetType(); index = -1; start = -1; end = -1; }
//SketchPoint get_line(int index, string point) //{ // SketchLine element = (SketchLine)Segments[index]; // if (point == "a" || point == "A") return element.GetStartPoint2(); // if (point == "b" || point == "B") return element.GetEndPoint2(); // return null; //} //SketchPoint get_arc(int index, string point) //{ // SketchArc element = (SketchArc)Segments[index]; // if (point == "a" || point == "A") return element.GetStartPoint2(); // if (point == "b" || point == "B") return element.GetEndPoint2(); // if (point == "c" || point == "C") return element.GetCenterPoint2(); // return null; //} SketchPoint get(int index, string point) { if (index < 0) { index = (iSegments - 1) - abs(index); } SketchSegment segment = Segments[index]; if (segment.GetType() == (int)swSketchSegments_e.swSketchARC) { SketchArc element = (SketchArc)segment; if (point == "a" || point == "A") { return(element.GetStartPoint2()); } if (point == "b" || point == "B") { return(element.GetEndPoint2()); } if (point == "c" || point == "C") { return(element.GetCenterPoint2()); } } if (segment.GetType() == (int)swSketchSegments_e.swSketchLINE) { SketchLine element = (SketchLine)segment; if (point == "a" || point == "A") { return(element.GetStartPoint2()); } if (point == "b" || point == "B") { return(element.GetEndPoint2()); } } return(null); }
public bool same(loopSeg tem) { if (seg == tem.seg) { return(true); } else if ((start == tem.start && end == tem.end) || (start == tem.end && end == tem.start)) { if (seg.GetType() == tem.seg.GetType()) { return(true); } return(false); } return(false); }
public Line(SketchSegment segment) { if (segment.GetType() != (int)swSketchSegments_e.swSketchLINE) { return; } ICurve curve = segment.GetCurve(); //In meters double[] value = curve.LineParams; start = new Point(new double[] { value[0], value[1], value[2] }); len = segment.GetLength(); dir = new Vector(new double[] { value[3], value[4], value[5] });//可能是单位化的 dir = dir.unit; dir.X *= len; dir.Y *= len; dir.Z *= len; end = new Point(start.X + dir.X, start.Y + dir.Y, start.Z + dir.Z); }
//-------------------------------------------------------------------------------------------------- bool _AddPathSegment(SketchSegment sketchSegment) { // Get start and end point Pnt2d start, end; if (sketchSegment.EndPoint == _LastPathEndPoint) { start = _Sketch.Points[sketchSegment.EndPoint]; end = _Sketch.Points[sketchSegment.StartPoint]; _LastPathEndPoint = sketchSegment.StartPoint; } else { start = _Sketch.Points[sketchSegment.StartPoint]; end = _Sketch.Points[sketchSegment.EndPoint]; _LastPathEndPoint = sketchSegment.EndPoint; } // Create path segment switch (sketchSegment) { case SketchSegmentLine lineSegment: return(_AddLineSegment(lineSegment, start, end)); case SketchSegmentBezier bezierSegment: return(_AddBezierSegment(bezierSegment, start, end)); case SketchSegmentArc arcSegment: return(_AddArcSegment(arcSegment, start, end)); case SketchSegmentEllipticalArc arcSegment: return(_AddEllipicalArcSegment(arcSegment, start, end)); } Messages.Warning($"Connectable segment {_Sketch.Segments.FirstOrDefault(x => x.Value == sketchSegment).Key} of type {sketchSegment.GetType().Name} does not have a method to be exported to a SVG path."); return(true); }
//-------------------------------------------------------------------------------------------------- void _AddUnconnectableSegment(SketchSegment sketchSegment) { if (sketchSegment is SketchSegmentCircle) { var sketchCircle = (SketchSegmentCircle)sketchSegment; var radius = sketchCircle.Radius(_Sketch.Points); if (radius > 0) { var center = _Sketch.Points[sketchCircle.CenterPoint]; _DomGroup.Children.Add(new SvgDomCircle(center, radius)); return; } } else if (sketchSegment is SketchSegmentEllipse) { var sketchEllipse = (SketchSegmentEllipse)sketchSegment; var curve = sketchEllipse.MakeCurve(_Sketch.Points) as Geom2d_Ellipse; if (curve != null) { var center = _Sketch.Points[sketchEllipse.CenterPoint]; var element = new SvgDomEllipse(center, curve.MajorRadius(), curve.MinorRadius()); var majorAxisPoint = _Sketch.Points[sketchEllipse.GetMajorAxisPoint(_Sketch.Points)]; double rotAngle = new Ax2d(center, new Vec2d(center, majorAxisPoint).ToDir()).Angle(new Ax2d(center, Dir2d.DX)); element.Transforms.Add(new SvgRotateTransform(rotAngle.ToDeg(), element.Center)); _DomGroup.Children.Add(element); return; } } else { Messages.Warning($"Unconnectable segment {_Sketch.Segments.FirstOrDefault(x => x.Value == sketchSegment).Key} of type {sketchSegment.GetType().Name} does not have a method to be exported to a SVG element."); } Messages.Warning($"Unconnectable segment {_Sketch.Segments.FirstOrDefault(x => x.Value == sketchSegment).Key} of type {sketchSegment.GetType().Name} could not be exported to SVG element."); }
protected override void Command() { try { Face2 face = null; SketchSegment segment = null; if (MdlBase.eSelect_RecupererTypeObjet(1) == e_swSelectType.swSelFACES) { face = MdlBase.eSelect_RecupererObjet <Face2>(1); segment = MdlBase.eSelect_RecupererObjet <SketchSegment>(2); } else { face = MdlBase.eSelect_RecupererObjet <Face2>(2); segment = MdlBase.eSelect_RecupererObjet <SketchSegment>(1); } if (face == null || segment == null) { return; } MdlBase.eEffacerSelection(); Boolean r = false; Boolean reverse = false; var sk = segment.GetSketch(); var xform = (MathTransform)sk.ModelToSketchTransform.Inverse(); if (segment.GetType() != (int)swSketchSegments_e.swSketchLINE) { return; } var sl = (SketchLine)segment; var start = new ePoint(sl.GetStartPoint2()); var end = new ePoint(sl.GetEndPoint2()); start.ApplyMathTransform(xform); end.ApplyMathTransform(xform); WindowLog.Ecrire(start.IsRef() + " " + start.ToString()); WindowLog.Ecrire(end.IsRef() + " " + end.ToString()); var box = (Double[])face.GetBox(); var pt = new ePoint((box[3] + box[0]) * 0.5, (box[4] + box[1]) * 0.5, (box[5] + box[2]) * 0.5); WindowLog.Ecrire(pt.IsRef() + " " + pt.ToString()); if (start.Distance2(pt) > end.Distance2(pt)) { reverse = true; } r = face.eSelectEntite(MdlBase, 4, false); r = segment.eSelect(MdlBase, 1, true); var cp = (Body2)face.GetBody(); r = cp.eSelect(MdlBase, 512, true); var fm = MdlBase.FeatureManager; var featRepetDef = (CurveDrivenPatternFeatureData)fm.CreateDefinition((int)swFeatureNameID_e.swFmCurvePattern); featRepetDef.D1AlignmentMethod = 0; featRepetDef.D1CurveMethod = 0; featRepetDef.D1InstanceCount = 3; featRepetDef.D1IsEqualSpaced = true; featRepetDef.D1ReverseDirection = reverse; featRepetDef.D1Spacing = 0.001; featRepetDef.D2InstanceCount = 1; featRepetDef.D2IsEqualSpaced = false; featRepetDef.D2PatternSeedOnly = false; featRepetDef.D2ReverseDirection = false; featRepetDef.D2Spacing = 0.001; featRepetDef.GeometryPattern = true; var featRepet = fm.CreateFeature(featRepetDef); WindowLog.Ecrire(featRepet != null); } catch (Exception e) { this.LogMethode(new Object[] { e }); WindowLog.Ecrire(new Object[] { e }); } }