Example #1
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);
        }
Example #2
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];
        }