protected BevelGear(IPart parent, GearData gearData, GearData conjugateGearData, ToothProfile toothProfile, double helicalAngle, double bevelAngle, double bevelKneeRatio, double depth) : base(parent, gearData, conjugateGearData, toothProfile, helicalAngle, depth) { BevelAngle = bevelAngle; BevelKneeRatio = bevelKneeRatio; StartPoint = Point.Create(0, 0, XOffset); EndPoint = StartPoint - Vector.Create(0, 0, Depth * Math.Cos(Alpha)); StartFrame = Frame.Create(StartPoint, Direction.DirX, -Direction.DirY); EndFrame = Frame.Create(EndPoint, Direction.DirX, -Direction.DirY); StartDiameter = GearData.PitchDiameter; EndDiameter = StartDiameter - 2 * Depth * Math.Sin(Alpha); StartCone = Cone.Create(StartFrame, StartDiameter / 2, Math.PI / 2 - Alpha); EndCone = Cone.Create(EndFrame, EndDiameter / 2, Math.PI / 2 - Alpha); }
protected static ToothProfile GetGearProfileFromOptions(GearData gearData, GearData conjugateGearData, bool useTrochoidalInterferenceRemoval, bool addDedendumClearance, double screwAngle = 0) { ToothProfile toothProfile = null; if (addDedendumClearance) { if (useTrochoidalInterferenceRemoval) { toothProfile = new ExtendedTrochoidalToothProfile(gearData, conjugateGearData); } else { if (gearData.IsSmallDedendum) { toothProfile = new ExtendedToothProfile(gearData); } else { toothProfile = new BasicToothProfile(gearData); } } } else { if (useTrochoidalInterferenceRemoval) { toothProfile = new BasicTrochoidalToothProfile(gearData, conjugateGearData); } else { if (gearData.IsSmallDedendum) { toothProfile = new ExtendedToothProfile(gearData); } else { toothProfile = new BasicToothProfile(gearData); } } } return(toothProfile); }
public static Gear Create(IPart parent, GearData gearData, GearData conjugateGearData, ToothProfile toothProfile, double helicalAngle, double screwAngle, double depth) { Gear gear = new StraightGear(parent, gearData, conjugateGearData, toothProfile, helicalAngle, screwAngle, depth); BuildGear(gear); return gear; }
protected StraightGear(IPart parent, GearData gearData, GearData conjugateGearData, ToothProfile toothProfile, double helicalAngle, double screwAngle, double depth) : base(parent, gearData, conjugateGearData, toothProfile, helicalAngle, depth) { StartPoint = Point.Origin + Vector.Create(0, 0, Depth / 2); ; EndPoint = StartPoint + Vector.Create(0, 0, -Depth); StartFrame = Frame.Create(StartPoint, Direction.DirX, Direction.DirY); EndFrame = Frame.Create(EndPoint, StartFrame.DirX, -StartFrame.DirY); StartPlane = Plane.Create(StartFrame); EndPlane = Plane.Create(EndFrame); ScrewAngle = screwAngle; }
public static Gear Create(IPart parent, GearData gearData, GearData conjugateGearData, ToothProfile toothProfile, double helicalAngle, double hypoidAngle, double hypoidOffset, double hypoidKneeRatio, double depth) { Gear gear = new HypoidGear(parent, gearData, conjugateGearData, toothProfile, helicalAngle, hypoidAngle, hypoidOffset, hypoidKneeRatio, depth); BuildGear(gear); return gear; }
protected HypoidGear(IPart parent, GearData gearData, GearData conjugateGearData, ToothProfile toothProfile, double helicalAngle, double hypoidAngle, double hypoidOffset, double hypoidKneeRatio, double depth) : base(parent, gearData, conjugateGearData, toothProfile, helicalAngle, depth) { HypoidAngle = hypoidAngle; HypoidOffset = hypoidOffset; HypoidKneeRatio = hypoidKneeRatio; TangentLine = Line.Create(Point.Origin, Direction.DirZ).CreateTransformedCopy(TransformToTangent.Inverse); Debug.Assert(Accuracy.LengthIsZero(TangentLine.Origin.Y)); A = TangentLine.Origin.Vector.Magnitude; Point pointA = Point.Create(A, 0, 0); Point p0 = TangentLine.Origin; Point p1 = TangentLine.Evaluate(1).Point; p0 = Plane.PlaneYZ.ProjectPoint(p0).Point; p1 = Plane.PlaneYZ.ProjectPoint(p1).Point; B = A * (p1.Z - p0.Z) / (p1.Y - p0.Y); Depth = TangentLine.Evaluate(Depth).Point.Z; HypoidOffset = TangentLine.Evaluate(HypoidOffset).Point.Z; StartZ = HypoidOffset; EndZ = HypoidOffset + Depth; StartPoint = Point.Create(0, 0, StartZ); EndPoint = Point.Create(0, 0, EndZ); StartFrame = Frame.Create(StartPoint, Direction.DirX, -Direction.DirY); EndFrame = Frame.Create(EndPoint, Direction.DirX, -Direction.DirY); StartDiameter = GetHyperbolicRadius(StartZ) * 2; EndDiameter = GetHyperbolicRadius(EndZ) * 2; StartCone = GetConeAtParameter(StartZ); EndCone = GetConeAtParameter(EndZ); StartPlane = Plane.Create(StartFrame); EndPlane = Plane.Create(EndFrame); }
protected Gear(IPart parent, GearData gearData, GearData conjugateGearData, ToothProfile toothProfile, double helicalAngle, double depth) { Parent = parent; GearData = gearData; ConjugateGearData = conjugateGearData; ToothProfile = toothProfile; HelicalAngle = helicalAngle; Depth = depth; Period = ToothProfile.GetProfile(); Window activeWindow = Window.ActiveWindow; string name = String.Format(Resources.GearPartNameFormat, GearData.Pitch * activeWindow.Units.Length.ConversionFactor, activeWindow.Units.Length.Symbol, GearData.NumberOfTeeth, GearData.PressureAngle * 180 / Math.PI); Part = Part.Create(Parent.Master.Document, name); Component = Component.Create(parent.Master, Part); Component.Transform(parent.TransformToMaster); GearLayer = NoteHelper.CreateOrGetLayer(Part.Document, Resources.GearLayerName, System.Drawing.Color.LightSteelBlue); PitchCircleLayer = NoteHelper.CreateOrGetLayer(Part.Document, Resources.PitchCircleLayerName, System.Drawing.Color.SteelBlue); PitchCircleLayer.SetVisible(null, false); VisualizationLayer = NoteHelper.CreateOrGetLayer(Part.Document, Resources.VisualizationBodyLayerName, System.Drawing.Color.SteelBlue); AlignmentPart = Part.Create(Part.Document, Resources.AlignmentPlanePartName); AlignmentComponent = Component.Create(Part, AlignmentPart); AlignmentDesBodies = new List<DesignBody>(); AlignmentLayer = NoteHelper.CreateOrGetLayer(Part.Document, Resources.AlignmentPlaneLayerName, System.Drawing.Color.AliceBlue); AlignmentLayer.SetVisible(null, false); }
public static Gear Create(IPart parent, GearData gearData, GearData conjugateGearData, ToothProfile toothProfile, double helicalAngle, double bevelAngle, double bevelKneeRatio, double depth) { Gear gear = new BevelGear(parent, gearData, conjugateGearData, toothProfile, helicalAngle, bevelAngle, bevelKneeRatio, depth); BuildGear(gear); return gear; }
public static Gear Create(IPart parent, GearData gearData, GearData conjugateGearData, ToothProfile toothProfile, double helicalAngle, double hypoidAngle, double hypoidOffset, double hypoidKneeRatio, double depth) { Gear gear = new HypoidGear(parent, gearData, conjugateGearData, toothProfile, helicalAngle, hypoidAngle, hypoidOffset, hypoidKneeRatio, depth); BuildGear(gear); return(gear); }
public static Gear Create(IPart parent, GearData gearData, GearData conjugateGearData, ToothProfile toothProfile, double helicalAngle, double bevelAngle, double bevelKneeRatio, double depth) { Gear gear = new BevelGear(parent, gearData, conjugateGearData, toothProfile, helicalAngle, bevelAngle, bevelKneeRatio, depth); BuildGear(gear); return(gear); }
public static Gear Create(IPart parent, GearData gearData, GearData conjugateGearData, ToothProfile toothProfile, double helicalAngle, double screwAngle, double depth) { Gear gear = new StraightGear(parent, gearData, conjugateGearData, toothProfile, helicalAngle, screwAngle, depth); BuildGear(gear); return(gear); }
protected StraightGear(IPart parent, GearData gearData, GearData conjugateGearData, ToothProfile toothProfile, double helicalAngle, double screwAngle, double depth) : base(parent, gearData, conjugateGearData, toothProfile, helicalAngle, depth) { StartPoint = Point.Origin + Vector.Create(0, 0, Depth / 2);; EndPoint = StartPoint + Vector.Create(0, 0, -Depth); StartFrame = Frame.Create(StartPoint, Direction.DirX, Direction.DirY); EndFrame = Frame.Create(EndPoint, StartFrame.DirX, -StartFrame.DirY); StartPlane = Plane.Create(StartFrame); EndPlane = Plane.Create(EndFrame); ScrewAngle = screwAngle; }
protected override void OnExecute(Command command, ExecutionContext context, System.Drawing.Rectangle buttonRect) { double lengthConversion = ActiveWindow.Units.Length.ConversionFactor; int numberOfTeethL = (int)Values[Resources.NumberOfTeethLText].Value; int numberOfTeethR = (int)Values[Resources.NumberOfTeethRText].Value; bool isInternalL = numberOfTeethL < 0; bool isInternalR = numberOfTeethR < 0; numberOfTeethL = Math.Abs(numberOfTeethL); numberOfTeethR = Math.Abs(numberOfTeethR); double pressureAngle = Values[Resources.PressureAngleText].Value * Math.PI / 180; double module = Values[Resources.ModuleText].Value / lengthConversion; double dedendumClearance = Values[Resources.DedendumClearanceText].Value; double depth = Values[Resources.DepthText].Value / lengthConversion; bool useTrochoidalInterferenceRemoval = Booleans[Resources.UseTrochoidalText].Value; bool addDedendumClearance = Booleans[Resources.AddDedendumClearance].Value; if (!addDedendumClearance) { dedendumClearance = 0; } bool isBevel = RibbonBooleanGroupCapsule.BooleanGroupCapsules[Resources.IsBevelText].IsEnabledCommandBoolean.Value; double bevelAngle = RibbonBooleanGroupCapsule.BooleanGroupCapsules[Resources.IsBevelText].Values[Resources.BevelAngleText].Value * Math.PI / 180; double bevelKneeRatio = RibbonBooleanGroupCapsule.BooleanGroupCapsules[Resources.IsBevelText].Values[Resources.BevelKneeRatioText].Value; bool isHelical = RibbonBooleanGroupCapsule.BooleanGroupCapsules[Resources.IsHelicalText].IsEnabledCommandBoolean.Value; double helicalAngle = RibbonBooleanGroupCapsule.BooleanGroupCapsules[Resources.IsHelicalText].Values[Resources.HelicalAngleText].Value * Math.PI / 180; if (!isHelical) { helicalAngle = 0; } bool isScrew = RibbonBooleanGroupCapsule.BooleanGroupCapsules[Resources.IsScrewText].IsEnabledCommandBoolean.Value; double screwAngle = RibbonBooleanGroupCapsule.BooleanGroupCapsules[Resources.IsScrewText].Values[Resources.ScrewAngleText].Value * Math.PI / 180; double screwAngleOffset = RibbonBooleanGroupCapsule.BooleanGroupCapsules[Resources.IsScrewText].Values[Resources.ScrewAngleBiasText].Value * Math.PI / 180; if (!isScrew) { screwAngle = 0; screwAngleOffset = 0; } double screwAngleAverage = screwAngle / 2; double screwAngleL = screwAngleAverage + screwAngleOffset; double screwAngleR = screwAngleAverage - screwAngleOffset; bool isHypoid = RibbonBooleanGroupCapsule.BooleanGroupCapsules[Resources.IsHypoidText].IsEnabledCommandBoolean.Value; double hypoidAngle = RibbonBooleanGroupCapsule.BooleanGroupCapsules[Resources.IsHypoidText].Values[Resources.HypoidAngleText].Value * Math.PI / 180; double hypoidOffset = RibbonBooleanGroupCapsule.BooleanGroupCapsules[Resources.IsHypoidText].Values[Resources.HypoidOffsetText].Value / lengthConversion; if (!isHypoid) { hypoidAngle = 0; hypoidOffset = 0; } Frame frame = Frame.World; //Circle circle = SelectedCircle(ActiveWindow); //if (circle != null) // frame = circle.Frame; List <ITrimmedCurve> selectedCurves = ActiveWindow.GetAllSelectedITrimmedCurves().ToList(); if (selectedCurves.Count == 2 && selectedCurves[0].Geometry is Circle && selectedCurves[0].Geometry is Circle) { Circle circle0 = (Circle)selectedCurves[0].Geometry; Circle circle1 = (Circle)selectedCurves[1].Geometry; Separation separation = circle0.Axis.GetClosestSeparation(circle1.Axis); if (Accuracy.LengthIsZero(separation.Distance)) { throw new NotImplementedException("Distance between axes is zero; only hypoid implemented."); } isHypoid = true; hypoidAngle = AddInHelper.AngleBetween(circle0.Axis.Direction, circle1.Axis.Direction); hypoidOffset = ((circle0.Frame.Origin - separation.PointA).Magnitude - depth / 2) / Math.Cos(hypoidAngle / 2); double radiusAApprox = separation.Distance * circle0.Radius / (circle0.Radius + circle1.Radius); double radiusBApprox = separation.Distance - radiusAApprox; numberOfTeethR = (int)Math.Round((double)numberOfTeethL / radiusAApprox * radiusBApprox); module = radiusAApprox * 2 / numberOfTeethL; Point midpoint = separation.PointA + (separation.PointA - separation.PointB) * numberOfTeethL / numberOfTeethR; Direction sideSide = (circle0.Frame.Origin - circle1.Frame.Origin).Direction; frame = Frame.Create(midpoint, Direction.Cross(sideSide, -(midpoint - circle0.GetClosestSeparation(circle1).PointA).Direction), sideSide); } double hypoidAngleL = Math.Atan(Math.Sin(hypoidAngle) / (Math.Cos(hypoidAngle) + (double)numberOfTeethR / numberOfTeethL)); double hypoidAngleR = Math.Atan(Math.Sin(hypoidAngle) / (Math.Cos(hypoidAngle) + (double)numberOfTeethL / numberOfTeethR)); Gear gearL = null; Gear gearR = null; var gearDataL = new GearData(numberOfTeethL, pressureAngle, module, dedendumClearance, isInternalL, screwAngleL); var gearDataR = new GearData(numberOfTeethR, pressureAngle, module, dedendumClearance, isInternalR, screwAngleR); ToothProfile toothProfileL = GetGearProfileFromOptions(gearDataL, gearDataR, useTrochoidalInterferenceRemoval, addDedendumClearance); ToothProfile toothProfileR = GetGearProfileFromOptions(gearDataR, gearDataL, useTrochoidalInterferenceRemoval, addDedendumClearance); if (isBevel) { gearL = BevelGear.Create(ActiveIPart, gearDataL, gearDataR, toothProfileL, helicalAngle, bevelAngle, bevelKneeRatio, depth); gearR = BevelGear.Create(ActiveIPart, gearDataR, gearDataL, toothProfileR, -helicalAngle, bevelAngle, bevelKneeRatio, depth); } else if (isHypoid) { gearL = HypoidGear.Create(ActiveIPart, gearDataL, gearDataR, toothProfileL, helicalAngle, hypoidAngleL, hypoidOffset, bevelKneeRatio, depth); gearR = HypoidGear.Create(ActiveIPart, gearDataR, gearDataL, toothProfileR, -helicalAngle, hypoidAngleR, hypoidOffset, bevelKneeRatio, depth); } else { gearL = StraightGear.Create(ActiveIPart, gearDataL, gearDataR, toothProfileL, helicalAngle, screwAngleL, depth); gearR = StraightGear.Create(ActiveIPart, gearDataR, gearDataL, toothProfileR, -helicalAngle, screwAngleR, depth); } Line zAxis = Line.Create(Point.Origin, Direction.DirZ); gearL.Component.Transform( Matrix.CreateMapping(frame) * Matrix.CreateRotation(zAxis, Math.PI) * gearL.TransformToTangent * Matrix.CreateRotation(zAxis, gearDataL.PitchAngle * ((double)1 / 2 + (gearDataL.NumberOfTeeth % 2 == 0 && !isHypoid ? -1 : 0))) ); gearR.Component.Transform( Matrix.CreateMapping(frame) * gearR.TransformToTangent * Matrix.CreateRotation(zAxis, gearDataR.PitchAngle * ((double)1 / 2 + (gearDataR.NumberOfTeeth % 2 == 0 && !isHypoid ? -1 : 0))) ); // if (gearDataR.NumberOfTeeth % 2 == 0) // gearR.Component.Transform(Matrix.CreateRotation(Line.Create(Point.Origin, Direction.DirZ), gearDataR.PitchAngle)); //gearR.Component.Transform(gearR.TransformToTangent); Part parent = ActiveIPart.Master; IDesignFace pitchCircleL = gearL.Component.Content.Bodies.Where(b => b.Master == gearL.PitchCircleDesBody).First().Faces.First(); IDesignFace pitchCircleR = gearR.Component.Content.Bodies.Where(b => b.Master == gearR.PitchCircleDesBody).First().Faces.First(); Part gearMountPart = Part.Create(parent.Document, String.Format(Resources.GearMountPartName, gearDataL.NumberOfTeeth, gearDataR.NumberOfTeeth)); Component gearMountComponent = Component.Create(parent, gearMountPart); DesignBody mountBodyL = DesignBody.Create(gearMountPart, string.Format(Resources.MountBodyName, gearDataL.NumberOfTeeth), pitchCircleL.Master.Shape.Body.CreateTransformedCopy(pitchCircleL.TransformToMaster.Inverse)); DesignBody mountBodyR = DesignBody.Create(gearMountPart, string.Format(Resources.MountBodyName, gearDataR.NumberOfTeeth), pitchCircleR.Master.Shape.Body.CreateTransformedCopy(pitchCircleR.TransformToMaster.Inverse)); IDesignFace mountCircleL = gearMountComponent.Content.Bodies.Where(b => b.Master == mountBodyL).First().Faces.First(); IDesignFace mountCircleR = gearMountComponent.Content.Bodies.Where(b => b.Master == mountBodyR).First().Faces.First(); Layer mountLayer = NoteHelper.CreateOrGetLayer(ActiveDocument, Resources.GearMountAlignmentCircleLayer, System.Drawing.Color.LightGray); mountLayer.SetVisible(null, false); mountBodyL.Layer = mountLayer; mountBodyR.Layer = mountLayer; MatingCondition matingCondition; matingCondition = AnchorCondition.Create(parent, gearMountComponent); matingCondition = AlignCondition.Create(parent, mountCircleL, pitchCircleL); matingCondition = AlignCondition.Create(parent, mountCircleR, pitchCircleR); // matingCondition = TangentCondition.Create(parent, pitchCircleL, pitchCircleR); GearCondition gearCondition = GearCondition.Create(parent, pitchCircleL, pitchCircleR); if (gearDataL.IsInternal ^ gearDataR.IsInternal) { gearCondition.IsBelt = true; } ActiveWindow.InteractionMode = InteractionMode.Solid; Settings.Default.NumberOfTeethL = numberOfTeethL; Settings.Default.NumberOfTeethR = numberOfTeethR; Settings.Default.PressureAngleDegrees = pressureAngle * 180 / Math.PI; Settings.Default.Module = module; Settings.Default.Depth = depth; Settings.Default.DedendumClearance = dedendumClearance; Settings.Default.UseTrochoidalInterferenceRemoval = useTrochoidalInterferenceRemoval; Settings.Default.AddDedendumClearace = addDedendumClearance; Settings.Default.IsBevel = isBevel; if (isBevel) { Settings.Default.BevelAngle = bevelAngle * 180 / Math.PI; Settings.Default.BevelKneeRatio = bevelKneeRatio; } Settings.Default.IsHelical = isHelical; Settings.Default.HelicalAngle = helicalAngle * 180 / Math.PI; Settings.Default.IsScrew = isScrew; Settings.Default.ScrewAngle = screwAngle * 180 / Math.PI; Settings.Default.ScrewAngleOffset = screwAngleOffset * 180 / Math.PI; Settings.Default.IsHypoid = isHypoid; Settings.Default.HypoidAngle = hypoidAngle * 180 / Math.PI; Settings.Default.HypoidOffset = hypoidOffset * lengthConversion; Settings.Default.Save(); }