示例#1
0
 public Sticker(Inventor.Document pDoc, Inventor.Application m_InvApp)
 {
     InitializeComponent();
     invApp = m_InvApp;
     m_TG   = invApp.TransientGeometry;
     if (pDoc.DocumentType == DocumentTypeEnum.kPartDocumentObject)
     {
         m_Doc = (PartDocument)pDoc;
     }
     if (pDoc.DocumentType == DocumentTypeEnum.kAssemblyDocumentObject)
     {
         m_Asm   = (AssemblyDocument)pDoc;
         compDef = m_Asm.ComponentDefinition;
         box     = compDef.RangeBox;
     }
     valXML  = new List <string>();
     attrXML = new List <string>();
     if (System.IO.File.Exists(@"C:\ProgramData\Autodesk\Inventor Addins\Stickers.xml"))
     {
         tbl = new InvDoc.XML(@"C:\ProgramData\Autodesk\Inventor Addins\Stickers.xml");
         tbl.ReadXML("Sticker", ref valXML, ref attrXML);
         if (attrXML.Count != 0)
         {
             for (int i = 0; i < attrXML.Count; i++)
             {
                 if (attrXML[i].StartsWith("Name="))
                 {
                     string XMLVal = tbl.substring(attrXML[i], "Name=");
                     this.comboBox1.Items.Add(XMLVal);
                 }
             }
         }
     }
 }
示例#2
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;
        }