public static Body CreateCable(ITrimmedCurve iTrimmedCurve, double diameter) { double radius = diameter / 2; CurveEvaluation curveEvaluation = iTrimmedCurve.Geometry.Evaluate(iTrimmedCurve.Bounds.Start); Point startPoint = curveEvaluation.Point; Direction dirZ = curveEvaluation.Tangent; Direction dirX = dirZ.ArbitraryPerpendicular; Direction dirY = Direction.Cross(dirZ, dirX); Frame profileFrame = Frame.Create(startPoint, dirX, dirY); Circle profileCircle = Circle.Create(profileFrame, radius); IList <ITrimmedCurve> profile = new List <ITrimmedCurve>(); profile.Add(CurveSegment.Create(profileCircle)); IList <ITrimmedCurve> path = new List <ITrimmedCurve>(); path.Add(iTrimmedCurve); Body body = Body.SweepProfile(Plane.Create(profileFrame), profile, path); if (body == null) { Debug.Fail("Sweep failed."); return(null); } return(body); }
public static Body CreateSphere(Point center, double diameter) { double radius = diameter / 2; Frame profileFrame = Frame.Create(center, Direction.DirX, Direction.DirY); Circle sphereCircle = Circle.Create(profileFrame, radius); Line sphereRevolveLine = Line.Create(center, Direction.DirX); IList <ITrimmedCurve> profile = new List <ITrimmedCurve>(); profile.Add(CurveSegment.Create(sphereCircle, Interval.Create(0, Math.PI))); profile.Add(CurveSegment.Create(sphereRevolveLine, Interval.Create(-radius, radius))); IList <ITrimmedCurve> path = new List <ITrimmedCurve>(); Circle sweepCircle = Circle.Create(Frame.Create(center, Direction.DirY, Direction.DirZ), radius); path.Add(CurveSegment.Create(sweepCircle)); Body body = Body.SweepProfile(Plane.Create(profileFrame), profile, path); if (body == null) { Debug.Fail("Sweep failed."); return(null); } return(body); }
public static Body CreateCone(Point point1, Point point2, double diameter1, double diameter2, bool isSurface) { Vector heightVector = point2 - point1; Frame frame1 = Frame.Create(point1, heightVector.Direction); Frame frame2 = Frame.Create(point2, heightVector.Direction); var profiles = new List <ICollection <ITrimmedCurve> >(); profiles.Add(new ITrimmedCurve[] { CurveSegment.Create(Circle.Create(frame1, diameter1 / 2)) }); profiles.Add(new ITrimmedCurve[] { CurveSegment.Create(Circle.Create(frame2, diameter2 / 2)) }); Body body = null; try { body = Body.LoftProfiles(profiles, false, true); } catch (Exception e) { Debug.WriteLine(e.Message); } if (body == null) { Debug.Fail("Error creating loft for cone"); return(null); } if (isSurface) { body.DeleteFaces(body.Faces.Where(f => f.Geometry is Plane).ToArray(), RepairAction.None); } return(body); }
protected override bool OnMouseMove(ScreenPoint cursorPos, Line cursorRay, MouseButtons button) { if (button != MouseButtons.None) { return(false); } IDocObject preselection = InteractionContext.Preselection; DesignEdge designEdge = preselection as DesignEdge; if (designEdge == null) // selection filtering is not applied if you (pre)select in the tree { return(false); } Circle edgeCircle = (Circle)designEdge.Shape.Geometry; CurveSegment innerCurve = CurveSegment.Create(Circle.Create(edgeCircle.Frame, apiGroove.InnerDiameter / 2)); CurveSegment outerCurve = CurveSegment.Create(Circle.Create(edgeCircle.Frame, apiGroove.OuterDiameter / 2)); var style = new GraphicStyle { LineColor = Color.DarkGray, LineWidth = 2 }; Graphic centerLine = Graphic.Create(style, new[] { CurvePrimitive.Create(innerCurve), CurvePrimitive.Create(outerCurve) }); style = new GraphicStyle { LineColor = Color.White, LineWidth = 4 }; Graphic highlightLine = Graphic.Create(style, new[] { CurvePrimitive.Create(innerCurve), CurvePrimitive.Create(outerCurve) }); Rendering = Graphic.Create(style, null, new[] { highlightLine, centerLine }); return(false); // if we return true, the preselection won't update }
public static MeshPrimitive GetCircularTabMesh(Point p0, Point p1, Direction normal, double angle, bool isMale) { Circle circle = GetCircularTabCircle(p0, p1, normal, angle, isMale); double centerParam = Math.PI / 2; if (!isMale) { angle *= -1; centerParam += Math.PI; } ITrimmedCurve circleSegment = CurveSegment.Create(circle, Interval.Create(centerParam - angle / 2, centerParam + angle / 2)); IList <Point> points = circleSegment.GetPolyline(); Debug.Assert(points.Count > 3, "Not enough points for tab faceting."); var facets = new List <Facet>(); for (int i = 1; i < points.Count - 1; i++) { facets.Add(new Facet(0, i, i + 1)); } return(MeshPrimitive.Create(points, normal, facets)); }
public static void CreateDashes(ITrimmedCurve curve, Part part, double dashMinSize, Layer dashLayer) { double length = curve.Length; int count = (int)Math.Floor(length / dashMinSize / 2) * 2; if (curve.StartPoint != curve.EndPoint) // odd number when not closed curve { count++; } double lastParam = curve.Bounds.Start; double param; for (int i = 0; i < count; i++) { if (curve.Geometry.TryOffsetParam(lastParam, length / count, out param)) { if (i % 2 == 1) { DesignCurve dash = DesignCurve.Create(part, CurveSegment.Create(curve.Geometry, Interval.Create(lastParam, param))); dash.Layer = dashLayer; } lastParam = param; } } }
public static DesignBody CreateCircle(Frame frame, double diameter, IPart part) { Plane plane = Plane.Create(frame); List <ITrimmedCurve> profile = new List <ITrimmedCurve>(); Circle circle = Circle.Create(frame, diameter / 2); profile.Add(CurveSegment.Create(circle)); Body body = null; try { body = Body.CreatePlanarBody(plane, profile); } catch { Debug.Assert(false, "Exception thrown creating body"); } if (body == null) { Debug.Fail("Profile was not connected, not closed, or not in order."); return(null); } if (part == null) { part = Window.ActiveWindow.ActiveContext.ActivePart; } DesignBody desBodyMaster = DesignBody.Create(part.Master, "Circle", body); desBodyMaster.Transform(part.TransformToMaster); return(desBodyMaster); }
public static IList <ITrimmedCurve> AsPolygon(this IList <Point> points) { var profile = new List <ITrimmedCurve>(); for (int i = 0; i < points.Count; i++) { ITrimmedCurve iTrimmedCurve = null; if (i < points.Count - 1) { iTrimmedCurve = CurveSegment.Create(points[i], points[i + 1]); } else { iTrimmedCurve = CurveSegment.Create(points[i], points[0]); } if (iTrimmedCurve == null) // if points are the same, the curve is null { continue; } profile.Add(iTrimmedCurve); } if (profile.Count == 0) { return(null); } return(profile); }
public void GetCurves(out IList <CurveSegment> cutterCurves, out IList <CurveSegment> rapidCurves, out IList <CurveSegment> arrowCurves) { Debug.Assert(CutterLocations != null); cutterCurves = new List <CurveSegment>(); rapidCurves = new List <CurveSegment>(); arrowCurves = new List <CurveSegment>(); for (int i = 0; i < CutterLocations.Length - 1; i++) { CurveSegment curve = CurveSegment.Create(CutterLocations[i].Point, CutterLocations[i + 1].Point); //Debug.Assert(curve != null); if (curve == null) { continue; } if (CutterLocations[i + 1].IsRapid) { rapidCurves.Add(curve); } else { cutterCurves.Add(curve); } if (CutterLocations[i].IsRapid && !CutterLocations[i + 1].IsRapid) { arrowCurves.Add(curve); } } }
public void AddCurve(ITrimmedCurve iTrimmedCurve) { if (iTrimmedCurve.Geometry is Line) { dxfCurves.Add(new DxfLine(iTrimmedCurve, textWriter)); return; } if (iTrimmedCurve.Geometry is Circle) { if (iTrimmedCurve.Bounds.Span == 2 * Math.PI) { dxfCurves.Add(new DxfCircle(iTrimmedCurve, textWriter)); } else { dxfCurves.Add(new DxfArc(iTrimmedCurve, textWriter)); } return; } IList <Point> points = iTrimmedCurve.Geometry.GetPolyline(iTrimmedCurve.Bounds); for (int i = 0; i < points.Count - 1; i++) { dxfCurves.Add(new DxfLine(CurveSegment.Create(points[i], points[i + 1]), textWriter)); } }
private static Body CreateSphericalSegment(Point tangent, Direction normal, double radius, double halfWidth, double thickness) { Point center = tangent + normal * radius; radius = Math.Abs(radius); Plane plane = Plane.Create(Frame.Create(center, normal, normal.ArbitraryPerpendicular)); Circle circle = Circle.Create(plane.Frame, radius); CurveSegment circleCurve = CurveSegment.Create(circle, Interval.Create(0, Math.Asin(halfWidth / radius))); Point rearCenter = tangent - normal * thickness; Point rearUpper = rearCenter + plane.Frame.DirY * halfWidth; var profile = new List <ITrimmedCurve>(); profile.Add(circleCurve); profile.Add(CurveSegment.Create(rearCenter, tangent)); profile.Add(CurveSegment.Create(rearCenter, rearUpper)); profile.Add(CurveSegment.Create(rearUpper, circleCurve.EndPoint)); foreach (ITrimmedCurve curve in profile) { DesignCurve.Create(Window.ActiveWindow.Scene as Part, curve); } ITrimmedCurve path = CurveSegment.Create(Circle.Create(Frame.Create(tangent, normal), 1)); return(Body.SweepProfile(plane, profile, new ITrimmedCurve[] { path })); // return Body.CreatePlanarBody(plane, new ITrimmedCurve[] { CurveSegment.Create(circle) }); // return ShapeHelper.CreateCircle(plane.Frame, radius * 2, Window.ActiveWindow.Scene as Part).Shape.Copy(); }
private void CreateDesignCurveIfPointsSeparate(Part part, Point a, Point b) { if (a != b) // compares within modeling tolerance { DesignCurve.Create(part, CurveSegment.Create(a, b)); } }
public static CurveSegment CreateHelixAroundCurve(this ITrimmedCurve curveSegment, double turns, double radius, double pointCount) { var points = new List <Point>(); Direction lastNormal = curveSegment.Geometry.Evaluate(curveSegment.Bounds.Start).Tangent.ArbitraryPerpendicular; for (int i = 0; i < pointCount; i++) { double ratio = (double)i / pointCount; double param = curveSegment.Bounds.Start + ratio * curveSegment.Bounds.Span; CurveEvaluation curveEval = curveSegment.Geometry.Evaluate(param); Direction normal = Direction.Cross(Direction.Cross(curveEval.Tangent, lastNormal), curveEval.Tangent); if (normal.IsZero) { normal = lastNormal; } Point point = curveEval.Point; Matrix rotation = Matrix.CreateRotation(Line.Create(point, curveEval.Tangent), 2 * Math.PI * turns * ratio); point += radius * normal; point = rotation * point; points.Add(point); lastNormal = normal; } return(CurveSegment.Create(NurbsCurve.CreateThroughPoints(false, points, 0.000001))); }
public static Body CreateCylinder(Point point1, Point point2, double diameter) // TBD Merge you lazy bum { Vector heightVector = point2 - point1; Frame frame = Frame.Create(point1, heightVector.Direction); Plane plane = Plane.Create(frame); List <ITrimmedCurve> profile = new List <ITrimmedCurve>(); profile.Add(CurveSegment.Create(Circle.Create(frame, diameter / 2))); Body body = null; try { body = Body.ExtrudeProfile(plane, profile, heightVector.Magnitude); } catch (Exception e) { Debug.WriteLine(e.Message); } if (body == null) { Debug.Fail("Profile was not connected, not closed, or not in order."); return(null); } return(body); }
protected override Body GetCappingBody() { Point startOuter = StartCone.WrapPoint(0, GearData.AddendumRadius * internalGearODScale); Point endOuter = EndCone.WrapPoint(0, GearData.AddendumRadius * internalGearODScale); Point startKnee = StartCone.WrapPoint(0, -(1 + BevelKneeRatio) * GearData.Module); Point endKnee = EndCone.WrapPoint(0, -(1 + BevelKneeRatio) * GearData.Module); Point startCenter = Axis.ProjectPoint(startKnee).Point; Point endCenter = Axis.ProjectPoint(endKnee).Point; IList <ITrimmedCurve> cappingProfile = new Point[] { startCenter, startKnee, startOuter, endOuter, endKnee, endCenter }.AsPolygon(); IList <ITrimmedCurve> revolvePath = new ITrimmedCurve[] { CurveSegment.Create(Circle.Create(StartFrame, 1)) }; Body cappingBody = null; try { cappingBody = Body.SweepProfile(Plane.PlaneZX, cappingProfile, revolvePath); } catch { foreach (ITrimmedCurve curve in cappingProfile) { DesignCurve.Create(Part, curve); } } return(cappingBody); }
public static DesignBody CreateBar(Part part) { Debug.Assert(part != null, "part != null"); double barRadius = 0.002; double barLenght = 0.020; Point pointStart = Point.Create(0, 0, 0); Point pointEnd = Point.Create(0, 0.04, 0.05); DesignCurve.Create(part, CurveSegment.Create(pointStart, pointEnd)); Body cylinder1 = Body.ExtrudeProfile(new CircleProfile(Plane.PlaneZX, barRadius), barLenght); DesignBody.Create(part, "Cylinder1", cylinder1); Body cylinder2 = Body.ExtrudeProfile(new CircleProfile(Plane.PlaneXY, barRadius), barLenght); DesignBody.Create(part, "Cylinder2", cylinder2); Body cylinder3 = Body.ExtrudeProfile(new CircleProfile(Plane.PlaneYZ, barRadius), barLenght); return(DesignBody.Create(part, "Cylinder3", cylinder3)); }
//static Plane CreatePlane(Point origin, Direction normal) //{ // return Plane.Create(Frame.Create(origin, normal)); //} static DesignBody CreatePPBar(Part part) { Window window = Window.ActiveWindow; Debug.Assert(part != null, "part 1= null"); double barRadius = 0.002; double barLenght = 0.020; Point pointStart = Point.Create(0, 0.03, 0.07); Point pointEnd = Point.Create(0.02, 0.04, 0.09); DesignCurve.Create(part, CurveSegment.Create(pointStart, pointEnd)); //Plane plane = CreatePlane(pointStart, normal); //DesignCurve line = DesignCurve.Create(); //Direction direction = Direction.Equals(CurveSegment); //Frame frame = Frame.Create(pointStart); //Plane plane = Plane.Create(frame); Body bar = Body.ExtrudeProfile(new CircleProfile(Plane.PlaneYZ, barRadius), barLenght); return(DesignBody.Create(part, "Cylinder", bar)); }
private static CurveSegment TrimAndTransform(ref Matrix trans, Plane planeA, Plane planeB, CurveSegment curve) { double startParam = planeA.IntersectCurve(curve.Geometry).First().EvaluationB.Param; double endParam = planeB.IntersectCurve(curve.Geometry).First().EvaluationB.Param; curve = CurveSegment.Create(curve.Geometry, Interval.Create(startParam, endParam)); return(curve.CreateTransformedCopy(trans)); }
static void CreateLine(Part line) { Window window = Window.ActiveWindow; Point pointStart = Point.Create(0.10, 0.04, 0.07); Point pointEnd = Point.Create(0.02, 0.11, 0.09); DesignCurve.Create(line, CurveSegment.Create(pointStart, pointEnd)); MessageBox.Show($"Line between {pointStart} and {pointEnd} will be created", "Info"); }
public override IEnumerable <CurveSegment> GetProfile() { Point center = Point.Origin + Direction.DirZ * Radius; Point top = Point.Origin + Direction.DirZ * CuttingHeight; var ballArc = CurveSegment.Create(Circle.Create(Frame.Create(center, Direction.DirX, Direction.DirZ), Radius), Interval.Create((double)3 / 4 * Const.Tau, Const.Tau)); var sideLine = CurveSegment.Create(center + Direction.DirX * Radius, top + Direction.DirX * Radius); var topLine = CurveSegment.Create(top + Direction.DirX * Radius, top); return(new[] { ballArc, sideLine, topLine }); }
public static ICollection <ITrimmedCurve> GetProfile(this IList <Point> points) { var iTrimmedCurves = new List <ITrimmedCurve>(); for (int i = 0; i < points.Count; i++) { iTrimmedCurves.Add(CurveSegment.Create(points[i], points[i == points.Count - 1 ? 0 : i + 1])); } return(iTrimmedCurves); }
public void AddPath(IList <Point> points, bool isClosed, double strokeWidth, Color?strokeColor, Color?fillColor) { List <ITrimmedCurve> iTrimmedCurves = new List <ITrimmedCurve>(); for (int i = 0; i < points.Count - 1; i++) { iTrimmedCurves.Add(CurveSegment.Create(points[i], points[i + 1])); } AddPath(iTrimmedCurves, isClosed, strokeWidth, strokeColor, fillColor); }
static void CreateLines(Part multiLine) { Window window = Window.ActiveWindow; List <PointTarget> points = ImportingFun.LoadSampleData(); foreach (var PointTarget in points) { //MessageBox.Show($"Line between {points[0]} and will be created"); DesignCurve.Create(multiLine, CurveSegment.Create(Point.Create(PointTarget.xPoint, PointTarget.yPoint, PointTarget.zPoint), Point.Create(PointTarget.x2Point, PointTarget.y2Point, PointTarget.z2Point))); } }
static void MultiBeamCreator(Part part) { try { //Document doc = Document.GetDocument(Settings.Default.ProjectPath + "/" + Settings.Default.ProjectName + ".scdoc"); Document doc = Window.ActiveWindow.Document; Part p = doc.MainPart; int id = 0; List <PointLocation> pointLocations = CsvDataRead.ReadData(); // Get all beams out of file foreach (var location in pointLocations) { Point startPoint = Point.Create(Double.Parse("" + (location.xPoint / 1000), new CultureInfo("de-DE")), Double.Parse("" + (location.yPoint / 1000), new CultureInfo("de-DE")), Double.Parse("" + (location.zPoint / 1000), new CultureInfo("de-DE"))); Point endPoint = Point.Create(Double.Parse("" + (location.x2Point / 1000), new CultureInfo("de-DE")), Double.Parse("" + (location.y2Point / 1000), new CultureInfo("de-DE")), Double.Parse("" + (location.z2Point / 1000), new CultureInfo("de-DE"))); if (location.diameter != 0) { try { double diameter = location.diameter; double radi = Double.Parse("" + (location.diameter / 2000), new CultureInfo("de-DE")); var lineSegment = CurveSegment.Create(startPoint, endPoint); var designLine = DesignCurve.Create(p, lineSegment); Vector heightVector = endPoint - startPoint; Frame frame = Frame.Create(startPoint, heightVector.Direction); Plane plane = Plane.Create(frame); var profi = new CircleProfile(plane, radi); //var doc = DocumentHelper.GetActiveDocument(); //Document doc = Document.GetDocument(Path.GetDirectoryName("Document1")); //Document doc = window.ActiveContext.Context.Document; Part beamProfile = Part.CreateBeamProfile(doc, "Beam" + id, profi); Beam.Create(beamProfile, designLine); id += 1; } catch (Exception ex) { MessageBox.Show(ex.ToString(), "Info"); } } } } catch (Exception exe) { MessageBox.Show(exe.ToString(), "Info"); } }
public static void Print(this Cone cone, Part part = null) { double startV = -Math.Cos(cone.HalfAngle) * cone.Radius; double endV = 0; ShapeHelper.CreateRevolvedCurve(cone.Axis, CurveSegment.Create( cone.Evaluate(PointUV.Create(0, startV)).Point, cone.Evaluate(PointUV.Create(0, endV)).Point )).Print(part); // Circle.Create(cone.Frame, cone.Radius).Print(part); // CurveSegment.Create(cone.Evaluate(PointUV.Create(0, 0)).Point, cone.Evaluate(PointUV.Create(Math.PI / 2, 0)).Point).Print(part); }
static void CreateShotNearPoint(Point point, double height, double radius) { Window activeWindow = Window.ActiveWindow; Line rayLine = Line.Create(point, activeWindow.Projection.Inverse * Direction.DirZ); ITrimmedCurve rayCurve = CurveSegment.Create(rayLine, Interval.Create(1000, -1000)); //DesignCurve.Create(activeWindow.Scene as Part, rayCurve); // draws the ray as a design object var intersectionList = new List <IntPoint <SurfaceEvaluation, CurveEvaluation> >(); foreach (IDesignBody designBody in (activeWindow.Scene as Part).Bodies) { foreach (IDesignFace designFace in designBody.Faces) { intersectionList.AddRange(designFace.Shape.IntersectCurve(rayCurve)); } } Point? closePoint = null; double closeParam = Double.MinValue; foreach (IntPoint <SurfaceEvaluation, CurveEvaluation> intersection in intersectionList) { if (intersection.EvaluationB.Param > closeParam) { closeParam = intersection.EvaluationB.Param; closePoint = intersection.Point; } } if (closePoint == null) { return; } DesignBody toolBody = ShapeHelper.CreateSphere(closePoint.Value, radius, activeWindow.Scene as Part); //TBD why doesn't this work on spacklePart? //Frame? frame = GetFrameFromPoint(designFace, point); //if (frame == null) // return; //Body body = CreateCylinder(point, frame.Value.DirX, frame.Value.DirY, radius, height); //DesignBody toolBody = AddInHelper.CreateSphere(frame.Value.Origin, radius, spacklePart); // TBD XXX Fix for v5 //if (spackleMode == SpackleMode.Add) // targetBody.Unite(new IDesignBody[] { toolBody }); //else if (spackleMode == SpackleMode.Cut) // targetBody.Subtract(new IDesignBody[] { toolBody }); }
private void CreateGeometry() { Window activeWindow = Window.ActiveWindow; Part mainPart = activeWindow.Scene as Part; if (mainPart == null) { return; } List <Body> bodies = new List <Body>(); foreach (int[,] patchData in patchIndices) { ControlPoint[,] controlPoints = new ControlPoint[4, 4]; for (int i = 0; i < 4; i++) { for (int j = 0; j < 4; j++) { controlPoints[i, j] = new ControlPoint(vertices[patchData[i, j] - 1], 1); } } IDictionary <string, Face> idToFace; IDictionary <string, Edge> idToEdge; bodies.Add(Body.Import(new BezierPatchForeignBody(controlPoints), out idToFace, out idToEdge)); if (bodies[bodies.Count - 1].Faces.Count == 0) { for (int i = 0; i < 4; i++) { for (int j = 0; j < 4; j++) { DesignCurve.Create(mainPart, CurveSegment.Create(PointCurve.Create(vertices[patchData[i, j] - 1]))); } } } } foreach (Body body in bodies) { if (body.Faces.Count > 0) { DesignBody.Create(mainPart, "Bezier", body); } } activeWindow.InteractionMode = InteractionMode.Solid; activeWindow.ZoomExtents(); }
protected override void OnExecute(Command command, System.Drawing.Rectangle buttonRect) { base.OnExecute(command, buttonRect); foreach (VideoForm videoForm in controlForm.VideoForms) { Line line = videoForm.TrackingCamera.GetLine(); var curveSegment = CurveSegment.Create(line, Interval.Create(-10, 10)); var desCurve = DesignCurve.Create(part, curveSegment); desCurve.Layer = referenceLayer; Point point = line.Origin; DesignBody desBody = ShapeHelper.CreateSphere(point, 0.1, part); desBody.Layer = referenceLayer; } }
public static DesignBody CreateSausage(Point point1, Point point2, double diameter, IPart part) { double radius = diameter / 2; Vector lengthVector = point2.Vector - point1.Vector; Direction dirX = lengthVector.Direction; Direction dirY = dirX.ArbitraryPerpendicular; Direction dirZ = Direction.Cross(dirX, dirY); Frame profileFrame = Frame.Create(point1, dirX, dirY); Plane profilePlane = Plane.Create(profileFrame); IList <ITrimmedCurve> profile = new List <ITrimmedCurve>(); Line axisLine = Line.Create(point1, dirX); profile.Add(CurveSegment.Create(axisLine, Interval.Create(-radius, lengthVector.Magnitude + radius))); Circle circle1 = Circle.Create(profileFrame, radius); profile.Add(CurveSegment.Create(circle1, Interval.Create(Math.PI / 2, Math.PI))); Line tangentLine = Line.Create(Matrix.CreateTranslation(dirY * radius) * point1, dirX); profile.Add(CurveSegment.Create(tangentLine, Interval.Create(0, lengthVector.Magnitude))); Circle circle2 = Circle.Create(Frame.Create(point2, dirX, dirY), radius); profile.Add(CurveSegment.Create(circle2, Interval.Create(0, Math.PI / 2))); IList <ITrimmedCurve> path = new List <ITrimmedCurve>(); Circle sweepCircle = Circle.Create(Frame.Create(point1, dirY, dirZ), radius); path.Add(CurveSegment.Create(sweepCircle)); Body body = Body.SweepProfile(Plane.Create(profileFrame), profile, path); if (body == null) { Debug.Fail("Profile was not connected, not closed, or swept along an inappropriate path."); return(null); } DesignBody desBodyMaster = DesignBody.Create(part.Master, "Sausage", body); desBodyMaster.Transform(part.TransformToMaster); return(desBodyMaster); }
public virtual ICollection <ITrimmedCurve> GetProfile() { baseRadius = Data.BaseRadius; pitchRadius = Data.PitchRadius; addendumRadius = Data.AddendumRadius; dedendumRadius = Data.DedendumRadius; basicInvolute = CurveSegment.Create(Data.CreateInvolute()); offsetAngle = Data.OffsetAngle; involutePitchTrans = Matrix.CreateRotation(Line.Create(Point.Origin, Direction.DirZ), offsetAngle); curveA = basicInvolute.CreateTransformedCopy(involutePitchTrans); curveB = curveA.CreateTransformedCopy(mirror); if (Data.TopStartAngle < Data.TopEndAngle) { topCurve = CurveSegment.Create(Data.AddendumCircle, Interval.Create(Data.TopStartAngle, Data.TopEndAngle)); period.Add(topCurve); } else // involutes intersect at top land { ICollection <IntPoint <CurveEvaluation, CurveEvaluation> > intersections = curveA.IntersectCurve(curveB.CreateTransformedCopy(Data.ToothTrans)); Debug.Assert(intersections.Count == 1); if (intersections.Count != 1) { curveA.Print(); curveB.CreateTransformedCopy(Data.ToothTrans).Print(); } curveA = CurveSegment.Create(curveA.Geometry, Interval.Create(curveA.Bounds.Start, intersections.First().EvaluationA.Param)); curveB = curveA.CreateTransformedCopy(mirror); } ICollection <IntPoint <CurveEvaluation, CurveEvaluation> > bottomIntersections = curveA.IntersectCurve(curveB); if (bottomIntersections.Count > 0 && bottomIntersections.First().Point.Vector.Magnitude > dedendumRadius) // the involutes intersect at bottom land { curveA = CurveSegment.Create(curveA.Geometry, Interval.Create(curveA.IntersectCurve(curveB).ToArray()[0].EvaluationA.Param, curveA.Bounds.End)); period.Add(curveA); period.Add(curveA.CreateTransformedCopy(mirror)); return(period); } return(null); }