public static void saveData(AssemblyDocument m_AsmDoc) { XDocument xd = new XDocument(); InvDoc.InvDocument <AssemblyDocument> iDoc = new InvDoc.InvDocument <AssemblyDocument>(m_AsmDoc); iDoc.doc = (Document)m_AsmDoc; string name = iDoc.path + iDoc.getProp("Part Number").Value + ".xml"; //tbl.saveDataInXML(xd,"Data",name, false); BOM m_BOM = m_AsmDoc.ComponentDefinition.BOM; string 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; } BOMView m_BOMView = m_BOM.BOMViews["Структурированный"]; TableInv tbl = null; tbl = new TableInv(m_AsmDoc, @"C:\ProgramData\Autodesk\Inventor Addins\Sequence.xml"); tbl.addTable(m_BOMView); tbl.saveDataInXML(xd, "Data", name, false); }
private void button1_Click(object sender, EventArgs e) { //drawTable("Spec",m_TG.CreatePoint2d(0, 0), new double[] { 0.6, 0.6, 0.8, 7, 6.3, 1, 2.2}, dataGridView1.Rows.Count - 1, // intArr2: new int[] {3,4,6}, _dgv: dataGridView1,heigthRow: 0.8); tbl = tbl ?? new TableInv(m_DrwDoc, @"C:\ProgramData\Autodesk\Inventor Addins\Sequence.xml"); if (tbl.countPerf != 0) { tbl.saveInAsm(); } int[] arr = txtBox.Text.Split(';').Select(s => int.Parse(s)).ToArray(); VariableDataForSpec vd = new VariableDataForSpec((Document)m_AsmDoc); vd.AttribDelete("Split"); if (txtBox.Text != "") { vd.AttribAdd <string>("Split", txtBox.Text, ValueTypeEnum.kStringType); } tbl.addToSheet("Spec", arr); //tbl.addTable(dgv); //tbl.drawTable("Спецификация", 0, dataGridView1.RowCount, m_TG.CreatePoint2d()); //string[] tmp = txtBox.Text.Split(new char[]{';'}); //int[] spl = new int[tmp.Count()/*+1*/]; int sum = 1; //foreach (Inventor.SketchedSymbol ss in m_DrwDoc.ActiveSheet.SketchedSymbols) //{ // if (ss.Name.StartsWith("Spec")) // { // pts.Add(ss.Position); // ss.Delete(); // } //} //for (int i = 0; i < tmp.Count(); i++) //{ // sum += Convert.ToInt16(tmp[i]); // if (sum > dataGridView1.RowCount) { // spl[i] = dataGridView1.RowCount; // Array.Resize(ref spl, i+1); // break; // } // spl[i] = sum; //} ////spl[spl.Count()-1] = 100; //Inventor.Application invApp = (Inventor.Application)m_DrwDoc.Parent; //invApp.ScreenUpdating = false; //drawTables(dataGridView1, spl); //invApp.ScreenUpdating = true; }
private void загрузитьДанныеToolStripMenuItem_Click_1(object sender, EventArgs e) { DataGridViewRow dgvr; InvDoc.InvDocument <AssemblyDocument> iDoc = new InvDoc.InvDocument <AssemblyDocument>(m_AsmDoc); iDoc.doc = (Document)m_AsmDoc; dgvr = dgvVar.CurrentRow; TableRow tr = tbl.rows.OfType <TableRow>().FirstOrDefault(t => t.group > 100 && t.dvgRow == dgvr.Index); if (tr == null) { return; } //OpenFileDialog ofd = new OpenFileDialog(); //ofd.InitialDirectory = iDoc.path; //ofd.Filter = "(*.iam, *.ipt)|*.iam;*.ipt"; //ofd.ShowDialog(); string fileName = InvDoc.u.OFD(iDoc.path, "(*.iam, *.ipt)|*.iam;*.ipt"); //string fileName = ofd.FileName; Document doc = Macros.StandardAddInServer.m_inventorApplication.Documents.Open(fileName, false); Dictionary <string, string> dic = new Dictionary <string, string>(); dic = TableInv.propDoc(doc); try { tr.cells[3].value = dic["PartNumber"]; tr.cells[4].value = dic["desc"]; tr.cells[6].value = dic["note"]; tr.cells[7].value = dic["dxf"]; tr.cells[8].value = dic["thickness"]; tr.cells[9].value = dic["FPLength"]; tr.cells[10].value = dic["FPWidth"]; } catch (Exception) { } doc.Close(); tbl.showTable(dgvVar, 100, 5000, tbl.group, varData: true); //tbl.addVarRows(dgvr.Cells[3].Value.ToString(), dgvr.Cells[4].Value.ToString(), tbl.countPerf); //dgv.Rows.Remove(dgvr); //tbl.showTable(dgv, 0, 99, tbl.group, varData: false); //tbl.showTable(dgvVar, 100, 5000, tbl.groupVar, varData: true); //balloon(); }
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; }