private void BuildOuterSections(ShaftSection testBoreSection) { var outerSections = testBoreSection.GetOuterSections().ToList(); this.TestShaftLength = outerSections.Sum(section => section.Length); bool leftBore = testBoreSection.BoreFromEdge == BoreFromEdge.FromLeft; var sketch = this.ComponentDefinition.Sketches.Add(this.ComponentDefinition.WorkPlanes[3]); sketch.NaturalAxisDirection = true; var sketchLines = sketch.SketchLines; sketchLines.AddByTwoPoints( this.TransientGeometry.CreatePoint2d(outerSections.First().SecondLine.StartPoint.X.InMillimeters()), this.TransientGeometry.CreatePoint2d(outerSections.Last().SecondLine.EndPoint.X.InMillimeters())); for (var index = 0; index < outerSections.Count; index++) { var outerSection = outerSections[index]; if (outerSection.Equals(outerSections.First())) { Point2d firstPoint = this.TransientGeometry.CreatePoint2d( outerSection.SecondLine.StartPoint.X.InMillimeters()); Point2d secondPoint = this.TransientGeometry.CreatePoint2d(outerSection.SecondLine.StartPoint.X.InMillimeters(), outerSection.SecondLine.StartPoint.Y.InMillimeters()); sketchLines.AddByTwoPoints(firstPoint, secondPoint); } var secondLineParams = outerSection.SecondLine; sketchLines.AddByTwoPoints( this.TransientGeometry.CreatePoint2d(secondLineParams.StartPoint.X.InMillimeters(), secondLineParams.StartPoint.Y.InMillimeters()), this.TransientGeometry.CreatePoint2d(secondLineParams.EndPoint.X.InMillimeters(), secondLineParams.EndPoint.Y.InMillimeters())); if (outerSection.Equals(outerSections.Last())) { sketchLines.AddByTwoPoints( this.TransientGeometry.CreatePoint2d(outerSection.SecondLine.EndPoint.X.InMillimeters(), outerSection.SecondLine.EndPoint.Y.InMillimeters()), this.TransientGeometry.CreatePoint2d(outerSection.SecondLine.EndPoint.X.InMillimeters())); } } sketchLines[1].StartSketchPoint.Merge(sketchLines[2].StartSketchPoint); for (int i = 2; i < sketchLines.Count; i++) { sketchLines[i].EndSketchPoint.Merge(sketchLines[i + 1].StartSketchPoint); } sketchLines[1].EndSketchPoint.Merge(sketchLines[sketchLines.Count].EndSketchPoint); var profile = sketch.Profiles.AddForSolid(); var revolveFeature = this.ComponentDefinition.Features.RevolveFeatures.AddFull(profile, this.ComponentDefinition.WorkAxes[1], PartFeatureOperationEnum.kJoinOperation); }
public override void InitializeInAccordanceWithSectionParameters( ShaftSection section, EdgeFeaturePosition?edgeFeaturePosition = null) { base.InitializeInAccordanceWithSectionParameters(section, edgeFeaturePosition); var cylinderSection = (CylinderSection)section; var neededDimensions = CalculateReliefDimensions(cylinderSection.Diameter); this.Width1 = neededDimensions.Width1; }
private void BuildTestCone(ShaftSection coneSection) { var sketch = this.ComponentDefinition.Sketches.Add(this.ComponentDefinition.WorkPlanes[3]); var line1 = sketch.SketchLines.AddByTwoPoints(this.TransientGeometry.CreatePoint2d(), this.TransientGeometry.CreatePoint2d( coneSection.SecondLine.StartPoint.X.InMillimeters(), coneSection.SecondLine.StartPoint.Y.InMillimeters())); var line2 = sketch.SketchLines.AddByTwoPoints( this.TransientGeometry.CreatePoint2d( coneSection.SecondLine.StartPoint.X.InMillimeters(), coneSection.SecondLine.StartPoint.Y.InMillimeters()), this.TransientGeometry.CreatePoint2d( coneSection.SecondLine.EndPoint.X.InMillimeters(), coneSection.SecondLine.EndPoint.Y.InMillimeters())); var line3 = sketch.SketchLines.AddByTwoPoints( this.TransientGeometry.CreatePoint2d( coneSection.SecondLine.EndPoint.X.InMillimeters(), coneSection.SecondLine.EndPoint.Y.InMillimeters()), this.TransientGeometry.CreatePoint2d( coneSection.SecondLine.EndPoint.X.InMillimeters())); var line4 = sketch.SketchLines.AddByTwoPoints( this.TransientGeometry.CreatePoint2d(line3.EndSketchPoint.Geometry.X, line3.EndSketchPoint.Geometry.Y), this.TransientGeometry.CreatePoint2d()); line1.EndSketchPoint.Merge(line2.StartSketchPoint); line2.EndSketchPoint.Merge(line3.StartSketchPoint); line3.EndSketchPoint.Merge(line4.StartSketchPoint); line4.EndSketchPoint.Merge(line1.StartSketchPoint); var profile = sketch.Profiles.AddForSolid(); var revolveFeature = this.ComponentDefinition.Features.RevolveFeatures.AddFull(profile, line4, PartFeatureOperationEnum.kNewBodyOperation); var body = revolveFeature.SurfaceBody; var filletEdge = body.LocateUsingPoint(ObjectTypeEnum.kEdgeObject, this.TransientGeometry.CreatePoint( this.EdgeFeature.EdgePoint.X.InMillimeters(), this.EdgeFeature.EdgePoint.Y.InMillimeters()), 0.01); this.EdgeCollection.Add(filletEdge); }
private void TranslateNext(ItemsControl itemsControl, ShaftSection currentSection) { var paths = itemsControl.FindChildren <Path>()?.ToList(); Path nextPath = paths?.SingleOrDefault(path => currentSection.NextSection?.Equals((ShaftSection)path.DataContext) ?? false); if (nextPath == null) { return; } float offset = currentSection.Length / 2; while (nextPath != null) { var nextPathSection = (ShaftSection)nextPath.DataContext; nextPath.Data.Transform = new TranslateTransform(offset, 0); nextPath = paths.SingleOrDefault(path => nextPathSection.NextSection?.Equals((ShaftSection)path.DataContext) ?? false); offset += nextPathSection.Length / 2; } }
private void TranslatePrevious(ItemsControl itemsControl, ShaftSection currentSection) { var paths = itemsControl.FindChildren <Path>()?.ToList(); Path previousPath = paths?.SingleOrDefault(path => currentSection.PreviousSection?.Equals((ShaftSection)path.DataContext) ?? false); if (previousPath == null) { return; } float offset = -currentSection.Length / 2; while (previousPath != null) { var previousPathSection = (ShaftSection)previousPath.DataContext; previousPath.Data.Transform = new TranslateTransform(offset, 0); previousPath = paths.SingleOrDefault(path => previousPathSection.PreviousSection?.Equals((ShaftSection)path.DataContext) ?? false); offset -= previousPathSection.Length / 2; } }
protected override void OnAttached() { ShaftSection shaftSection = (ShaftSection)this.AssociatedObject.DataContext; shaftSection.PropertyChanged += (sender, args) => { if (args.PropertyName != nameof(ShaftSection.FirstEdgeFeatureHasErrors) && args.PropertyName != nameof(ShaftSection.SecondEdgeFeatureHasErrors)) { return; } var sectionSender = (ShaftSection)sender; if (sectionSender.FirstEdgeFeatureHasErrors || sectionSender.SecondEdgeFeatureHasErrors) { this.oldBackground = this.AssociatedObject.Background; this.AssociatedObject.Background = new BrushConverter().ConvertFrom("#fdadad") as SolidColorBrush; } else { this.AssociatedObject.Background = this.oldBackground; } }; }
public static void SetSection(UIElement element, ShaftSection value) { element.SetValue(SectionProperty, value); }
private void BuildTestBoreSection(ShaftSection testBoreSection) { bool fromLeft = this.BoreFromEdge == BoreFromEdge.FromLeft; PlanarSketch sketch = this.ComponentDefinition.Sketches.Add(this.ComponentDefinition.WorkPlanes[3]); sketch.NaturalAxisDirection = true; var sketchLines = sketch.SketchLines; sketchLines.AddByTwoPoints( this.TransientGeometry.CreatePoint2d(fromLeft ? testBoreSection.SecondLine.StartPoint.X.InMillimeters() : (this.TestShaftLength - testBoreSection.SecondLine.StartPoint.X).InMillimeters()), this.TransientGeometry.CreatePoint2d(fromLeft ? testBoreSection.SecondLine.EndPoint.X.InMillimeters() : (this.TestShaftLength - testBoreSection.SecondLine.EndPoint.X).InMillimeters())); var line1 = sketch.SketchLines.AddByTwoPoints( this.TransientGeometry.CreatePoint2d(fromLeft ? testBoreSection.SecondLine.StartPoint.X.InMillimeters() : (this.TestShaftLength - testBoreSection.SecondLine.StartPoint.X) .InMillimeters()), this.TransientGeometry.CreatePoint2d( fromLeft ? testBoreSection.SecondLine.StartPoint.X.InMillimeters() : (this.TestShaftLength - testBoreSection.SecondLine.StartPoint.X) .InMillimeters(), testBoreSection.SecondLine.StartPoint.Y.InMillimeters())); var line2 = sketch.SketchLines.AddByTwoPoints( this.TransientGeometry.CreatePoint2d( fromLeft ? testBoreSection.SecondLine.StartPoint.X.InMillimeters() : (this.TestShaftLength - testBoreSection.SecondLine.StartPoint.X) .InMillimeters(), testBoreSection.SecondLine.StartPoint.Y.InMillimeters()), this.TransientGeometry.CreatePoint2d( fromLeft ? testBoreSection.SecondLine.EndPoint.X.InMillimeters() : (this.TestShaftLength - testBoreSection.SecondLine.EndPoint.X) .InMillimeters(), testBoreSection.SecondLine.EndPoint.Y.InMillimeters())); var line3 = sketch.SketchLines.AddByTwoPoints( this.TransientGeometry.CreatePoint2d( fromLeft ? testBoreSection.SecondLine.EndPoint.X.InMillimeters() : (this.TestShaftLength - testBoreSection.SecondLine.EndPoint.X) .InMillimeters(), testBoreSection.SecondLine.EndPoint.Y.InMillimeters()), this.TransientGeometry.CreatePoint2d(fromLeft ? testBoreSection .SecondLine.EndPoint.X.InMillimeters() : (this.TestShaftLength - testBoreSection.SecondLine.EndPoint.X).InMillimeters())); var line4 = sketch.SketchLines.AddByTwoPoints( this.TransientGeometry.CreatePoint2d(line3.EndSketchPoint.Geometry.X, line3.EndSketchPoint.Geometry.Y), line1.StartSketchPoint.Geometry); line1.EndSketchPoint.Merge(line2.StartSketchPoint); line2.EndSketchPoint.Merge(line3.StartSketchPoint); line3.EndSketchPoint.Merge(line4.StartSketchPoint); line4.EndSketchPoint.Merge(line1.StartSketchPoint); var profile = sketch.Profiles.AddForSolid(); var revolveFeature = this.ComponentDefinition.Features.RevolveFeatures.AddFull(profile, line4, PartFeatureOperationEnum.kCutOperation); }
private void BuildTestSections(ShaftSection testBoreSection) { BuildOuterSections(testBoreSection); BuildTestBoreSection(testBoreSection); }