static public RadiusDimConstraint addRadius(SketchEntity ent, SketchPoint sp1, SketchPoint sp2, string name) { mp = u.midPt(sp1.Geometry, sp2.Geometry); val = ps.DimensionConstraints.AddRadius(ent, mp); addName <RadiusDimConstraint>(name, "R"); return(val as RadiusDimConstraint); }
public bool AddCell(SketchEntity cell, Rot4 sketchRot) { bool added = damagedCells.Add(cell.Normalize(sketchRot)); if (added) { this.parent.HitPoints -= DamageUnit; } return(added); }
static public bool cmpLen(ProfilePath pp, double b = 0.6) { SketchEntity se1 = (SketchEntity)((ProfileEntity)pp[1]).SketchEntity; SketchEntity se2 = (SketchEntity)((ProfileEntity)pp[2]).SketchEntity; if (ParamLen(se1) == b || ParamLen(se2) == b) { return(true); } return(false); }
public override bool SameForSubtracting(SketchEntity other) { if (!(other is SketchRoof sketchRoof)) { return(false); } if (sketchRoof == this) { return(true); } return(this.roof == sketchRoof.roof); }
public static SketchEntity Normalize(this SketchEntity se, Rot4 sketchRot) { SketchEntity entity = se.DeepCopy(); int newRot = Rot4.North.AsInt - sketchRot.AsInt; if (newRot < 0) { newRot += 4; } Rot4 rot1 = new Rot4(newRot); entity.pos = entity.pos.RotatedBy(rot1); return(entity); }
public SketchLine addLine() { cmd = (ps.Application as Inventor.Application).CommandManager; if (doc.SelectSet.Count != 0 && doc.SelectSet[1] is SketchLine) { return(doc.SelectSet[1] as SketchLine); } object ob = cmd.Pick(SelectionFilterEnum.kSketchCurveFilter, "Выберите грань для главного направления"); SketchEntity se = /*ps.AddByProjectingEntity*/ ob as SketchEntity; if (se is SketchLine) { return(se as SketchLine); } return(null); }
} //end of method InterpreteSketch private void InterpreteSketchEntity(SketchEntity sketchEntity) { String entityType = ""; if (sketchEntity is SketchPoint) { //sketchPoints are just optional? //skip it return; } if (sketchEntity is SketchLine) { //get multiple sketchLine's, put them in list, at end of sketch, interprete all sketchlines _needToInterpreteSketchLine = true; listOfSketchLines.Add((SketchLine)sketchEntity); return; } if (sketchEntity is SketchCircle) { entityType = "circle"; listOfCodeLines.Add(Exporter.ExportCircle((SketchCircle)sketchEntity, entityType + NumberOfSketchEntities)); } else if (sketchEntity is SketchArc) { entityType = "arc"; listOfCodeLines.Add(Exporter.ExportArc((SketchArc)sketchEntity, entityType + NumberOfSketchEntities)); } else if (sketchEntity is SketchEllipse) { entityType = "ellipse"; listOfCodeLines.Add(Exporter.ExportEllipseFull((SketchEllipse)sketchEntity, entityType + NumberOfSketchEntities)); } else if (sketchEntity is SketchEllipticalArc) { entityType = "ellipseArc"; listOfCodeLines.Add(Exporter.ExportEllipticalArc((SketchEllipticalArc)sketchEntity, entityType + NumberOfSketchEntities)); } listOfEntityNamesOfOneSketch.Add(entityType + NumberOfSketchEntities); NumberOfSketchEntities++; } //end of method InterpreteSketchEntity
static public double ParamLen(SketchEntity se) { double min, max, length; Curve2dEvaluator eval = null; if (se.Type == ObjectTypeEnum.kSketchLineObject || se.Type == ObjectTypeEnum.kSketchLineProxyObject) { eval = ((SketchLine)se).Geometry.Evaluator; } else if (se.Type == ObjectTypeEnum.kSketchArcObject || se.Type == ObjectTypeEnum.kSketchArcProxyObject) { eval = ((SketchArc)se).Geometry.Evaluator; } else if (se.Type == ObjectTypeEnum.kSketchSplineObject || se.Type == ObjectTypeEnum.kSketchSplineProxyObject) { eval = ((SketchSpline)se).Geometry.Evaluator; } eval.GetParamExtents(out min, out max); eval.GetLengthAtParam(min, max, out length); return(Math.Round(length, 2)); }
public PlanarSketch InsideRing() { PlanarSketch sketch = partCompDef.Sketches.Add(partCompDef.WorkPlanes[3]); SketchPoints points_ = sketch.SketchPoints; SketchArcs arcs_ = sketch.SketchArcs; SketchLines lines_ = sketch.SketchLines; points_.Add(transGeom.CreatePoint2d(0, d / 2)); points_.Add(transGeom.CreatePoint2d(B / 2 - r, d / 2)); points_.Add(transGeom.CreatePoint2d(B / 2 - r, d / 2 + r)); points_.Add(transGeom.CreatePoint2d(B / 2, d / 2 + r)); points_.Add(transGeom.CreatePoint2d(B / 2, d / 2 + r + 0.25 * d / 3)); points_.Add(transGeom.CreatePoint2d(B / 2 - 0.15 * B / 2, d / 2 + r + 0.40 * d / 3)); points_.Add(transGeom.CreatePoint2d(B / 2 - 0.4 * B / 2, d / 2 + r + 0.40 * d / 3)); points_.Add(transGeom.CreatePoint2d(0.2 * B / 2, d / 2 + r + 0.40 * d / 3)); points_.Add(transGeom.CreatePoint2d(0, d / 2 + r + 0.40 * d / 3)); points_.Add(transGeom.CreatePoint2d(Dw / 2, (D / 2 - d / 2) / 2 + d / 2)); lines_.AddByTwoPoints(points_[1], points_[2]); arcs_.AddByCenterStartEndPoint(points_[3], points_[2], points_[4], true); for (int i = 4; i < 7; i++) { lines_.AddByTwoPoints(points_[i], points_[i + 1]); } lines_.AddByTwoPoints(points_[8], points_[9]); lines_.AddByTwoPoints(points_[9], points_[1]); arcs_.AddByCenterStartEndPoint(points_[10], points_[7], points_[8], false); sketch.GeometricConstraints.AddGround(sketch.SketchEntities[10]); arcs_[2].StartSketchPoint.Merge(points_[8]); arcs_[2].CenterSketchPoint.Merge(points_[10]); for (int i = 1; i < 6; i++) { sketch.GeometricConstraints.AddGround(sketch.SketchEntities[i]); } SketchEntity entity = sketch.SketchEntities[19]; sketch.DimensionConstraints.AddRadius(entity, points_[1].Geometry); sketch.DimensionConstraints[1].Parameter.Value = Dw / 2; center_line = sketch.SketchLines.AddByTwoPoints(transGeom.CreatePoint2d(-1, 0), transGeom.CreatePoint2d(1, 0)); return(sketch); }
static public CoincidentConstraint addConsid(SketchEntity se1, SketchEntity se2) { return(ps.GeometricConstraints.AddCoincident(se1, se2)); }
static public PerpendicularConstraint addPerp(SketchEntity se1, SketchEntity se2) { return(ps.GeometricConstraints.AddPerpendicular(se1, se2)); }
static public TangentSketchConstraint addTangent(SketchEntity se1, SketchEntity se2) { return(ps.GeometricConstraints.AddTangent(se1, se2)); }
public bool CheckCell(SketchEntity cell, Rot4 sketchRot) { bool check = damagedCells.Contains(cell.Normalize(sketchRot)); return(check); }