public void Works_isInvisible() { Inventor.Application app = null; app = ApplicationShim.NewInstance(false); try { Assert.IsNotNull(app); } finally { if (app != null) { Process[] procs = Process.GetProcessesByName("Inventor"); app.Quit(); if (procs.Length == 1) { procs[0].WaitForExit(); } Marshal.ReleaseComObject(app); app = null; //GC.Collect(); //GC.WaitForPendingFinalizers(); } } }
public InsertXportForm(Inventor.Application application, InsertXportCmd insertXportCmd) { InitializeComponent(); m_inventorApplication = application; m_insertXportCmd = insertXportCmd; radiobtn2.Checked = true; }
public Inventor.Camera GetDocument(ref Inventor._Document Document, ref Inventor.Application invApplication) { Inventor.PartDocument PartDocument = null; Inventor.Camera Camera = null; mInvApplication = invApplication; if (Document.DocumentType == Inventor.DocumentTypeEnum.kPartDocumentObject) { PartDocument = (Inventor.PartDocument)Document; if (PartDocument != null) { if (PartDocument.ComponentDefinitions.Count > 0) { Camera = mInvApplication.ActiveView.Camera; Inventor.PartComponentDefinition PartComponentDefinition = PartDocument.ComponentDefinitions[1]; foreach (Inventor.SurfaceBody SurfaceBody in PartComponentDefinition.SurfaceBodies) { GetFaceToView(SurfaceBody, ref PartDocument, ref Camera); } return(Camera); } } } return(Camera); }
private void Form1_Load(object sender, EventArgs e) { try { _InvApplication = System.Runtime.InteropServices.Marshal.GetActiveObject("Inventor.Application") as Inventor.Application; } catch { Type inventorAppType = System.Type.GetTypeFromProgID("Inventor.Application"); _InvApplication = System.Activator.CreateInstance(inventorAppType) as Inventor.Application; } _InvApplication.Visible = true; string addInCLSID = "{28e1f9bc-44fb-464c-ba98-e9c14c7eed44}"; Inventor.ApplicationAddIn addIn = _InvApplication.ApplicationAddIns.get_ItemById(addInCLSID.ToUpper()); //Make sure addin is activated if (!addIn.Activated) { addIn.Activate(); } _InvAddInInterface = addIn.Automation as HelloWorldCS.AutomationInterface; }
private void Form1_Load(object sender, EventArgs e) { try { InvApp = (Inventor.Application)System.Runtime.InteropServices.Marshal.GetActiveObject("Inventor.Application"); } catch { System.Windows.Forms.MessageBox.Show("Starting a New Inventor Session"); } if (InvApp == null) { Type inventorAppType = System.Type.GetTypeFromProgID("Inventor.Application"); InvApp = System.Activator.CreateInstance(inventorAppType) as Inventor.Application; InvApp.Visible = true; } Inventor.Document Document = InvApp.ActiveDocument; if (Document.DocumentType == Inventor.DocumentTypeEnum.kAssemblyDocumentObject) { Inventor.AssemblyDocument AssemblyDocument = (Inventor.AssemblyDocument)Document; foreach (Inventor.OccurrencePattern OccurrencePattern in AssemblyDocument.ComponentDefinition.OccurrencePatterns) { if (OccurrencePattern.Type == Inventor.ObjectTypeEnum.kRectangularOccurrencePatternObject) { Inventor.RectangularOccurrencePattern RectangularOccurrencePattern; RectangularOccurrencePattern = (Inventor.RectangularOccurrencePattern)OccurrencePattern; foreach (Inventor.OccurrencePatternElement OccurrencePatternElement in RectangularOccurrencePattern.OccurrencePatternElements) { cmbElements.Items.Add(OccurrencePatternElement.Name); } } } } }
public void Activate(Inventor.ApplicationAddInSite addInSiteObject, bool firstTime) { log.Debug("Activating ThreadModeler Addin"); // This method is called by Inventor when it loads the addin. // The AddInSiteObject provides access to the Inventor Application object. // The FirstTime flag indicates if the addin is loaded for the first time. // Initialize AddIn members. m_inventorApplication = addInSiteObject.Application; Type addinType = this.GetType(); AdnInventorUtilities.Initialize(m_inventorApplication, addinType); Toolkit.Initialize(m_inventorApplication); ThreadWorker.Initialize(m_inventorApplication); AdnCommand.AddCommand(new ThreadModelerCmd(m_inventorApplication)); AdnCommand.AddCommand(new AboutCtrlCmd(m_inventorApplication)); AdnCommand.AddCommand(new HelpCtrlCmd(m_inventorApplication)); // Only after all commands have been added, // load Ribbon UI from customized xml file. // Make sure "InternalName" of above commands is matching // "internalName" tag described in xml of corresponding command. AdnRibbonBuilder.CreateRibbon( m_inventorApplication, addinType, "ThreadModeler.resources.ribbons.xml"); }
/// <summary> /// Saves the .ipt. /// </summary> /// <param name="app"> /// Link to Inventor. /// </param> public static void SavePart(Inventor.Application app, SaveFileDialog saveFileDialog, Form form, Model.InventorAPI api) { app = AppActivity(app); if (app == null) { return; } try { saveFileDialog.Filter = "Inventor Part Document|*.ipt"; saveFileDialog.Title = api.GetLongName(); saveFileDialog.FileName = api.GetPartDoc().DisplayName; if (saveFileDialog.ShowDialog() == DialogResult.OK) { if (!string.IsNullOrWhiteSpace(saveFileDialog.FileName)) { api.GetPartDoc().SaveAs(saveFileDialog.FileName, false); api.SetFileName(saveFileDialog.FileName); } } form.Close(); } catch { MessageBox.Show("Деталь ещё не создана, либо программа не видит созданную деталь.", form.Text); } }
public static void Draw(ref Inventor.Application _InvApplication, string Type) { string GraphicsName = "CG_Test"; Inventor.AssemblyDocument assemblyDocument = (Inventor.AssemblyDocument)_InvApplication.ActiveDocument; Inventor.ComponentOccurrences Occurrences = assemblyDocument.ComponentDefinition.Occurrences; if (Type == "Run") { // Test(ref _InvApplication,ref assemblyDocument, GraphicsName); //TestDrawRangeBoxs(ref _InvApplication, ref assemblyDocument, ref Occurrences, GraphicsName); Inventor.ClientGraphics ClientGraphics = null; DeleteNamedGraphics(ref assemblyDocument, GraphicsName); ClientGraphics = assemblyDocument.ComponentDefinition.ClientGraphicsCollection.Add(GraphicsName); DrawClientGraphicSolid(ref _InvApplication, ref ClientGraphics, ref assemblyDocument, "Clear - Green 1"); SetHighLightSet(ref _InvApplication, ref assemblyDocument, ref Occurrences, ""); } else { DeleteNamedGraphics(ref assemblyDocument, GraphicsName); _InvApplication.ActiveView.Update(); } // Inventor.AssemblyComponentDefinition ComponentDefinition = null; // Inventor.ClientGraphics ClientGraphics = null; }
/// <summary> /// Constructor for the CWBasket Form. /// </summary> /// <param name="invApp">Current Inventor Applciation</param> public MeshBasketForm(Inventor.Application invApp) { InitializeComponent(); this.CenterToParent(); this.invApp = invApp; resetDefault(); // Set Default Values for text blocks }
public void Activate(Inventor.ApplicationAddInSite addInSiteObject, bool firstTime) { // This method is called by Inventor when it loads the AddIn. // The AddInSiteObject provides access to the Inventor Application object. // The FirstTime flag indicates if the AddIn is loaded for the first time. // Initialize AddIn members. log.Debug("ScreenShot loaded!"); m_inventorApplication = addInSiteObject.Application; m_ClientId = "{b3aa6727-f2d0-4c6d-8150-16fa9c493dff}"; Type addinType = this.GetType(); AdnCommand.AddCommand( new ScreenGrabCtrlCmd( m_inventorApplication)); AdnCommand.AddCommand( new ScreengrabAboutCtrlCmd( m_inventorApplication)); AdnCommand.AddCommand( new ScreenGrabHelpCtrlCmd( m_inventorApplication)); // Only after all commands have been added, // load Ribbon UI from customized xml file. // Make sure "InternalName" of above commands is matching // "internalName" tag described in xml of corresponding command. AdnRibbonBuilder.CreateRibbon( m_inventorApplication, addinType, "InventorScreenshot.Resources.ribbons.xml"); }
public static void Run(ref Inventor.Application _InvApplication, string Type) { Inventor.AssemblyDocument assemblyDocument = (Inventor.AssemblyDocument)_InvApplication.ActiveDocument; CInvInputEvents evt = new CInvInputEvents(_InvApplication); evt.OnSelectionChange += Evt_OnSelectionChange; }
public CFlange(ref Inventor.Application InvApplication, ref Inventor.PartDocument invPartDocument, ref Inventor.UnitsTypeEnum UnitsType, string szworkplanename, string szDiaOD, string szDiaID, string szThickness, string szPCD, string szBoltHoleDia, string szNumberBoltHoles) { szWorkPlaneName = szworkplanename; InvApp = InvApplication; PartDocument = invPartDocument; CToModelValue.ConvertFlatFacedFlangeDimsToModelWorldUnits(ref PartDocument, ref UnitsType, szDiaOD, szDiaID, szThickness, szPCD, szBoltHoleDia, szNumberBoltHoles, out FlangeDiaOD, out FlangeDiaID, out FlangeThickness, out FlangePlacedCenterDiameter, out FlangeBoltHoleDia, out FlangeNumberBoltHoles); }
/// ////////////////////////////////////////////////////////////////////////////////////////////////////// private static void DrawClientGraphicSolid(ref Inventor.Application _InvApplication, ref Inventor.ClientGraphics ClientGraphics, ref Inventor.AssemblyDocument assemblyDocument, string AssetName) {//"Clear - Green 1" "Clear" Inventor.Asset localAsset; localAsset = assemblyDocument.Assets[AssetName]; Inventor.GraphicsNode SurfacesNode = ClientGraphics.AddNode(1); SurfacesNode.Appearance = localAsset; Inventor.Box box = null; Inventor.SurfaceBody SurfaceBody; Inventor.TransientBRep TransientBRep; TransientBRep = _InvApplication.TransientBRep; Inventor.SurfaceGraphics SurfaceGraphics; int length = assemblyDocument.ComponentDefinition.Occurrences.Count; for (int i = length; i >= 1; i--) { if (GetInventorObjType(assemblyDocument.ComponentDefinition.Occurrences[i]) == Inventor.ObjectTypeEnum.kComponentOccurrenceObject) { Inventor.ComponentOccurrence componentOccurrence = assemblyDocument.ComponentDefinition.Occurrences[i]; box = componentOccurrence.RangeBox; SurfaceBody = TransientBRep.CreateSolidBlock(box.Copy()); SurfaceGraphics = SurfacesNode.AddSurfaceGraphics(SurfaceBody); SurfacesNode.Appearance = localAsset; } } _InvApplication.ActiveView.Update(); }
private void Setting_Load(object sender, EventArgs e) { try { _InvApplication = System.Runtime.InteropServices.Marshal.GetActiveObject("Inventor.Application") as Inventor.Application; } catch { Type inventorAppType = System.Type.GetTypeFromProgID("Inventor.Application"); _InvApplication = System.Activator.CreateInstance(inventorAppType) as Inventor.Application; } _InvApplication.Visible = true; string addInCLSID = "{55488e4a-45de-4630-a00c-b31e0eb17ba8}"; Inventor.ApplicationAddIn addIn = _InvApplication.ApplicationAddIns.get_ItemById(addInCLSID.ToUpper()); //Make sure addin is activated if (!addIn.Activated) { addIn.Activate(); } // _InvAddInInterface = addIn.Automation as InventorViewsServer.IAutomationInterface; }
public UserGUI() { InitializeComponent(); _InvApplication = null; try { _InvApplication = (Inventor.Application)System.Runtime.InteropServices.Marshal.GetActiveObject("Inventor.Application"); } catch { if (System.Windows.Forms.MessageBox.Show("Trying to Open a new instance of Autodesk Inventor", "Inventor Error", System.Windows.Forms.MessageBoxButtons.OKCancel, System.Windows.Forms.MessageBoxIcon.Question) != System.Windows.Forms.DialogResult.OK) { return; //To Caller } } if (_InvApplication == null) { try { Type inventorAppType = System.Type.GetTypeFromProgID("Inventor.Application"); _InvApplication = System.Activator.CreateInstance(inventorAppType) as Inventor.Application; } catch { System.Windows.Forms.MessageBox.Show("Can Not Open Autodesk Inventor " + Environment.NewLine + "See Your Administrator", "Instalation Error", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Question); return; } } cClientGraphics = new CClientGraphic(ref _InvApplication); }
public CExportDXF(string PartNumberPreFixIdent, string FileSaveLocation, ref Inventor.Application InvApplication) { mInvApplication = InvApplication; FileSaveUrl = ""; IsFileNameQtyAdded = false; FaceViews = new CDrawingView(ref InvApplication); //logWriter = new System.IO.StreamWriter("E:\\LogParts.txt"); if (PartNumberPreFixIdent != "") { PartNumberID = PartNumberPreFixIdent; } else { PartNumberID = "P"; } if (FileSaveLocation != "") { FileSaveUrl = FileSaveLocation; } else { FileSaveUrl = ""; } }
private void TestFrm_FormClosed(object sender, FormClosedEventArgs e) { while (System.Runtime.InteropServices.Marshal.ReleaseComObject(InvApp) > 0) { } InvApp = null; GC.Collect(); GC.WaitForPendingFinalizers(); }
private void Build_Click(object sender, EventArgs e) { app = Auto.AppActivity(app); if (app == null) { return; } Model.Assembly.Build(app, openFileDialog1, Text); }
public EditNetForm(Inventor.Application application, EditNetCmd editNetCmd) { InitializeComponent(); m_inventorApplication = application; m_editNetCmd = editNetCmd; checkBoxChoose.Checked = true; btnedit.Enabled = false; dataportNET.ClearSelection(); }
public DeleteCavityForm(Inventor.Application application, DeleteCmd deleteCmd) { InitializeComponent(); m_inventorApplication = application; m_deleteCmd = deleteCmd; this.btnsure.Enabled = false; this.checkBoxChoose.Checked = true; }
public RotateForm(Inventor.Application application, RotateCmd rotateCmd) { InitializeComponent(); m_inventorApplication = application; m_rotateCmd = rotateCmd; checkBoxChoose.Checked = true; btnsure.Enabled = false; comboBoxAngle.Text = "0"; }
private static void Test(ref Inventor.Application _InvApplication, ref Inventor.AssemblyDocument assemblyDocument, string ClientGraphicsName) { Inventor.AssemblyComponentDefinition ComponentDefinition = assemblyDocument.ComponentDefinition; // add ClientGraphics Inventor.ClientGraphics ClientGraphics = null; ClientGraphics = DeleteNamedGraphics(ref assemblyDocument, ClientGraphicsName); ClientGraphics = ComponentDefinition.ClientGraphicsCollection.Add(ClientGraphicsName); //add GraphicsDataSets Inventor.GraphicsDataSets GraphDataSets; try { GraphDataSets = assemblyDocument.GraphicsDataSetsCollection[ClientGraphicsName]; if (GraphDataSets != null) { GraphDataSets.Delete(); } } catch { } GraphDataSets = assemblyDocument.GraphicsDataSetsCollection.Add(ClientGraphicsName); Inventor.GraphicsCoordinateSet oCoordSet = GraphDataSets.CreateCoordinateSet(1); // add GraphicsNode Inventor.GraphicsNode LineNode = ClientGraphics.AddNode(1); // add LineGraphics Inventor.LineGraphics LineSet = LineNode.AddLineGraphics(); LineSet.CoordinateSet = oCoordSet; Inventor.TransientGeometry oTG = _InvApplication.TransientGeometry; oCoordSet.Add(1, oTG.CreatePoint(0, 0, 0)); oCoordSet.Add(2, oTG.CreatePoint(20, 30, 0)); oCoordSet.Add(3, oTG.CreatePoint(40, 20, 0)); oCoordSet.Add(4, oTG.CreatePoint(60, 30, 100)); // set LineDefinitionSpace as screen space LineSet.LineDefinitionSpace = Inventor.LineDefinitionSpaceEnum.kScreenSpace; // set Colour Inventor.GraphicsColorSet graphicsColorSet = LineSet.ColorSet; graphicsColorSet = GraphDataSets.CreateColorSet(1); LineSet.ColorSet = graphicsColorSet; LineSet.ColorSet.Add(1, 255, 1, 0); // set lineweight LineSet.LineWeight = 2; // set LineType LineSet.LineType = Inventor.LineTypeEnum.kChainLineType; // set LineScale LineSet.LineScale = 2; _InvApplication.ActiveView.Update(); }
private void Build_Click(object sender, EventArgs e) { app = Auto.AppActivity(app); if (app == null) { return; } api = new Model.InventorAPI(app, "КК", "Конический корпус"); Model.Parts.MainBody.Build(api, Text); }
public CDXFExport(string PartNumberIdent, string FileSaveLocation, ref Inventor.Application InvApplication) { mInvApplication = InvApplication; PartNumberID = PartNumberIdent; FaceViews = new CDrawingView(ref InvApplication); Inventor.AssemblyDocument AssemblyDocument = (Inventor.AssemblyDocument)mInvApplication.ActiveDocument; GetAllPartsInBom(ref AssemblyDocument); }
private void Build_Click(object sender, EventArgs e) { app = Auto.AppActivity(app); if (app == null) { return; } api = new Model.InventorAPI(app, "К", "Крышка"); Model.Parts.Top.Build(api, Text); }
public void Deactivate() { // This method is called by Inventor when the AddIn is unloaded. // The AddIn will be unloaded either manually by the user or // when the Inventor session is terminated. // Release objects. Marshal.ReleaseComObject(m_inventorApplication); m_inventorApplication = null; }
private void Build_Click(object sender, EventArgs e) { app = Auto.AppActivity(app); if (app == null) { return; } api = new Model.InventorAPI(app, "БО", "Боковые опоры"); Model.Parts.Hold.Build(api, Text); }
public CDXFExport(ref System.Windows.Forms.ListBox ListBoxComponents, string PartNumberIdent, string FileSaveLocation, ref Inventor.Application InvApplication) { mInvApplication = InvApplication; ListComponents = ListBoxComponents; PartNumberID = PartNumberIdent; FaceViews = new CDrawingView(ref InvApplication); Inventor.AssemblyDocument AssemblyDocument = (Inventor.AssemblyDocument)mInvApplication.ActiveDocument; GetAllPartsInBom(ref AssemblyDocument); }
private void Build_Click(object sender, EventArgs e) { app = Auto.AppActivity(app); if (app == null) { return; } api = new Model.InventorAPI(app, "КВ", "Корпус для выгрузки материалов"); Model.Parts.Bottom.Build(api, Text); }
private void Build_Click(object sender, EventArgs e) { app = Auto.AppActivity(app); if (app == null) { return; } api = new Model.InventorAPI(app, "Шнек", "Шнек"); Model.Parts.Auger.Build(api, base.Text); }
public static void Main(string[] args) { Console.Title = Title; //Hide the Console Window IntPtr hWnd = FindWindow(null, Console.Title); if (hWnd != IntPtr.Zero) { //SW_HIDE = 0 ShowWindow(hWnd, 0); } bool retry = false; do { try { retry = false; _InvApplication = (Inventor.Application) (System.Runtime.InteropServices.Marshal.GetActiveObject("Inventor.Application")); mForm = new Form1(_InvApplication); mForm.Text = Title; mForm.ShowDialog(); } catch (Exception) { string Message = "Inventor is not running..."; string Caption = Title + " Sample Error"; MessageBoxButtons Buttons = MessageBoxButtons.RetryCancel; DialogResult Result = MessageBox.Show(Message, Caption, Buttons, MessageBoxIcon.Exclamation); switch (Result) { case DialogResult.Retry: retry = true; break; case DialogResult.Cancel: return; } } } while (retry == true); }
/// <summary> /// Конструктор с входными параметрами модели /// </summary> /// <param name="houseProperties">Параметры модели</param> /// <param name="inventorApi"></param> public HouseModel(HouseProperties houseProperties, InventorApi inventorApi) { _houseProperties = houseProperties; _api = inventorApi; InventorApplication = inventorApi.InventorApplication; }