public static void BOMViewTraverse(this _I.BOMView view, Action <_I.ComponentDefinition, int> action)
        {
            int level = 0;

            QueryRows(view.BOMRows, level);

            void QueryRows(_I.BOMRowsEnumerator oBOMRows, int lvl)
            {
                foreach (_I.BOMRow oRow in oBOMRows)
                {
                    var oCompDef = oRow.ComponentDefinitions[1];
                    action(oCompDef, lvl);

                    if (oRow.ChildRows != null)
                    {
                        QueryRows(oRow.ChildRows, ++level);
                        level--;
                    }
                }
            }
        }
Ejemplo n.º 2
0
            private void Grid_CellEndEdit(object sender, DataGridViewCellEventArgs e)
            {
                if (e.ColumnIndex == 3 || e.ColumnIndex == 4)
                {
                    Inventor.Application      invApp   = Macros.StandardAddInServer.m_inventorApplication;
                    Inventor.Document         oDoc     = invApp.ActiveDocument;
                    Inventor.AssemblyDocument m_AsmDoc = (AssemblyDocument)InvDoc.u.referendedDoc(oDoc as Document);
                    Inventor.BOM m_BOM = m_AsmDoc.ComponentDefinition.BOM;
                    m_BOM.StructuredViewEnabled = true;
                    if (!m_BOM.StructuredViewFirstLevelOnly)
                    {
                        m_BOM.StructuredViewFirstLevelOnly = true;
                    }
                    Inventor.BOMView m_BOMView = m_BOM.BOMViews["Структурированный"];
                    foreach (Inventor.BOMRow row in m_BOMView.BOMRows)
                    {
                        Inventor.ComponentDefinition oCompDef = row.ComponentDefinitions[1];
                        oDoc = (Inventor.Document)oCompDef.Document;
                        string partNumber = (string)oDoc.PropertySets[3][2].Value;
                        string desc       = (string)oDoc.PropertySets[3][14].Value;
                        if (partNumber == val1 && desc == val2)
                        {
                            switch (x)
                            {
                            case 3:
                                oDoc.PropertySets[3][2].Value = ((DataGridView)sender)[x, y].Value.ToString();
                                break;

                            case 4:
                                oDoc.PropertySets[3][14].Value = ((DataGridView)sender)[x, y].Value.ToString();
                                break;
                            }
                            break;
                        }
                    }
                }
            }
Ejemplo n.º 3
0
        public Table(Inventor.Document pDoc, Inventor.Application m_InvApp)
        {
            boundsScreen = Screen.PrimaryScreen.WorkingArea;
            scale        = boundsScreen.Width * 0.465 / 16.5;
            m_TG         = m_InvApp.TransientGeometry;
            switch (pDoc.DocumentType)
            {
            case DocumentTypeEnum.kAssemblyDocumentObject:
                m_AsmDoc = (AssemblyDocument)pDoc;
                break;

            case DocumentTypeEnum.kDrawingDocumentObject:
                m_DrwDoc = (DrawingDocument)pDoc;
                m_AsmDoc = (AssemblyDocument)InvDoc.u.referendedDoc(m_DrwDoc as Document);    //m_DrwDoc.ReferencedDocuments.Count];
                if (m_AsmDoc.FullDocumentName.EndsWith(">"))
                {
                    m_AsmDoc = (AssemblyDocument)((Inventor.Application)m_AsmDoc.Parent).Documents.Open(m_AsmDoc.FullFileName, false);
                }
                break;
            }
            path          = pDoc.FullFileName.ToString();
            path          = path.Substring(0, path.LastIndexOf('\\'));
            m_BOM         = m_AsmDoc.ComponentDefinition.BOM;
            partNumberAsm = m_AsmDoc.PropertySets[3][2].Value.ToString();
            m_BOM.StructuredViewEnabled = true;
            if (!m_BOM.StructuredViewFirstLevelOnly)
            {
                m_BOM.StructuredViewFirstLevelOnly = true;
            }
            //if (m_BOM.StructuredViewFirstLevelOnly)
            //    m_BOM.StructuredViewFirstLevelOnly = false;
            m_BOMView = m_BOM.BOMViews["Структурированный"];
            InitializeComponent();
            this.ClientSize        = Screen.PrimaryScreen.WorkingArea.Size;
            this.Format.Width      = (int)(0.6 * scale);
            this.Zone.Width        = (int)(0.6 * scale);
            this.Position.Width    = (int)(0.8 * scale);
            this.PartNumber.Width  = (int)(5 * scale);
            this.Description.Width = (int)(6.3 * scale);
            this.Count.Width       = (int)(1 * scale);
            this.Note.Width        = (int)(2.2 * scale);

            this.FormatVar.Width      = this.Format.Width;
            this.ZoneVar.Width        = this.Zone.Width;
            this.PositionVar.Width    = this.Position.Width;
            this.PartNumberVar.Width  = this.PartNumber.Width;
            this.DescriptionVar.Width = this.Description.Width;
            this.CountVar.Width       = this.Count.Width;
            this.NoteVar.Width        = this.Note.Width;

            int offset = (int)(0.004 * boundsScreen.Width);
            int width  = dgv.Columns.OfType <DataGridViewColumn>().Sum(e => e.Width);

            width                   += 22;
            this.dgv.Size            = new System.Drawing.Size(width, this.Size.Height - menu.Height - 50 /*(int)(boundsScreen.Height*0.08)*/);
            this.dgv.Location        = new System.Drawing.Point(0, this.menu.Bounds.Bottom);
            this.dgvVar.Size         = dgv.Size;
            this.dgvVar.Location     = new System.Drawing.Point(dgv.Location.X + dgv.Width, dgv.Location.Y);
            this.dgv.RowHeadersWidth = this.dgvVar.RowHeadersWidth = 20;

            label1.Location = new System.Drawing.Point(dgv.Location.X + width / 2 - label1.Width / 2, dgv.Location.Y /*- label1.Width/2*/ - 24);
            label2.Location = new System.Drawing.Point(dgv.Location.X + width + width / 2 - label2.Width / 2, dgv.Location.Y /*- label2.Width/2*/ - 24);
            label2.Visible  = false;
            dgvVar.Visible  = false;

            width *= 2;
            width += (int)(0.001 * boundsScreen.Width);
            int bottomButton = dgv.Bounds.Bottom + (boundsScreen.Height - dgv.Bounds.Bottom) / 2 - button1.Bounds.Height / 2;

            this.button1.Width    = button2.Width = button3.Width = txtBox.Width = /*txtBox3.Width = */ (int)(0.045 * boundsScreen.Width);
            this.button1.Location = new System.Drawing.Point(dgvVar.Bounds.Right + offset, this.menu.Bounds.Bottom + offset);
            this.button3.Location = new System.Drawing.Point(button1.Bounds.Left, button1.Bounds.Bottom + offset);
            this.button2.Location = new System.Drawing.Point(button3.Bounds.Left, button3.Bounds.Bottom + offset);
            this.lbl.Location     = new System.Drawing.Point(button2.Bounds.Left, button2.Bounds.Bottom + offset);
            this.txtBox.Location  = new System.Drawing.Point(button2.Bounds.Left, lbl.Bounds.Bottom + offset);
            //this.lbl3.Location = new System.Drawing.Point(button2.Bounds.Left, txtBox.Bounds.Bottom + offset);
            //this.txtBox3.Location = new System.Drawing.Point(button2.Bounds.Left, lbl3.Bounds.Bottom + offset);

            //initSpec(dgv);

            tbl = tbl ?? new TableInv(m_DrwDoc, @"C:\ProgramData\Autodesk\Inventor Addins\Sequence.xml");
            //if (txtBox.Text != "") tbl.split = txtBox.Text;
            //VariableDataForSpec vd = new VariableDataForSpec((Document)m_AsmDoc);
            //List<string> lst = vd.AttribLoad("Split");
            AttributeSet attSet;

            if (m_AsmDoc.AttributeSets.get_NameIsUsed("Split"))
            {
                attSet = m_AsmDoc.AttributeSets["Split"];

                if (attSet.Count != 0)
                {
                    txtBox.Text = attSet[1].Value.ToString();
                }
            }

            tbl.addTable(m_BOMView);
            if (tbl.countPerf == 0)
            {
                tbl.showTable(dgv, 0, 100, tbl.group, varData: false);
            }
            else
            {
                tbl.showTable(dgv, 0, 100, tbl.group, varData: false);
                tbl.showTable(dgvVar, 100, 5000, tbl.group, varData: true);
                dgvVar.Visible = true;
            }
            //tbl.asmDoc = m_AsmDoc;
            balloon();
            dgv.RowHeaderMouseClick += dataGridView1_RowHeaderMouseClick;
            dgv.KeyDown             += dgv_KeyDown;
        }