//-------------------------------------------------------------------------------------------------- bool _MakeSketch(IShapeOperand sourceShape) { var sourceBRep = GetOperandBRep(0); if (sourceBRep == null) { return(false); } // Calculate Parameters var center = new Pnt2d(-_Radius, 0).Rotated(Pnt2d.Origin, _OriginalAngle.ToRad()); var(interval, offset) = _CalculateParameters(); // Build Transforms List <Trsf2d> transforms = new List <Trsf2d>((int)_Quantity); for (var index = 0; index < _Quantity; index++) { var angle = (interval * index + offset).ToRad(); var transform = Trsf2d.Identity; if (_KeepOrientation) { // Translation transform transform.SetTranslation(Pnt2d.Origin.Rotated(center, angle).ToVec()); } else { // Rotation transform transform.SetRotation(center, angle); } transforms.Add(transform); } // Do it! var resultShape = Topo2dUtils.TransformSketchShape(sourceBRep, transforms, false); if (resultShape == null) { return(false); } // Finalize BRep = resultShape; return(true); }
//-------------------------------------------------------------------------------------------------- bool _MakeSketch(IShapeOperand sourceShape) { var sourceBRep = GetOperandBRep(0); if (sourceBRep == null) { return(false); } // Calculate Offsets var extents = sourceBRep.BoundingBox().Extents(); var interval1 = new Vec2d(_CalculateOffset(DistanceMode1, Quantity1, Distance1, extents.X), 0); interval1.Rotate(_Rotation.ToRad()); var offset = Vec2d.Zero; switch (_Alignment1) { case AlignmentMode.Center: offset += interval1 * (Quantity1 - 1) * -0.5; break; case AlignmentMode.Last: interval1 *= -1; break; } var interval2 = new Vec2d(0, _CalculateOffset(DistanceMode2, Quantity2, Distance2, extents.Y)); interval2.Rotate(_Rotation.ToRad()); switch (_Alignment2) { case AlignmentMode.Center: offset += interval2 * (Quantity2 - 1) * -0.5; break; case AlignmentMode.Last: interval2 *= -1; break; } // Build Transforms List <Trsf2d> transforms = new List <Trsf2d>((int)(Quantity1 * Quantity2)); for (var index1 = 0; index1 < Quantity1; index1++) { for (var index2 = 0; index2 < Quantity2; index2++) { if (_Border && index1 != 0 && index1 != Quantity1 - 1 && index2 != 0 && index2 != Quantity2 - 1) { continue; // Skip inner parts } var transform = new Trsf2d(); transform.SetTranslation(interval1 * index1 + interval2 * index2 + offset); transforms.Add(transform); } } // Do it! var resultShape = Topo2dUtils.TransformSketchShape(sourceBRep, transforms, false); if (resultShape == null) { return(false); } // Finalize BRep = resultShape; return(true); }