private Inventor.ExtrudeFeature CreateFlangeExtrustion(ref Inventor.PartDocument PartDocument, string FlangeDiaOD, string FlangeDiaID, string FlangeThickness) { Inventor.UnitsOfMeasure UnitsOfMeasure; Inventor.PlanarSketch Sketch; Inventor.TransientGeometry TransientGeometry; Inventor.SketchCircle SketchCircle; Inventor.WorkPoint WorkPoint; Inventor.WorkPlane BaseWorkPlane; Inventor.RadiusDimConstraint RadiusDimConstraint = null; Inventor.SketchEntity SketchEntity; Inventor.ObjectCollection SketchObjectCollection; Inventor.Profile Profile; Inventor.ExtrudeDefinition ExtrudeDefinition; Inventor.ExtrudeFeature ExtrudeFeature = null; SketchObjectCollection = InvApp.TransientObjects.CreateObjectCollection(); UnitsOfMeasure = PartDocument.UnitsOfMeasure; double DiaOD = 0, DiaID = 0, Thickness = 0; DiaOD = UnitsOfMeasure.GetValueFromExpression(FlangeDiaOD, Inventor.UnitsTypeEnum.kMillimeterLengthUnits); DiaID = UnitsOfMeasure.GetValueFromExpression(FlangeDiaID, Inventor.UnitsTypeEnum.kMillimeterLengthUnits); Thickness = UnitsOfMeasure.GetValueFromExpression(FlangeThickness, Inventor.UnitsTypeEnum.kMillimeterLengthUnits); TransientGeometry = InvApp.TransientGeometry; WorkPoint = PartDocument.ComponentDefinition.WorkPoints[1]; BaseWorkPlane = GetPartDocumentWorkPlane(ref PartDocument, "XY"); Sketch = PartDocument.ComponentDefinition.Sketches.Add(BaseWorkPlane, false); SketchEntity = Sketch.AddByProjectingEntity(WorkPoint); SketchCircle = Sketch.SketchCircles.AddByCenterRadius(TransientGeometry.CreatePoint2d(0, 0), DiaOD / 2); RadiusDimConstraint = Sketch.DimensionConstraints.AddRadius((Inventor.SketchEntity)SketchCircle, TransientGeometry.CreatePoint2d(0, 0), false); Sketch.GeometricConstraints.AddCoincident(SketchEntity, (Inventor.SketchEntity)SketchCircle.CenterSketchPoint); RadiusDimConstraint = null; SketchCircle = null; SketchCircle = Sketch.SketchCircles.AddByCenterRadius(TransientGeometry.CreatePoint2d(0, 0), DiaID / 2); RadiusDimConstraint = Sketch.DimensionConstraints.AddRadius((Inventor.SketchEntity)SketchCircle, TransientGeometry.CreatePoint2d(0, 0), false); Sketch.GeometricConstraints.AddCoincident(SketchEntity, (Inventor.SketchEntity)SketchCircle.CenterSketchPoint); SketchObjectCollection.Add(SketchCircle); Profile = Sketch.Profiles.AddForSolid(true, SketchObjectCollection); ExtrudeDefinition = PartDocument.ComponentDefinition.Features.ExtrudeFeatures.CreateExtrudeDefinition(Profile, Inventor.PartFeatureOperationEnum.kNewBodyOperation); ExtrudeDefinition.SetDistanceExtent(Thickness, Inventor.PartFeatureExtentDirectionEnum.kPositiveExtentDirection); ExtrudeFeature = PartDocument.ComponentDefinition.Features.ExtrudeFeatures.Add(ExtrudeDefinition); ExtrudeFeature.Name = "FlangeBase"; return(ExtrudeFeature); }
private Inventor.ExtrudeFeature Extrude_FlangeBody(ref Inventor.PartDocument PartDocument) { Inventor.TransientGeometry TransientGeometry; Inventor.SketchCircle SketchCircle; Inventor.RadiusDimConstraint RadiusDimConstraint = null; Inventor.Profile SketchProfile; Inventor.ExtrudeDefinition ExtrudeDefinition; Inventor.ExtrudeFeature ExtrudeFeature = null; Inventor.PlanarSketch Sketch; Inventor.SketchEntity SketchEntity; PartDocument = AddSketchProjectCenterPoint(PartDocument, out Sketch, out SketchEntity); TransientGeometry = InvApp.TransientGeometry; SketchCircle = Sketch.SketchCircles.AddByCenterRadius(TransientGeometry.CreatePoint2d(0, 0), FlangeDiaOD / 2); RadiusDimConstraint = Sketch.DimensionConstraints.AddRadius((Inventor.SketchEntity)SketchCircle, TransientGeometry.CreatePoint2d(0, 0), false); Sketch.GeometricConstraints.AddCoincident(SketchEntity, (Inventor.SketchEntity)SketchCircle.CenterSketchPoint); RadiusDimConstraint = null; SketchCircle = null; Inventor.ObjectCollection SketchObjectCollection; SketchObjectCollection = InvApp.TransientObjects.CreateObjectCollection(); SketchCircle = Sketch.SketchCircles.AddByCenterRadius(TransientGeometry.CreatePoint2d(0, 0), FlangeDiaID / 2); RadiusDimConstraint = Sketch.DimensionConstraints.AddRadius((Inventor.SketchEntity)SketchCircle, TransientGeometry.CreatePoint2d(0, 0), false); Sketch.GeometricConstraints.AddCoincident(SketchEntity, (Inventor.SketchEntity)SketchCircle.CenterSketchPoint); SketchObjectCollection.Add(SketchCircle); SketchProfile = Sketch.Profiles.AddForSolid(true, SketchObjectCollection); ExtrudeDefinition = PartDocument.ComponentDefinition.Features.ExtrudeFeatures.CreateExtrudeDefinition(SketchProfile, Inventor.PartFeatureOperationEnum.kNewBodyOperation); ExtrudeDefinition.SetDistanceExtent(FlangeThickness, Inventor.PartFeatureExtentDirectionEnum.kPositiveExtentDirection); //Extrude The Sketch Profile ExtrudeFeature = PartDocument.ComponentDefinition.Features.ExtrudeFeatures.Add(ExtrudeDefinition); ExtrudeFeature.Name = "FlangeBody"; return(ExtrudeFeature); }
public Inventor.ExtrudeFeature Extrude_FlangeBody() { Inventor.TransientGeometry TransientGeometry; Inventor.SketchCircle SketchCircle; Inventor.RadiusDimConstraint RadiusDiamension = null; Inventor.Profile SketchProfile; Inventor.ExtrudeDefinition ExtrudeDefinition; Inventor.ExtrudeFeature ExtrudeFeature = null; Inventor.PlanarSketch Sketch; Inventor.SketchEntity SketchEntity; //Create Sketch on wp project 0,0,0 work point Geometry PartDocument = AddSketchProjectCenterPoint(PartDocument, out Sketch, out SketchEntity); //Get the Transient Geometry Object from Inventor TransientGeometry = InvApp.TransientGeometry; //Draw Outside Hole DrawCircle_Constrain_Diamension(TransientGeometry.CreatePoint2d(0, 0), out SketchCircle, out RadiusDiamension, Sketch, SketchEntity, FlangeDiaOD / 2); RadiusDiamension = null; // reset for next use SketchCircle = null; Inventor.ObjectCollection SketchObjectCollection; SketchObjectCollection = InvApp.TransientObjects.CreateObjectCollection(); //Draw Inside Hole Add to sketch objects DrawCircle_Constrain_Diamension(TransientGeometry.CreatePoint2d(0, 0), out SketchCircle, out RadiusDiamension, Sketch, SketchEntity, FlangeDiaID / 2); //Add to sketch Collection ready for Extrude SketchObjectCollection.Add(SketchCircle); //Convert to profileing SketchProfile = Sketch.Profiles.AddForSolid(true, SketchObjectCollection); ExtrudeDefinition = PartDocument.ComponentDefinition.Features.ExtrudeFeatures.CreateExtrudeDefinition(SketchProfile, Inventor.PartFeatureOperationEnum.kNewBodyOperation); ExtrudeDefinition.SetDistanceExtent(FlangeThickness, Inventor.PartFeatureExtentDirectionEnum.kPositiveExtentDirection); //Extrude The Sketch Profile ExtrudeFeature = PartDocument.ComponentDefinition.Features.ExtrudeFeatures.Add(ExtrudeDefinition); ExtrudeFeature.Name = "FlangeBody"; return(ExtrudeFeature); }