public CutOp(Inventor.Document newDoc) { if (newDoc.DocumentType == DocumentTypeEnum.kAssemblyDocumentObject) { m_PartDoc = (PartDocument)newDoc.ActivatedObject; } if (newDoc.DocumentType == DocumentTypeEnum.kPartDocumentObject) { m_PartDoc = (PartDocument)newDoc; } if (m_PartDoc.SubType == "{9C464203-9BAE-11D3-8BAD-0060B0CE6BB4}") { smcd = (SheetMetalComponentDefinition)m_PartDoc.ComponentDefinition; } smf = (SheetMetalFeatures)smcd.Features; CutDefinition cd = smf.CutFeatures.CreateCutDefinition(selectFromSketch()); try { cd.SetCutAcrossBendsExtent("Толщина"); } catch (Exception) { cd.SetCutAcrossBendsExtent("Thickness"); } smf.CutFeatures.Add(cd); }
public static void createCutLavorazione(PartDocument oDoc, List <string> nomeSketch) { SheetMetalComponentDefinition oCompDef = (SheetMetalComponentDefinition)oDoc.ComponentDefinition; foreach (string nameS in nomeSketch) { try { PlanarSketch oSketch = oCompDef.Sketches[nameS]; SheetMetalFeatures oSheetMetalFeatures = (SheetMetalFeatures)oCompDef.Features; Profile oProfile = oSketch.Profiles.AddForSolid(); CutDefinition oCutDefinition = oSheetMetalFeatures.CutFeatures.CreateCutDefinition(oProfile); //oCutDefinition.SetThroughAllExtent(PartFeatureExtentDirectionEnum.kNegativeExtentDirection); CutFeature oCutFeature = oSheetMetalFeatures.CutFeatures.Add(oCutDefinition); } catch { throw new Exception("Nome sketch non esiste: " + nameS); } } }
static public void createCut(PlanarSketch ps) { SheetMetalFeatures smf = getSMF(); CutDefinition cd = smf.CutFeatures.CreateCutDefinition(ps.Profiles.AddForSolid(false)); try { cd.SetCutAcrossBendsExtent("Толщина"); } catch (Exception) { cd.SetCutAcrossBendsExtent("Thickness"); } smf.CutFeatures.Add(cd); }
static public CutFeature addCut(SheetMetalComponentDefinition smcd, string name) { SheetMetalFeatures smf = (SheetMetalFeatures)smcd.Features; PlanarSketch ps = smcd.Sketches[name]; CutDefinition cd = smf.CutFeatures.CreateCutDefinition(ps.Profiles.AddForSolid()); try { cd.SetCutAcrossBendsExtent("Толщина"); } catch (Exception) { cd.SetCutAcrossBendsExtent("Thickness"); } return(smf.CutFeatures.Add(cd)); }
private void offset(Profile profiles) { foreach (ProfilePath pr in profiles) { flag = cmpLen(pr); if (!flag) { b = Convert.ToDouble(this.textBox2.Text.Replace(',', separator)) / 10; } else { b = Convert.ToDouble(this.textBox3.Text.Replace(',', separator)) / 10; } if (pr.Count == 4) { ProfileEntity pe1 = (ProfileEntity)pr[1]; ProfileEntity pe3 = (ProfileEntity)pr[3]; if (pe1.SketchEntity.Type == ObjectTypeEnum.kSketchLineObject || pe1.SketchEntity.Type == ObjectTypeEnum.kSketchLineProxyObject) { ((SketchLine)pe1.SketchEntity).Construction = true; pt1 = ((SketchLine)pe1.SketchEntity).StartSketchPoint; pt3 = ((SketchLine)pe1.SketchEntity).EndSketchPoint; } else if (pe1.SketchEntity.Type == ObjectTypeEnum.kSketchArcObject || pe1.SketchEntity.Type == ObjectTypeEnum.kSketchArcProxyObject) { ((SketchArc)pe1.SketchEntity).Construction = true; pt1 = ((SketchArc)pe1.SketchEntity).StartSketchPoint; pt3 = ((SketchArc)pe1.SketchEntity).EndSketchPoint; } else if (pe1.SketchEntity.Type == ObjectTypeEnum.kSketchSplineObject || pe1.SketchEntity.Type == ObjectTypeEnum.kSketchSplineProxyObject) { ((SketchSpline)pe1.SketchEntity).Construction = true; pt1 = ((SketchSpline)pe1.SketchEntity).StartSketchPoint; pt3 = ((SketchSpline)pe1.SketchEntity).EndSketchPoint; } if (pe3.SketchEntity.Type == ObjectTypeEnum.kSketchLineObject || pe3.SketchEntity.Type == ObjectTypeEnum.kSketchLineProxyObject) { pt2 = ((SketchLine)pe3.SketchEntity).StartSketchPoint; if (pt2.Geometry.VectorTo(pt1.Geometry).Length < pt2.Geometry.VectorTo(pt3.Geometry).Length) { pt2 = ((SketchLine)pe3.SketchEntity).EndSketchPoint; } //pt3 = ((SketchLine)pe3.SketchEntity).Geometry.EndPoint; } else if (pe3.SketchEntity.Type == ObjectTypeEnum.kSketchArcObject || pe3.SketchEntity.Type == ObjectTypeEnum.kSketchArcProxyObject) { pt2 = ((SketchArc)pe3.SketchEntity).StartSketchPoint; if (pt2.Geometry.VectorTo(pt1.Geometry).Length < pt2.Geometry.VectorTo(pt3.Geometry).Length) { pt2 = ((SketchArc)pe3.SketchEntity).EndSketchPoint; } //pt3 = ((SketchArc)pe3.SketchEntity).Geometry.EndPoint; } else if (pe3.SketchEntity.Type == ObjectTypeEnum.kSketchSplineObject || pe3.SketchEntity.Type == ObjectTypeEnum.kSketchSplineProxyObject) { pt2 = ((SketchSpline)pe3.SketchEntity).StartSketchPoint; if (pt2.Geometry.VectorTo(pt1.Geometry).Length < pt2.Geometry.VectorTo(pt3.Geometry).Length) { pt2 = ((SketchSpline)pe3.SketchEntity).EndSketchPoint; } //pt3 = ((SketchSpline)pe3.SketchEntity).EndSketchPoint.Geometry; } //ps.Edit(); rect(pt1.Geometry, pt2.Geometry, pt3.Geometry); //ps.ExitEdit(); } } smf = (SheetMetalFeatures)smcd.Features; ps = smcd.Sketches[name]; CutDefinition cd = smf.CutFeatures.CreateCutDefinition(ps.Profiles.AddForSolid()); try { cd.SetCutAcrossBendsExtent("Толщина"); } catch (Exception) { cd.SetCutAcrossBendsExtent("Thickness"); } smf.CutFeatures.Add(cd); }
/// <inheritdoc/> internal override void Build(WorkspacePanel workspace, List <Speed4Dstep> speedPoints, ItemJoin incommingJoin) { if (_speedAlgorithm == SpeedAlgorithm.TowerBased || !UseExplicitKerf) { base.Build(workspace, speedPoints, incommingJoin); return; } if (incommingJoin.Item2 != this) { throw new NotSupportedException("Incomming join point is not valid."); } var cuttingSpeed = workspace.CuttingSpeed; var cutPoints = CutPoints.ToArray(); if (!cutPoints.First().Equals(cutPoints.Last())) { throw new NotSupportedException("Shape is not closed."); } var definitionPoints = CutDefinition.ToArray(); if (cutPoints.Count() != definitionPoints.Count()) { throw new NotSupportedException("Invalid cut points count."); } //skip the repetitive point so we can join to whatever shape part. cutPoints = cutPoints.Take(cutPoints.Length - 1).ToArray(); definitionPoints.Take(definitionPoints.Length - 1).ToArray(); var projector = new PlaneProjector(_shapeMetricThickness, _wireLength); var outJoins = workspace.FindOutgoingJoins(this); var startIndex = incommingJoin.JoinPointIndex2; for (var i = startIndex + 1; i <= startIndex + cutPoints.Length; ++i) { var currentIndex = i % cutPoints.Length; var currentPoint = cutPoints[currentIndex]; var speeds = getSpeeds(definitionPoints, currentIndex, cuttingSpeed, projector); //System.Diagnostics.Debug.Print(speeds.ToString()); var speed1Limit = speeds.Item1.ToDeltaT() >= Constants.StartDeltaT || speeds.Item1.ToDeltaT() < 0; var speed2Limit = speeds.Item2.ToDeltaT() >= Constants.StartDeltaT || speeds.Item2.ToDeltaT() < 0; if (!speed1Limit || !speed2Limit) { throw new PlanningException("Speed limit exceeded"); } speedPoints.Add(currentPoint.With(speeds.Item1, speeds.Item2)); var currentOutgoingJoins = workspace.GetOutgoingJoinsFrom(currentIndex, outJoins); foreach (var currentOutgoingJoin in currentOutgoingJoins) { currentOutgoingJoin.Build(workspace, speedPoints); } } }