Exemplo n.º 1
0
        public CDXFExport(ref System.Windows.Forms.ListBox ListBoxComponents, string PartNumberIdent, string FileSaveLocation, ref Inventor.Application InvApplication)
        {
            mInvApplication = InvApplication;
            ListComponents  = ListBoxComponents;
            PartNumberID    = PartNumberIdent;

            FaceViews = new CDrawingView(ref InvApplication);
            Inventor.AssemblyDocument AssemblyDocument = (Inventor.AssemblyDocument)mInvApplication.ActiveDocument;
            GetAllPartsInBom(ref AssemblyDocument);
        }
Exemplo n.º 2
0
        public CDXFExport(string PartNumberIdent, string FileSaveLocation, ref Inventor.Application InvApplication)
        {
            mInvApplication = InvApplication;

            PartNumberID = PartNumberIdent;

            FaceViews = new CDrawingView(ref InvApplication);
            Inventor.AssemblyDocument AssemblyDocument = (Inventor.AssemblyDocument)mInvApplication.ActiveDocument;
            GetAllPartsInBom(ref AssemblyDocument);
        }
Exemplo n.º 3
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];
        }