예제 #1
0
        private void Bolt_HolePatternFeature(ref Inventor.PartDocument PartDocument, ref Inventor.ExtrudeFeature ExtrudeFeature, Inventor.ObjectCollection ObjectCollection, string HoleDia, string HoleNumber)
        {
            Inventor.ObjectCollection HoleObjectCollection = null;
            Inventor.HoleFeature      HoleFeature;
            Inventor.SketchHolePlacementDefinition SketchHolePlacementDefinition;

            HoleObjectCollection          = InvApp.TransientObjects.CreateObjectCollection();
            SketchHolePlacementDefinition = PartDocument.ComponentDefinition.Features.HoleFeatures.CreateSketchPlacementDefinition(ObjectCollection);
            HoleFeature = PartDocument.ComponentDefinition.Features.HoleFeatures.AddDrilledByThroughAllExtent(SketchHolePlacementDefinition, FlangeBoltHoleDia, Inventor.PartFeatureExtentDirectionEnum.kPositiveExtentDirection);
            HoleObjectCollection.Add(HoleFeature);
            PartDocument.ComponentDefinition.Features.CircularPatternFeatures.Add(HoleObjectCollection, GetWorkAxis(ref PartDocument, "Z"), false, FlangeNumberBoltHoles, "360", true, Inventor.PatternComputeTypeEnum.kOptimizedCompute);
        }
예제 #2
0
 public void ModelMake(ref Inventor.Application InvInterface)
 {
     InvApp = InvInterface;
     Inventor.PartDocument     FlangePartDocument = null;
     Inventor.ExtrudeFeature   ExtrudeFeature     = null;
     Inventor.ObjectCollection ObjectCollection   = null;
     FlangePartDocument = (Inventor.PartDocument)InvApp.ActiveDocument;
     FlangePartDocument = CreateNewPartDocument();
     ExtrudeFeature     = CreateFlangeExtrustion(ref FlangePartDocument, szFlangeDiaOD, szFlangeDiaID, szThickness);
     Changeview();
     ObjectCollection = CreateHoleSketch(ref FlangePartDocument, ref ExtrudeFeature, "160", "30");
     CreateHoleFeatureFromSketch(ref FlangePartDocument, ref ExtrudeFeature, ObjectCollection, "18", "8");
     AddFlangeiMateDefinitions(ref FlangePartDocument, szFlangeDiaID, "E", "0");
     SavePartFile(ref FlangePartDocument);
 }
예제 #3
0
        public void HideOrShowGroup(ref Inventor.AssemblyDocument m_AssemblyDocument, bool hide, String GroupName, String GroupNumber)
        {
            try
            {
                Inventor.AttributeManager attbMan = m_AssemblyDocument.AttributeManager;

                Inventor.ObjectCollection objCol = default(Inventor.ObjectCollection);
                objCol = attbMan.FindObjects(GroupName, GroupName + "A", "G");

                Inventor.ComponentOccurrence componentoccurrence = default(Inventor.ComponentOccurrence);
                int length = objCol.Count;
                for (int i = 1; i <= length; i++)
                {
                    componentoccurrence         = (Inventor.ComponentOccurrence)objCol[i];
                    componentoccurrence.Visible = hide;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Problem hiding component");
            }
        }
예제 #4
0
        private Inventor.ObjectCollection CreateHoleSketch(ref Inventor.PartDocument PartDocument, ref Inventor.ExtrudeFeature ExtrudeFeature, string PCD, string PCDAngle)
        {
            Inventor.UnitsOfMeasure            UnitsOfMeasure;
            Inventor.PlanarSketch              Sketch    = null;
            Inventor.WorkPoint                 WorkPoint = null;
            Inventor.SketchEntity              CenterPointSketchEntity = null;
            Inventor.SketchArc                 pcdSketchArc            = null;
            Inventor.SketchLine                AngleSketchLine         = null;
            Inventor.SketchLine                CenterSketchLine        = null;
            Inventor.SketchPoint               SketchPoint             = null;
            Inventor.TransientGeometry         TransientGeometry;
            Inventor.RadiusDimConstraint       RadiusDimConstraint       = null;
            Inventor.TwoLineAngleDimConstraint TwoLineAngleDimConstraint = null;
            Inventor.ObjectCollection          ObjectCollection          = null;
            Inventor.ModelParameter            ModelParameter            = null;
            ObjectCollection = InvApp.TransientObjects.CreateObjectCollection();

            double pcdDia = 0, pcdAngle = 0.0;

            UnitsOfMeasure = PartDocument.UnitsOfMeasure;
            pcdDia         = UnitsOfMeasure.GetValueFromExpression(PCD, Inventor.UnitsTypeEnum.kMillimeterLengthUnits);

            pcdAngle  = UnitsOfMeasure.GetValueFromExpression(PCDAngle, Inventor.UnitsTypeEnum.kDegreeAngleUnits);
            WorkPoint = PartDocument.ComponentDefinition.WorkPoints[1];

            TransientGeometry = InvApp.TransientGeometry;

            foreach (Inventor.Face Face in ExtrudeFeature.EndFaces)
            {
                if (Face.SurfaceType == Inventor.SurfaceTypeEnum.kPlaneSurface)
                {
                    Sketch = PartDocument.ComponentDefinition.Sketches.Add(Face, false);
                    CenterPointSketchEntity       = Sketch.AddByProjectingEntity(WorkPoint);
                    CenterSketchLine              = Sketch.SketchLines.AddByTwoPoints(TransientGeometry.CreatePoint2d(0, 0), TransientGeometry.CreatePoint2d(0, pcdDia / 2));
                    CenterSketchLine.Construction = true;
                    AngleSketchLine = Sketch.SketchLines.AddByTwoPoints(CenterSketchLine.StartSketchPoint, TransientGeometry.CreatePoint2d(20, pcdDia / 2));
                    AngleSketchLine.Construction = true;
                    Sketch.GeometricConstraints.AddCoincident(CenterPointSketchEntity, (Inventor.SketchEntity)CenterSketchLine.StartSketchPoint);
                    Sketch.GeometricConstraints.AddEqualLength(CenterSketchLine, AngleSketchLine);
                    pcdSketchArc = Sketch.SketchArcs.AddByCenterStartEndPoint(CenterSketchLine.StartSketchPoint, CenterSketchLine.EndSketchPoint, AngleSketchLine.EndSketchPoint, false);
                    pcdSketchArc.Construction = true;
                    Sketch.GeometricConstraints.AddVertical((Inventor.SketchEntity)CenterSketchLine, false);
                    Sketch.GeometricConstraints.AddCoincident(CenterPointSketchEntity, (Inventor.SketchEntity)pcdSketchArc.CenterSketchPoint);
                    SketchPoint = Sketch.SketchPoints.Add(TransientGeometry.CreatePoint2d(0, 0), true);

                    Sketch.GeometricConstraints.AddCoincident((Inventor.SketchEntity)SketchPoint, (Inventor.SketchEntity)AngleSketchLine.EndSketchPoint);
                    RadiusDimConstraint = Sketch.DimensionConstraints.AddRadius((Inventor.SketchEntity)pcdSketchArc, pcdSketchArc.Geometry.Center, false);
                    if (RadiusDimConstraint.Parameter.ParameterType == Inventor.ParameterTypeEnum.kModelParameter)
                    {
                        ModelParameter = (Inventor.ModelParameter)RadiusDimConstraint.Parameter;
                        if (ModelParameter.BuiltIn)
                        {
                            ModelParameter.Name  = "PCD";
                            ModelParameter.Value = pcdDia / 2;
                        }
                    }


                    TwoLineAngleDimConstraint = Sketch.DimensionConstraints.AddTwoLineAngle(CenterSketchLine, AngleSketchLine, TransientGeometry.CreatePoint2d(1, 1), false);
                    if (TwoLineAngleDimConstraint.Parameter.ParameterType == Inventor.ParameterTypeEnum.kModelParameter)
                    {
                        ModelParameter = null;
                        ModelParameter = (Inventor.ModelParameter)TwoLineAngleDimConstraint.Parameter;
                        if (ModelParameter.BuiltIn)
                        {
                            ModelParameter.Name  = "Angle";
                            ModelParameter.Value = pcdAngle / 2;
                        }
                    }

                    ObjectCollection.Add(SketchPoint);
                }
                PartDocument.Update();
            }
            return(ObjectCollection);
        }
예제 #5
0
        private void UserInputEvents_OnSelect(Inventor.ObjectsEnumerator JustSelectedEntities, ref Inventor.ObjectCollection MoreSelectedEntities, Inventor.SelectionDeviceEnum SelectionDevice, Inventor.Point ModelPosition, Inventor.Point2d ViewPosition, Inventor.View View)
        {
            if (View.Parent != null)
            {
                Inventor.Document Document = (Inventor.Document)View.Parent;
                if (Document.DocumentType == Inventor.DocumentTypeEnum.kAssemblyDocumentObject)
                {
                    Inventor.AssemblyDocument AssemblyDocument = (Inventor.AssemblyDocument)Document;

                    OnSelectionChange(ref AssemblyDocument, ref MoreSelectedEntities);
                }
                else
                {
                    Inventor.AssemblyDocument AssemblyDocument = null;
                    JustSelectedEntities = null;
                    OnSelectionChange(ref AssemblyDocument, ref MoreSelectedEntities);
                }
            }
        }
예제 #6
0
 private void UserInputEvents_OnPreSelect(ref object PreSelectEntity, out bool DoHighlight, ref Inventor.ObjectCollection MorePreSelectEntities, Inventor.SelectionDeviceEnum SelectionDevice, Inventor.Point ModelPosition, Inventor.Point2d ViewPosition, Inventor.View View)
 {
     DoHighlight = true;
     //roll over
     // MessageBox.Show("On PreSelect");
 }
예제 #7
0
 private static void SetHighLightSet(ref Inventor.AssemblyDocument assemblyDocument, ref Inventor.ObjectCollection objectCollection)
 {
     if (objectCollection.Count >= 1)
     {
         Inventor.HighlightSet highlightSet = assemblyDocument.HighlightSets.Add();
         //highlightSet.Color = _InvApplication.TransientObjects.CreateColor(0, 0, 255, 1);
         //highlightSet.Color = _InvApplication.TransientObjects.CreateColor(255, 0, 0, 1);
         highlightSet.AddMultipleItems(objectCollection);
     }
     else
     {
         return;
     }
 }
예제 #8
0
 private static void Evt_OnSelectionChange(ref Inventor.AssemblyDocument AssemblyDocument, ref Inventor.ObjectCollection ObjectCollection)
 {
     //Inventor.ObjectCollection objectCollection = JustSelected.GetEnumerator()
     SetHighLightSet(ref AssemblyDocument, ref ObjectCollection);
 }
예제 #9
0
        private void UserInputEvents_OnSelect(Inventor.ObjectsEnumerator JustSelectedEntities, ref Inventor.ObjectCollection MoreSelectedEntities, Inventor.SelectionDeviceEnum SelectionDevice, Inventor.Point ModelPosition, Inventor.Point2d ViewPosition, Inventor.View View)
        {
            if (View.Parent != null)
            {
                Inventor.Document         Document         = (Inventor.Document)View.Parent;
                Inventor.AssemblyDocument AssemblyDocument = (Inventor.AssemblyDocument)Document;

                if (JustSelectedEntities.Count > 0)
                {
                    for (int i = JustSelectedEntities.Count; i >= 1; i--)
                    {
                        GetInventorObjType(JustSelectedEntities[i]);
                    }
                }
            }
        }