Beispiel #1
0
        private void tsbSetting_Click(object sender, EventArgs e)
        {
            FieldSelectForm <CheckData> form = new FieldSelectForm <CheckData>();

            if (form.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                RefreshGrid();
            }
        }
Beispiel #2
0
        /// <summary>
        /// Attempts to connect to an open Inventor Application instance and the active assembly document.
        /// </summary>
        /// <returns>true if successful, false if failed</returns>
        public static bool Connect()
        {
            try
            {
                INVENTOR_APPLICATION = (Inventor.Application)System.Runtime.InteropServices.Marshal.GetActiveObject("Inventor.Application");
                INVENTOR_APPLICATION.ApplicationEvents.OnQuit          += ApplicationEvents_OnQuit;
                INVENTOR_APPLICATION.ApplicationEvents.OnCloseDocument += ApplicationEvents_OnCloseDocument;
            }
            catch
            {
                return(false);
            }

            ASSEMBLY_DOCUMENT = null;

            if (fullDocumentName.Equals("undef"))
            {
                if (INVENTOR_APPLICATION.Documents.VisibleDocuments.OfType <Inventor.AssemblyDocument>().Count() > 0)
                {
                    FieldSelectForm fieldSelector = new FieldSelectForm();
                    if (fieldSelector.ShowDialog() == DialogResult.OK)
                    {
                        foreach (Inventor.Document doc in INVENTOR_APPLICATION.Documents.VisibleDocuments.OfType <Inventor.AssemblyDocument>())
                        {
                            if (doc.DisplayName == fieldSelector.SelectedField)
                            {
                                ASSEMBLY_DOCUMENT = (Inventor.AssemblyDocument)doc;
                            }
                        }

                        if (ASSEMBLY_DOCUMENT == null)
                        {
                            return(false);
                        }

                        fullDocumentName = ASSEMBLY_DOCUMENT.FullDocumentName;
                    }
                    else
                    {
                        return(false);
                    }
                }
                else
                {
                    return(false);
                }
            }
            else
            {
                foreach (Inventor.Document doc in INVENTOR_APPLICATION.Documents.VisibleDocuments.OfType <Inventor.AssemblyDocument>())
                {
                    if (doc.FullDocumentName == fullDocumentName)
                    {
                        ASSEMBLY_DOCUMENT = (Inventor.AssemblyDocument)doc;
                    }
                }

                if (ASSEMBLY_DOCUMENT == null)
                {
                    return(false);
                }
            }

            return(true);
        }