Message 1 of 1
Flat Pattern Editing Enigma: Pattern Out of Location
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I'm trying to add a simple cut to the end of a break line to indicate to the shop where the break line should be located. As you can see from the pic's, it's not always consistent. The issue seems to arise on all parts where a relief is present. As the code and pic's show, the bend line is projected onto the sketch, but sometimes the bend line start/end points are placed randomly out in space. Any ideas?
Thank you,
Eric...
private void _addCircleTickMarksToFlatPattern(PartDocument _prtDoc, SheetMetalComponentDefinition _compDef, double _radius = 0.635) { // Set a reference to the flat pattern FlatPattern _flatPattern = _compDef.FlatPattern; // Set a reference to a new sketch. PlanarSketch _sketch; try { _sketch = _flatPattern.Sketches.Add(_flatPattern.TopFace); } catch (Exception) { return; } // Set a reference to a collection of bend up/down and tangent edges. Edges _bendUp = _flatPattern.GetEdgesOfType(FlatPatternEdgeTypeEnum.kBendUpFlatPatternEdge); Edges _bendDwn = _flatPattern.GetEdgesOfType(FlatPatternEdgeTypeEnum.kBendDownFlatPatternEdge); // Set a reference to the application transient geometry. TransientGeometry _tg = Application.TransientGeometry; // Collect all bend edges. List<Edge> _bendEdgeList = new List<Edge>(); foreach (Edge _edge in _bendUp) _bendEdgeList.Add(_edge); foreach (Edge _edge in _bendDwn) _bendEdgeList.Add(_edge); // Set a reference to a transaction ID int _transID = 0; // B/c sometimes the sketch won't be updated with new lines, we need a reference // to a changed status flag that denotes when the feature should be created. bool _createCut = false; foreach (Edge _bendEdge in _bendEdgeList) { // Project the bend edge onto the sketch. _sketch.AddByProjectingEntity(_bendEdge); // Set a reference to the bend start/end points. Point2d _bendStartPt2D = _tg.CreatePoint2d(_bendEdge.StartVertex.Point.X, _bendEdge.StartVertex.Point.Y); Point2d _bendEndPt2D = _tg.CreatePoint2d(_bendEdge.StopVertex.Point.X, _bendEdge.StopVertex.Point.Y); // Set a reference to a collection of sketch objects. List<SketchCircle> _sketchCircles = new List<SketchCircle>(); List<SketchPoint> _sketchPoints = new List<SketchPoint>(); _sketchPoints.Add(_sketch.SketchPoints.Add(_bendStartPt2D)); _sketchPoints.Add(_sketch.SketchPoints.Add(_bendEndPt2D)); // Set a reference to the transaction manager. Transaction _transaction; if (_sketchPoints.Count >= 2) { // Start a new transaction. _transaction = _app.Master.Application.TransactionManager.StartTransaction((_Document)_prtDoc, $"Create Circle: {++_transID}"); // Create a circle of connected points. _sketchCircles.Add(_sketch.SketchCircles.AddByCenterRadius(_sketchPoints[0], _radius)); _sketchCircles.Add(_sketch.SketchCircles.AddByCenterRadius(_sketchPoints[1], _radius)); // Finish the transaction. _transaction.End(); _createCut = true; } } if (_createCut) { // Set a reference to a profile object. Profile _profile = _sketch.Profiles.AddForSolid(); // Set a reference to the cut definition. CutDefinition _cutDef = _flatPattern.Features.CutFeatures.CreateCutDefinition(_profile); _cutDef.SetThroughAllExtent(PartFeatureExtentDirectionEnum.kNegativeExtentDirection); // Add the cut feature. CutFeature _cutFea = _flatPattern.Features.CutFeatures.Add(_cutDef); _cutFea.Name = "Cut: Tick Marks"; } else _sketch.Delete(); }
This one is correct
This one is wrong.