Ejemplo n.º 1
0
        //    Create flat pattern drawing view API Sample
        //Description
        //This sample demonstrates the creation of a flat pattern base view in a drawing.
        //Open a drawing document and run the sample.
        public void AddFlatPatternDrawingView()
        {
            // Set a reference to the drawing document.
            // This assumes a drawing document is active.
            Inventor.DrawingDocument oDrawDoc = (Inventor.DrawingDocument)mInvApplication.ActiveDocument;

            //Set a reference to the active sheet.
            Inventor.Sheet oSheet = (Inventor.Sheet)oDrawDoc.ActiveSheet;

            // Create a new NameValueMap object
            Inventor.NameValueMap oBaseViewOptions = (Inventor.NameValueMap)mInvApplication.TransientObjects.CreateNameValueMap();

            // Set the options to use when creating the base view.
            oBaseViewOptions.Add("SheetMetalFoldedModel", false);

            // Open the sheet metal document invisibly
            Inventor._Document oModel = (Inventor._Document)mInvApplication.Documents.Open(@"C:\temp\SheetMetal.ipt", false);

            // Create the placement point object.
            Inventor.Point2d oPoint = default(Inventor.Point2d);
            oPoint = mInvApplication.TransientGeometry.CreatePoint2d(25, 25);

            // Create a base view.
            Inventor.DrawingView oBaseView = (Inventor.DrawingView)oSheet.DrawingViews
                                             .AddBaseView(oModel, oPoint, 1, Inventor.ViewOrientationTypeEnum.kDefaultViewOrientation,
                                                          Inventor.DrawingViewStyleEnum.kHiddenLineRemovedDrawingViewStyle, "", Type.Missing, oBaseViewOptions);

            // Release reference of the invisibly open model
            oModel.ReleaseReference();
        }
Ejemplo n.º 2
0
 private void DrawCircle_Constrain_Diamension(Inventor.Point2d CenterPoint, out Inventor.SketchCircle SketchCircle, out Inventor.RadiusDimConstraint RadiusDimConstraint, Inventor.PlanarSketch Sketch, Inventor.SketchEntity SketchEntity, double Radius)
 {
     //Draw
     SketchCircle = Sketch.SketchCircles.AddByCenterRadius(CenterPoint, Radius);
     //Dim
     RadiusDimConstraint = Sketch.DimensionConstraints.AddRadius((Inventor.SketchEntity)SketchCircle, CenterPoint, false);
     //Anchor
     Sketch.GeometricConstraints.AddCoincident(SketchEntity, (Inventor.SketchEntity)SketchCircle.CenterSketchPoint);
 }
Ejemplo n.º 3
0
        private static Inventor.Point2d GetDrawingCenterPoint(Inventor.Sheet CurrentSheet, Inventor.TransientGeometry TransientGeometry)
        {
            Inventor.Point2d Point2d = null;
            double           DrawingTitelBlockHeight = 5;

            if (CurrentSheet.Size == Inventor.DrawingSheetSizeEnum.kA4DrawingSheetSize)
            {
                DrawingTitelBlockHeight = 5;
            }
            else if (CurrentSheet.Size == Inventor.DrawingSheetSizeEnum.kA3DrawingSheetSize)
            {
                DrawingTitelBlockHeight = 5;
            }
            double[] ViewCenter = new double[2];

            double SheetWidth  = CurrentSheet.Width;
            double SheetHeight = CurrentSheet.Height;

            ViewCenter[0] = SheetWidth / 2;
            ViewCenter[1] = (SheetHeight + DrawingTitelBlockHeight) / 2;

            Point2d = TransientGeometry.CreatePoint2d(ViewCenter[0], ViewCenter[1]);
            return(Point2d);
        }
Ejemplo n.º 4
0
        //    Adding Representation views API Sample
        //Description
        //This sample demonstrates how to create a base view by specifying various representations.
        //Before running this sample, make sure that the file
        // C:\TempReps.iam exists (or change the path in the sample).
        //     The file must contain a level of detail representation named MyLODRep,
        //     a positional representation named MyPositionalRep and a design view representation named MyDesignViewRep.
        public void AddBaseViewWithRepresentations()
        {
            // Set a reference to the drawing document.
            // This assumes a drawing document is active.
            Inventor.DrawingDocument oDrawDoc = (Inventor.DrawingDocument)mInvApplication.ActiveDocument;

            //Set a reference to the active sheet.
            Inventor.Sheet oSheet = (Inventor.Sheet)oDrawDoc.ActiveSheet;

            // Create a new NameValueMap object
            Inventor.NameValueMap oBaseViewOptions = (Inventor.NameValueMap)mInvApplication.TransientObjects.CreateNameValueMap();

            // Set the representations to use when creating the base view.
            oBaseViewOptions.Add("PositionalRepresentation", "MyPositionalRep");
            oBaseViewOptions.Add("DesignViewRepresentation", "MyDesignViewRep");
            oBaseViewOptions.Add("DesignViewAssociative", true);

            // Open the model document (corresponding to the "MyLODRep" representation).
            string strFullDocumentName = null;

            strFullDocumentName = mInvApplication.FileManager.GetFullDocumentName(@"C:\tempreps.iam", "MyLODRep");

            Inventor._Document oModel = (Inventor._Document)mInvApplication.Documents.Open(strFullDocumentName, false);

            // Create the placement point object.
            Inventor.Point2d oPoint = default(Inventor.Point2d);
            oPoint = mInvApplication.TransientGeometry.CreatePoint2d(25, 25);

            // Create a base view.
            Inventor.DrawingView oBaseView = (Inventor.DrawingView)oSheet.DrawingViews.
                                             AddBaseView(oModel, oPoint, 2, Inventor.ViewOrientationTypeEnum.kIsoTopLeftViewOrientation,
                                                         Inventor.DrawingViewStyleEnum.kHiddenLineRemovedDrawingViewStyle, "", Type.Missing, oBaseViewOptions);

            // Release reference of the invisibly open model
            oModel.ReleaseReference();
        }
Ejemplo n.º 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);
                }
            }
        }
Ejemplo n.º 6
0
 private void MouseEventsSink_OnMouseUp(Inventor.MouseButtonEnum Button, Inventor.ShiftStateEnum ShiftKeys, Inventor.Point ModelPosition, Inventor.Point2d ViewPosition, Inventor.View View)
 {
 }
Ejemplo n.º 7
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");
 }
Ejemplo n.º 8
0
 private void UserInputEvents_OnUnSelect(Inventor.ObjectsEnumerator UnSelectedEntities, Inventor.SelectionDeviceEnum SelectionDevice, Inventor.Point ModelPosition, Inventor.Point2d ViewPosition, Inventor.View View)
 {
     // MessageBox.Show("On UnSelect");
 }
Ejemplo n.º 9
0
 private void UserInputEvents_OnStopPreSelect(Inventor.Point ModelPosition, Inventor.Point2d ViewPosition, Inventor.View View)
 {
     //MessageBox.Show("On Stop PreSelect");
 }
Ejemplo n.º 10
0
 private void UserInputEvents_OnDoubleClick(Inventor.ObjectsEnumerator SelectedEntities, Inventor.SelectionDeviceEnum SelectionDevice, Inventor.MouseButtonEnum Button, Inventor.ShiftStateEnum ShiftKeys, Inventor.Point ModelPosition, Inventor.Point2d ViewPosition, Inventor.View View, Inventor.NameValueMap AdditionalInfo, out Inventor.HandlingCodeEnum HandlingCode)
 {
     HandlingCode = Inventor.HandlingCodeEnum.kEventHandled;
     //MessageBox.Show("On Double Click");
 }
Ejemplo n.º 11
0
        public void CreateOrdinateDimensions()
        {
            // Set a reference to the drawing document.
            // This assumes a drawing document is active.
            Inventor.DrawingDocument oDrawDoc = (Inventor.DrawingDocument)mInvApplication.ActiveDocument;

            // Set a reference to the active sheet.
            Inventor.Sheet oActiveSheet = (Inventor.Sheet)oDrawDoc.ActiveSheet;

            // Set a reference to the drawing curve segment.
            // This assumes that a linear drawing curve is selected.
            Inventor.DrawingCurveSegment oDrawingCurveSegment = (Inventor.DrawingCurveSegment)oDrawDoc.SelectSet[1];


            // Set a reference to the drawing curve.
            Inventor.DrawingCurve oDrawingCurve = default(Inventor.DrawingCurve);
            oDrawingCurve = oDrawingCurveSegment.Parent;

            if (!(oDrawingCurve.CurveType == Inventor.CurveTypeEnum.kLineSegmentCurve))
            {
                //MessageBox.Show("A linear curve should be selected for this sample.");
                return;
            }

            // Create point intents to anchor the dimension to.
            Inventor.GeometryIntent oDimIntent1 = default(Inventor.GeometryIntent);
            oDimIntent1 = oActiveSheet.CreateGeometryIntent(oDrawingCurve, Inventor.PointIntentEnum.kStartPointIntent);

            Inventor.GeometryIntent oDimIntent2 = default(Inventor.GeometryIntent);
            oDimIntent2 = oActiveSheet.CreateGeometryIntent(oDrawingCurve, Inventor.PointIntentEnum.kEndPointIntent);

            // Set a reference to the view to which the curve belongs.
            Inventor.DrawingView oDrawingView = default(Inventor.DrawingView);
            oDrawingView = oDrawingCurve.Parent;

            // If origin indicator has not been already created, create it first.
            if (!oDrawingView.HasOriginIndicator)
            {
                // The indicator will be located at the start point of the selected curve.
                oDrawingView.CreateOriginIndicator(oDimIntent1);
            }

            // Set a reference to the ordinate dimensions collection.
            Inventor.OrdinateDimensions oOrdinateDimensions = default(Inventor.OrdinateDimensions);
            oOrdinateDimensions = oActiveSheet.DrawingDimensions.OrdinateDimensions;

            // Create the x-axis vector
            Inventor.Vector2d oXAxis = default(Inventor.Vector2d);
            oXAxis = mInvApplication.TransientGeometry.CreateVector2d(1, 0);

            Inventor.Vector2d oCurveVector = default(Inventor.Vector2d);
            oCurveVector = oDrawingCurve.StartPoint.VectorTo(oDrawingCurve.EndPoint);

            Inventor.Point2d           oTextOrigin1 = default(Inventor.Point2d);
            Inventor.Point2d           oTextOrigin2 = default(Inventor.Point2d);
            Inventor.DimensionTypeEnum DimType      = default(Inventor.DimensionTypeEnum);

            if (oCurveVector.IsParallelTo(oXAxis))
            {
                // Selected curve is horizontal
                DimType = Inventor.DimensionTypeEnum.kVerticalDimensionType;

                // Set the text points for the 2 dimensions.
                oTextOrigin1 = mInvApplication.TransientGeometry.CreatePoint2d(oDrawingCurve.StartPoint.X, oDrawingView.Top + 5);
                oTextOrigin2 = mInvApplication.TransientGeometry.CreatePoint2d(oDrawingCurve.EndPoint.X, oDrawingView.Top + 5);
            }
            else
            {
                // Selected curve is vertical or at an angle.
                DimType = Inventor.DimensionTypeEnum.kHorizontalDimensionType;

                // Set the text points for the 2 dimensions.
                oTextOrigin1 = mInvApplication.TransientGeometry.CreatePoint2d(oDrawingView.Left - 5, oDrawingCurve.StartPoint.Y);
                oTextOrigin2 = mInvApplication.TransientGeometry.CreatePoint2d(oDrawingView.Left - 5, oDrawingCurve.EndPoint.Y);
            }

            // Create the first ordinate dimension.
            Inventor.OrdinateDimension oOrdinateDimension1 = default(Inventor.OrdinateDimension);
            oOrdinateDimension1 = oOrdinateDimensions.Add(oDimIntent1, oTextOrigin1, DimType);

            // Create the second ordinate dimension.
            Inventor.OrdinateDimension oOrdinateDimension2 = default(Inventor.OrdinateDimension);
            oOrdinateDimension2 = oOrdinateDimensions.Add(oDimIntent2, oTextOrigin2, DimType);
        }
Ejemplo n.º 12
0
        //    Add detail drawing view API Sample
        //Description
        //This sample demonstrates the creation of a detail drawing view with an attach point.
        //Before running this sample, select a drawing view in the active drawing.
        public void CreateDetailView()
        {
            // Set a reference to the drawing document.
            // This assumes a drawing document is active.
            Inventor.DrawingDocument oDrawDoc = (Inventor.DrawingDocument)mInvApplication.ActiveDocument;

            //Set a reference to the active sheet.
            Inventor.Sheet oSheet = (Inventor.Sheet)oDrawDoc.ActiveSheet;

            Inventor.DrawingView oDrawingView = default(Inventor.DrawingView);
            // Check to make sure a drawing view is selected.
            try
            {
                // Set a reference to the selected drawing. This assumes
                // that the selected view is not a draft view.
                oDrawingView = (Inventor.DrawingView)oDrawDoc.SelectSet[1];
            }
            catch
            {
                //MessageBox.Show("A drawing view must be selected.");
                return;
            }


            // Set a reference to the center of the base view.
            Inventor.Point2d oPoint = (Inventor.Point2d)oDrawingView.Center;

            // Translate point by a distance = 2 * width of the view
            // This will be the placement point of the detail view.
            oPoint.X = oPoint.X + 2 * oDrawingView.Width;

            // Set corner one of rectangular fence as
            // the left-bottom corner of the base view.
            Inventor.Point2d oCornerOne = (Inventor.Point2d)oDrawingView.Center;


            oCornerOne.X = oCornerOne.X - oDrawingView.Width / 2;
            oCornerOne.Y = oCornerOne.Y - oDrawingView.Height / 2;

            // Set corner two of rectangular fence as
            // the center of the base view.
            Inventor.Point2d oCornerTwo = (Inventor.Point2d)oDrawingView.Center;

            // Get any linear curve from the base view
            Inventor.DrawingCurve oCurveToUse = null;
            foreach (Inventor.DrawingCurve oCurve in oDrawingView.DrawingCurves)
            {
                if (oCurve.CurveType == Inventor.CurveTypeEnum.kLineSegmentCurve)
                {
                    oCurveToUse = oCurve;
                    break;
                }
            }

            // Create an intent object
            Inventor.GeometryIntent oAttachPoint = (Inventor.GeometryIntent)oSheet.
                                                   CreateGeometryIntent(oCurveToUse, Inventor.PointIntentEnum.kStartPointIntent);

            // Create the detail view
            Inventor.DetailDrawingView oDetailView = (Inventor.DetailDrawingView)oSheet.DrawingViews.
                                                     AddDetailView(oDrawingView, oPoint, Inventor.DrawingViewStyleEnum.kFromBaseDrawingViewStyle,
                                                                   false, oCornerOne, oCornerTwo, oAttachPoint, 2);
        }
Ejemplo n.º 13
0
        private void DrawDocument(Inventor._Document Document, string TypeOfPart)
        {
            Inventor.ViewOrientationTypeEnum Orientation = Inventor.ViewOrientationTypeEnum.kDefaultViewOrientation;
            Inventor.DrawingDocument         DrawingDocument;
            Inventor.Sheet Sheet;

            Inventor.DrawingView       DrawingView;
            Inventor.TransientGeometry oTG = mInvApplication.TransientGeometry;
            CreateDrawingDocument(out DrawingDocument, out Sheet);
            //Inventor.DrawingStandardStyle DrawingStandardStyle;
            //DrawingStandardStyle = DrawingDocument.StylesManager.ActiveStandardStyle;
            if (TypeOfPart == "SheetMetal")
            {
                Inventor.NameValueMap BaseViewOptions = (Inventor.NameValueMap)mInvApplication.TransientObjects.CreateNameValueMap();
                BaseViewOptions.Add("SheetMetalFoldedModel", false);
                DrawingView = AddDocumentBaseView(Document, Sheet, oTG, BaseViewOptions);
            }
            else if (TypeOfPart == "Plate")
            {
                CDrawingView    CView  = new CDrawingView();
                Inventor.Camera Camera = null;
                Camera      = CView.GetDocument(ref Document, ref mInvApplication);
                DrawingView = AddDocumentBaseView(Document, Sheet, oTG, Camera);
            }
            else
            {
                ViewOrientation(ref Orientation);
                DrawingView = AddDocumentBaseView(Document, Sheet, oTG, Orientation);
            }


            try
            {
                Inventor.DrawingCurve SelectedCurve = null;

                foreach (Inventor.DrawingCurve CurveLine in DrawingView.get_DrawingCurves(null))
                {
                    //Skip Circles
                    if (CurveLine.StartPoint != null && CurveLine.EndPoint != null)
                    {
                        if (WithinTol(CurveLine.StartPoint.Y, CurveLine.EndPoint.Y, 0.001))
                        {
                            if (SelectedCurve == null)
                            {
                                //This is the first horizontal curve found.
                                SelectedCurve = CurveLine;
                            }
                            else
                            {
                                //Check to see if this curve is higher (smaller x value) than the current selected
                                if (CurveLine.MidPoint.Y < SelectedCurve.MidPoint.X)
                                {
                                    SelectedCurve = CurveLine;
                                }
                            }
                        }
                    }
                }
                //Create geometry intents point for the curve.
                Inventor.GeometryIntent oGeomIntent1 = Sheet.CreateGeometryIntent(SelectedCurve, Inventor.PointIntentEnum.kStartPointIntent);
                Inventor.GeometryIntent oGeomIntent2 = Sheet.CreateGeometryIntent(SelectedCurve, Inventor.PointIntentEnum.kEndPointIntent);
                Inventor.Point2d        oDimPos      = oTG.CreatePoint2d(SelectedCurve.MidPoint.X - 2, SelectedCurve.MidPoint.Y);

                Inventor.GeneralDimensions      oGeneralDimensions = Sheet.DrawingDimensions.GeneralDimensions;
                Inventor.LinearGeneralDimension oLinearDim;
                oLinearDim = oGeneralDimensions.AddLinear(oDimPos, oGeomIntent1, oGeomIntent2, Inventor.DimensionTypeEnum.kAlignedDimensionType, true);
            }
            catch (Exception)
            {
            }
            mInvApplication.SilentOperation = true;
            string partURL       = Document.FullFileName;
            int    NameLength    = Document.FullFileName.Length;
            string partURLTrimed = partURL.Remove(NameLength - 4);

            //DrawingDocument.Save();
            DrawingDocument.SaveAs(partURLTrimed + ".idw", false);
            DrawingDocument.Close(true);
            Document.Close(false);
            mInvApplication.SilentOperation = false;


            //Sheet.RevisionTables.Add(oTG.CreatePoint2d(Sheet.Width, Sheet.Height));  //1mm div 10//1 row = 4
            //Inventor.DimensionStyle dimstyle = DrawingDocument.StylesManager.DimensionStyles[cmbDimStyles.Text];
            //Inventor.Layer layer = DrawingDocument.StylesManager.Layers[cmbLayers.Text];
        }
Ejemplo n.º 14
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]);
                    }
                }
            }
        }