Esempio n. 1
0
        public Inventor.Camera GetDocument(ref Inventor._Document Document, ref Inventor.Application invApplication)
        {
            Inventor.PartDocument PartDocument = null;
            Inventor.Camera       Camera       = null;
            mInvApplication = invApplication;
            if (Document.DocumentType == Inventor.DocumentTypeEnum.kPartDocumentObject)
            {
                PartDocument = (Inventor.PartDocument)Document;

                if (PartDocument != null)
                {
                    if (PartDocument.ComponentDefinitions.Count > 0)
                    {
                        Camera = mInvApplication.ActiveView.Camera;
                        Inventor.PartComponentDefinition PartComponentDefinition = PartDocument.ComponentDefinitions[1];

                        foreach (Inventor.SurfaceBody SurfaceBody in PartComponentDefinition.SurfaceBodies)
                        {
                            GetFaceToView(SurfaceBody, ref PartDocument, ref Camera);
                        }
                        return(Camera);
                    }
                }
            }
            return(Camera);
        }
Esempio n. 2
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();
        }
Esempio n. 3
0
        /// <summary>
        /// Handles the OnCloseDocument event by attempting to reconnect to the Assembly Document.
        /// </summary>
        /// <param name="DocumentObject"></param>
        /// <param name="FullDocumentName"></param>
        /// <param name="BeforeOrAfter"></param>
        /// <param name="Context"></param>
        /// <param name="HandlingCode"></param>
        public static void ApplicationEvents_OnCloseDocument(Inventor._Document DocumentObject, string FullDocumentName, Inventor.EventTimingEnum BeforeOrAfter, Inventor.NameValueMap Context, out Inventor.HandlingCodeEnum HandlingCode)
        {
            HandlingCode = Inventor.HandlingCodeEnum.kEventHandled;

            if (ASSEMBLY_DOCUMENT.RevisionId == DocumentObject.RevisionId)
            {
                MAINWINDOW.BeginInvoke(new Action(RequestConnection));
            }
        }
Esempio n. 4
0
        private static Inventor.DrawingView AddDocumentBaseView(Inventor._Document Document, Inventor.Sheet Sheet, Inventor.TransientGeometry TransientGeometry, Inventor.NameValueMap BaseViewOptions)
        {
            double ViewWidth = 17;

            Inventor.DrawingView DrawingView = Sheet.DrawingViews.AddBaseView(Document as Inventor._Document, GetDrawingCenterPoint(Sheet, TransientGeometry), 0.2, Inventor.ViewOrientationTypeEnum.kDefaultViewOrientation, Inventor.DrawingViewStyleEnum.kHiddenLineRemovedDrawingViewStyle, "", null, BaseViewOptions);

            DrawingView.Scale = ViewWidth / DrawingView.Width * DrawingView.Scale;

            return(DrawingView);
        }
Esempio n. 5
0
        private static Inventor.DrawingView AddDocumentBaseView(Inventor._Document Document, Inventor.Sheet Sheet, Inventor.TransientGeometry TransientGeometry, Inventor.Camera Camera)
        {
            double ViewWidth = 17;

            Inventor.DrawingView DrawingView = Sheet.DrawingViews.AddBaseView(Document as Inventor._Document, GetDrawingCenterPoint(Sheet, TransientGeometry), 0.2, Inventor.ViewOrientationTypeEnum.kArbitraryViewOrientation, Inventor.DrawingViewStyleEnum.kHiddenLineRemovedDrawingViewStyle, "", Camera, null);

            DrawingView.Scale = ViewWidth / DrawingView.Width * DrawingView.Scale;

            SetViewScale(Sheet, ref DrawingView);

            return(DrawingView);
        }
Esempio n. 6
0
        private void ProcessFileRefs(Inventor.File File)
        {
            foreach (Inventor.FileDescriptor DescriptedFile in File.ReferencedFileDescriptors)
            {
                if (!DescriptedFile.ReferenceMissing)
                {
                    if (DescriptedFile.ReferencedFileType != Inventor.FileTypeEnum.kForeignFileType)
                    {
                        if (DescriptedFile.ReferencedFileType == Inventor.FileTypeEnum.kPartFileType) //part or sub;
                        {
                            string TartgetPartNumber           = "";
                            Inventor.PartDocument PartDocument = (Inventor.PartDocument)mInvApplication.Documents.Open(DescriptedFile.FullFileName, false);
                            TartgetPartNumber = PartDocument.PropertySets["{32853F0F-3444-11d1-9E93-0060B03C1CA6}"].get_ItemByPropId((int)Inventor.PropertiesForDesignTrackingPropertiesEnum.kPartNumberDesignTrackingProperties).Value;

                            if (TartgetPartNumber.StartsWith(txtPartID))
                            {
                                string             TypeOfPart = "";
                                Inventor._Document Document   = (Inventor._Document)PartDocument;

                                // normal part
                                if (PartDocument.SubType != "{9C464203-9BAE-11D3-8BAD-0060B0CE6BB4}")
                                {
                                    TypeOfPart = "Plate";
                                    DrawDocument(Document, TypeOfPart);
                                }
                                else // if sheet metal
                                {
                                    TypeOfPart = "SheetMetal";
                                    DrawDocument(Document, TypeOfPart);
                                }

                                // Document.Close(false);
                            }
                            PartDocument.Close(false);
                        }
                    }
                }
            }
        }
Esempio n. 7
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();
        }
Esempio n. 8
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];
        }