private void rowDelete(BOMView bomView, DataGridView _dgv) { bool remove = true; foreach (DataGridViewRow dgvr in _dgv.Rows) { if (dgvr.Cells[3].Value != null && dgvr.Cells[2].Value.ToString() != "") { foreach (Inventor.BOMRow row in m_BOMView.BOMRows) { 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; string key = (string)oDoc.PropertySets[1][4].Value.ToString(); string pos = (string)row.ItemNumber; partNumber = partNumber.Trim(); if (partNumber == dgvr.Cells[3].Value.ToString() && desc == dgvr.Cells[4].Value.ToString()) { remove = false; break; } } if (remove && dgvr.Cells[4].Value.ToString().StartsWith("p")) { _dgv.Rows.Remove(dgvr); } remove = true; } } }
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); } } } } }
public MyBalloon(Inventor.Document oDoc) { if (oDoc.DocumentType == DocumentTypeEnum.kDrawingDocumentObject && InvDoc.u.referendedDoc(oDoc).DocumentType == DocumentTypeEnum.kAssemblyDocumentObject) { m_DrwDoc = (Inventor.DrawingDocument)oDoc; m_AsmDoc = (Inventor.AssemblyDocument)InvDoc.u.referendedDoc(oDoc); invApp = (Inventor.Application)oDoc.Parent; cmdMgr = invApp.CommandManager; interEvts = cmdMgr.CreateInteractionEvents(); selEvts = interEvts.SelectEvents; selEvts.AddSelectionFilter(SelectionFilterEnum.kDrawingCurveSegmentFilter); selEvts.SingleSelectEnabled = true; selEvts.OnSelect += new SelectEventsSink_OnSelectEventHandler(selectEvts); mouseEvts = interEvts.MouseEvents; mouseEvts.MouseMoveEnabled = true; mouseEvts.OnMouseClick += new MouseEventsSink_OnMouseClickEventHandler(mouseClick); mouseEvts.OnMouseMove += new MouseEventsSink_OnMouseMoveEventHandler(mouseMove); objs = invApp.TransientObjects.CreateObjectCollection(); interEvts.StatusBarText = "Первая точка выноски:"; interEvts.Start(); //dcs = (Inventor.DrawingCurveSegment)cmdMgr.Pick(SelectionFilterEnum.kDrawingCurveSegmentFilter, "Выберите компонент:"); //m_Type = obj.GetType(); //compOcc = (ComponentOccurrence)m_Type.GetProperty("ContainingOccurrence"); //interEvts.InteractionGraphics; //if (obj. // dcs.Parent.ModelGeometry.GetType() == Inventor.ObjectTypeEnum.kEdgeProxyObject) //{ //} } }
public CutOp(Inventor.Document newDoc) { if (newDoc.DocumentType == DocumentTypeEnum.kAssemblyDocumentObject) { m_PartDoc = (PartDocument)newDoc.ActivatedObject; } if (newDoc.DocumentType == DocumentTypeEnum.kPartDocumentObject) { m_PartDoc = (PartDocument)newDoc; } if (m_PartDoc.SubType == "{9C464203-9BAE-11D3-8BAD-0060B0CE6BB4}") { smcd = (SheetMetalComponentDefinition)m_PartDoc.ComponentDefinition; } smf = (SheetMetalFeatures)smcd.Features; CutDefinition cd = smf.CutFeatures.CreateCutDefinition(selectFromSketch()); try { cd.SetCutAcrossBendsExtent("Толщина"); } catch (Exception) { cd.SetCutAcrossBendsExtent("Thickness"); } smf.CutFeatures.Add(cd); }
public RecoverOp(Inventor.Document newDoc) { try { invApp = (Inventor.Application)newDoc.Parent; pathFile = newDoc.FullFileName.ToString(); pathFile = pathFile.Substring(0, pathFile.LastIndexOf('\\')); foreach (Document doc in invApp.Documents.VisibleDocuments) { XMLDoc xdoc = new XMLDoc(@"C:\ProgramData\Autodesk\Inventor Addins\rename.xml", "head"); recoverReference(doc, xdoc); } if (newDoc.DocumentType == DocumentTypeEnum.kAssemblyDocumentObject) { m_AsmDoc = (AssemblyDocument)newDoc; recoverAssembly(); tr.End(); } if (newDoc.DocumentType == DocumentTypeEnum.kDrawingDocumentObject) { m_DrwDoc = newDoc as DrawingDocument; recoverDrawing(); } } catch { } finally { tr.End(); } }
/// <summary> /// Gets the value of a numeric parameter. /// </summary> /// <param name="document"></param> /// <param name="parameterName"></param> /// <returns></returns> public static string GetParameterValue(this Inventor.Document document, string parameterName) { Parameter parameter = document.GetParameter(parameterName); UnitsOfMeasure uom = document.UnitsOfMeasure; if (!ParameterExists(parameter)) { return(String.Empty); } var value = parameter.Value; var unit = parameter.get_Units(); UnitsTypeEnum unitEnum; unitEnum = uom.GetTypeFromString(unit); switch (unitEnum) { case UnitsTypeEnum.kBooleanUnits: return((string)parameter.Value); case UnitsTypeEnum.kTextUnits: return((string)parameter.Value); default: return(uom.GetStringFromValue((double)value, unitEnum)); } }
public IMate(Inventor.Document oDoc, string name = "", string typ = "", string offset = "") { invApp = (Inventor.Application)oDoc.Parent; Doc = (Document)oDoc.ActivatedObject; if (Doc == null) { Doc = oDoc; } CmdMgr = invApp.CommandManager; objs = invApp.TransientObjects.CreateObjectCollection(); InitializeComponent(); XML n; string filePath = @"C:\ProgramData\Autodesk\Inventor Addins\Imate.xml"; if (!System.IO.File.Exists(filePath)) { MessageBox.Show("Отсутствует файл " + filePath); } n = new InvDoc.XML(filePath); data = new List <XMLData>(); data = n.ReadXML("Imates"); foreach (XMLData s in data) { this.comboBox3.Items.Add(s.val); } this.comboBox2.Text = offset; this.comboBox1.Text = typ; this.comboBox3.Text = name; //this.Deactivate += (sender, e) => MessageBox.Show("Deactivated!"); }
///<summary>Initializes a new instance of <see cref="StepExporter"/></summary> public StepExporter(Inventor.Document Document) { this.Document = Document; Application app = (Application)Document.Parent; Author = app.UserName; }
/// <summary> /// Returns a string if the user propertySets contain the specified property name. /// </summary> /// <param name="document"></param> /// <param name="propertyName"></param> /// <returns>string</returns> private static object GetSuperCustomPropertyValue(Inventor.Document document, string propertyName) { Property temp = document.GetSuperCustomProperty(propertyName); //try // { return(temp.Value ?? ""); // } //catch { return "";} }
public Passport(Inventor.Document pDoc, Inventor.Application m_InvApp) { InitializeComponent(); invApp = m_InvApp; if (pDoc.DocumentType == DocumentTypeEnum.kDrawingDocumentObject) { drwDoc = (DrawingDocument)pDoc; sheet = drwDoc.ActiveSheet; } }
public void _buttonDef1_OnExecute(NameValueMap Context) { Inventor.Document Document = m_inventorApplication.ActiveDocument; if (Document.DocumentType == Inventor.DocumentTypeEnum.kAssemblyDocumentObject) { Inventor.AssemblyDocument AssemblyDocument = (Inventor.AssemblyDocument)Document; IComDialog comDialog = new UIMain(); comDialog.RunUI(m_inventorApplication); } }
public Utility(Document newDoc) { m_doc = newDoc; if (m_doc.DocumentType == DocumentTypeEnum.kAssemblyDocumentObject) { m_Asm = (AssemblyDocument)m_doc; } if (m_doc.DocumentType == DocumentTypeEnum.kDrawingDocumentObject) { m_Drw = (DrawingDocument)m_doc; } }
public void _buttonDef1_OnExecute(NameValueMap Context) { Inventor.Document Document = m_inventorApplication.ActiveDocument; if (Document.DocumentType == Inventor.DocumentTypeEnum.kPartDocumentObject) { Inventor.PartDocument PartDocument = (Inventor.PartDocument)Document; // System.Windows.Forms.MessageBox.Show("Button clicked!!", "Ribbon Demo"); SetReps mSetting = new SetReps(); mSetting.Show(); mSetting.SetSettings(ref PartDocument); } }
public Offset(Inventor.Document newDoc) { if (newDoc.DocumentType == DocumentTypeEnum.kPartDocumentObject) { m_PartDoc = (PartDocument)newDoc; } if (newDoc.DocumentType == DocumentTypeEnum.kAssemblyDocumentObject) { asmDoc = (AssemblyDocument)newDoc; m_PartDoc = (PartDocument)asmDoc.ActivatedObject; } //addProject(); //return; tg = ((Inventor.Application)m_PartDoc.Parent).TransientGeometry; InitializeComponent(); }
public static Parameter GetParameter(this Inventor.Document document, string parameterName) { Parameters parameters = GetParameters(document); _ = parameters ?? throw new ArgumentException("This document " + document.FullDocumentName + " does not support parameters."); foreach (Parameter parameter in parameters) { if (parameter.Name == parameterName) { return(parameter); } } return(null); }
/// <summary> /// Returns a property object for a user-created custom property. /// </summary> /// <param name="document">Inventor.Document</param> /// <param name="propertyName"></param> /// <returns>Property</returns> private static Property GetSuperCustomProperty(this Inventor.Document document, string propertyName) { foreach (PropertySet i in document.PropertySets) { //ignore stock propertySets if (NativePropertySetLookup.Contains(i.DisplayName)) { continue; } foreach (Property j in i) { if (j.DisplayName == propertyName) { return(j); } } } return(null); }
/// <summary> /// Returns a Document Object subtype if a subtype exists. If not, a generic Inventor.Document is returned. /// </summary> /// <param name="document">Document object</param> /// <returns>dynamic</returns> public static dynamic ReturnSpecificDocumentObject(this Inventor.Document document) { switch (document) { case PartDocument d: return(d); case AssemblyDocument d: return(d); case DrawingDocument d: return(d); case PresentationDocument d: return(d); default: return(document); } }
public static void RemoveParameter(this Inventor.Document document, string parameterName) { //Parameters parameters = GetParameters(document); //_ = parameters ?? throw new ArgumentException("This document " + document.FullDocumentName + " does not support parameters."); Parameter parameter = document.GetParameter(parameterName); if (!ParameterExists(parameter)) { return; } if (!ParameterIsWritable(parameter)) { return; } if (parameter.InUse) { return; } parameter.Delete(); }
public BreakOp(Inventor.Document oDoc, bool hor) { if (oDoc.DocumentType == DocumentTypeEnum.kDrawingDocumentObject) { invApp = (Inventor.Application)oDoc.Parent; m_TG = invApp.TransientGeometry; cmdMgr = invApp.CommandManager; m_DrwDoc = (Inventor.DrawingDocument)oDoc; horizont = hor; m_View = (DrawingView)cmdMgr.Pick(SelectionFilterEnum.kDrawingViewFilter, "Вид для разрыва:"); interEvts = cmdMgr.CreateInteractionEvents(); //interEvts.InteractionDisabled = false; mouseEvts = interEvts.MouseEvents; mouseEvts.OnMouseClick += new MouseEventsSink_OnMouseClickEventHandler(mouseClick); interEvts.StatusBarText = "Первая точка разрыва:"; interEvts.Start(); //m_DrwDoc.ActiveSheet.DrawingViews //if ( m_DrwDoc.SelectSet[1] ) //pt1 = m_DrwDoc.SelectSet[1]; } }
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; } } } }
public static InvDocument ByInvDocument(Inventor.Document invDocument) { return(new InvDocument(invDocument)); }
///<summary>Initializes a new instance of <see cref="DwgExporter"/> with a custom export configuration file.</summary> public DwgExporter(Inventor.Document Document, string ConfigurationFile) { this.Document = Document; this.ConfigurationFile = ConfigurationFile; }
private InvDocument(Inventor.Document invDocument) { InternalDocument = invDocument; }
private InvDocument InternalAdd(InvDocumentTypeEnum documentTypeEnum, string templateFileName, bool createVisible) { Inventor.Application invApp = (Inventor.Application)InventorServices.Persistence.PersistenceManager.InventorApplication; Inventor.Document document = invApp.Documents.Add(InvDocumentTypeEnum.kAssemblyDocumentObject.As <DocumentTypeEnum>(), templateFileName, createVisible); return(InvDocument.ByInvDocument(document)); }
private static void wip_kDrawingCurveSegmentObject() { Inventor.Application oApp = ApplicationShim.CurrentInstance(); SelectSet oSSet = oApp.ActiveDocument.SelectSet; if (oSSet.Count == 0) { return; } Inventor.Document returnDocument = null; dynamic obj = oSSet[2]; switch (obj.type) { case 117478144: //kDrawingCurveSegmentObject //try to set the drawing curve object to point at the containingOccurrence object. //Edge Objects and Edge Proxy Objects DrawingCurveSegment drawingCurveSegment = (DrawingCurveSegment)obj; DrawingCurve drawingCurve = drawingCurveSegment.Parent; dynamic modelGeometry; try { modelGeometry = drawingCurve.ModelGeometry; } catch { Console.WriteLine("Are you sure the object can be found? The ModelGeometry cannot be located. exiting..."); Console.ReadLine(); return; } ComponentOccurrence componentOccurrence; try //for a selected DrawingCurveSegment belonging to an assembly component { componentOccurrence = modelGeometry.ContainingOccurrence; returnDocument = (Document)componentOccurrence.Definition.Document; break; } catch { } try //for a selected DrawingCurveSegment belonging to a part { returnDocument = (Document)modelGeometry.Parent.ComponentDefinition.Document; break; } catch { } break; } if (returnDocument == null) { Console.WriteLine("The document could not be found!"); } else { Console.WriteLine("Document Type: " + returnDocument.DocumentSubType); Console.WriteLine(returnDocument.FullFileName); } Console.ReadLine(); }
///<summary>Initializes a new instance of <see cref="DwgExporter"/> with the default export configuration.</summary> public DwgExporter(Inventor.Document Document) { this.Document = Document; }
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; }