Beispiel #1
0
        /// <summary>
        /// Opens box.ipt and runs SamplePlugin
        /// </summary>
        /// <param name="app"></param>
        private static void DebugSamplePlugin(InventorServer app)
        {
            // get project directory
            string projectdir = Directory.GetParent(Directory.GetCurrentDirectory()).Parent.FullName;

            // get box.ipt absolute path
            string boxPath = System.IO.Path.Combine(projectdir, @"inputFiles", "box.ipt");

            // open box.ipt by Inventor
            Document doc = app.Documents.Open(boxPath);

            // get params.json absolute path
            string outputPath = System.IO.Path.Combine(projectdir, @"outputFiles\");

            // create a name value map
            Inventor.NameValueMap map = app.TransientObjects.CreateNameValueMap();

            // add parameters into the map, do not change "_1". You may add more parameters "_2", "_3"...
            map.Add("_1", outputPath);

            // create an instance of CreateBitmapsBundlePlugin
            CreateBitmapsBundlePlugin.SampleAutomation plugin = new CreateBitmapsBundlePlugin.SampleAutomation(app);

            // run the plugin
            plugin.RunWithArguments(doc, map);
        }
        /// <summary>
        /// Opens box.ipt and runs samplePlugin
        /// </summary>
        /// <param name="app"></param>
        private static void DebugSamplePlugin(InventorServer app)
        {
            string projectDir = Directory.GetParent(Directory.GetCurrentDirectory()).Parent.FullName;
            string sampleDir  = System.IO.Path.Combine(projectDir, "sample");
            string outputDir  = System.IO.Path.Combine(projectDir, "output");

            if (System.IO.Directory.Exists(outputDir))
            {
                System.IO.Directory.Delete(outputDir, true);
            }
            CopyDirectory(sampleDir, outputDir);

            // open the template Inventor file in the copied folder
            //Document doc = app.Documents.Open(System.IO.Path.Combine(outputDir, "template.iam"));

            // create a name value map for additional parameters to the Inventor plugin
            Inventor.NameValueMap args = app.TransientObjects.CreateNameValueMap();
            // add configuration into the map, do not change "_1". You may add more parameters "_2", "_3"...
            args.Add("_1", System.IO.Path.Combine(outputDir, "config.json"));
            // add absolute path to the folder with all STEP files
            args.Add("_2", System.IO.Path.Combine(outputDir, "modules"));

            // create an instance of DesignAutomationForInventor1Plugin
            DesignAutomationForInventor1Plugin.SampleAutomation plugin = new DesignAutomationForInventor1Plugin.SampleAutomation(app);

            // run the plugin
            plugin.RunWithArguments(null, args);
        }
 /// <summary>
 /// Event Handler for the button's execute event
 /// </summary>
 /// <param name="context"></param>
 protected virtual void ClientRectangleButtonDefinition_OnExecute(Inventor.NameValueMap context)
 {
     invApplication.CommandManager.StopActiveCommand();
     this.ButtonPressed = true;
     CommandIsRunning   = true;
     clientRectangleLogicInstance.StartRectangleInteraction();
 }
Beispiel #4
0
        /// <summary>
        /// Opens box.ipt and runs SamplePlugin
        /// </summary>
        /// <param name="app"></param>
        private static void DebugSamplePlugin(InventorServer app)
        {
            Document doc = null;

            // create a name value map
            Inventor.NameValueMap map = app.TransientObjects.CreateNameValueMap();

            // add parameters into the map, do not change "_1". You may add more parameters "_2", "_3"...
            //map.Add("_1", paramsPath);

            // create an instance of InventorIpartMakerDAPlugin
            InventorIpartMakerDAPlugin.SampleAutomation plugin = new InventorIpartMakerDAPlugin.SampleAutomation(app);

            // run the plugin
            plugin.RunWithArguments(doc, map);
        }
        /// <summary>
        /// Opens box.ipt and runs samplePlugin
        /// </summary>
        /// <param name="app"></param>
        private static void DebugSamplePlugin(InventorServer app)
        {
            // get solution directory
            string solutiondir        = Directory.GetParent(Directory.GetCurrentDirectory()).Parent.Parent.FullName;
            string inputFilesDir      = System.IO.Path.Combine(solutiondir, @"clientApp\inputFiles\");
            string inputFilesLocalDir = System.IO.Path.Combine(solutiondir, @"debugPluginLocally\inputFiles\");

            // get box.ipt absolute path
            string boxPath     = System.IO.Path.Combine(inputFilesDir, "box.ipt");
            string boxPathCopy = System.IO.Path.Combine(inputFilesLocalDir, "boxcopy.ipt");

            try
            {
                // delete an existing file
                System.IO.File.Delete(boxPathCopy);
            }
            catch (IOException)
            {
                Console.WriteLine("The specified file is in use. It might be open by Inventor");
                return;
            }

            // create a copy
            System.IO.File.Copy(boxPath, boxPathCopy);

            // open box.ipt by Inventor
            Document doc = app.Documents.Open(boxPathCopy);

            // get paramsSmall.json absolute path
            string paramsPathSmall = System.IO.Path.Combine(inputFilesDir, "paramsSmall.json");

            // get paramsLarge.json absolute path
            string paramsPathLarge = System.IO.Path.Combine(inputFilesDir, "paramsLarge.json");

            // create a name value map
            Inventor.NameValueMap map = app.TransientObjects.CreateNameValueMap();

            // add parameters into the map, do not change "_1". You may add more parameters "_2", "_3"...
            map.Add("_1", paramsPathSmall);
            map.Add("_2", paramsPathLarge);

            // create an instance of samplePlugin
            samplePlugin.SampleAutomation plugin = new samplePlugin.SampleAutomation(app);

            // run the plugin
            plugin.RunWithArguments(doc, map);
        }
Beispiel #6
0
        /// <param name="app"></param>
        private static void DebugSamplePlugin(InventorServer app)
        {
            //NOTE:Posible enhancement: Create a copy of the main ipt file first and work with that

            // open rail-layout-copy.ipt by Inventor
            //Document doc = app.Documents.Open(sketchPath);

            // create a name value map
            Inventor.NameValueMap map = app.TransientObjects.CreateNameValueMap();
            //map.Add("_1", inputParamsPath);

            // create an instance of LayoutSketchServicePlugin
            LayoutSketchServicePlugin.SampleAutomation plugin = new LayoutSketchServicePlugin.SampleAutomation(app);

            // run the plugin
            plugin.RunWithArguments(null, map);
        }
Beispiel #7
0
            public static bool ExportDwf(
                Inventor.Application App,
                Document doc,
                string filename)
            {
                try
                {
                    TranslatorAddIn translator = App.ApplicationAddIns.get_ItemById(
                        "{0AC6FD95-2F4D-42CE-8BE0-8AEA580399E4}") as TranslatorAddIn;

                    Inventor.TranslationContext ctx = App.TransientObjects.CreateTranslationContext();
                    ctx.Type = Inventor.IOMechanismEnum.kFileBrowseIOMechanism;

                    Inventor.NameValueMap options = App.TransientObjects.CreateNameValueMap();

                    Inventor.DataMedium medium = App.TransientObjects.CreateDataMedium();

                    if (translator.get_HasSaveCopyAsOptions(medium, ctx, options))
                    {
                        options.set_Value("Launch_Viewer", 0);
                        options.set_Value("Publish_Mode", 62723);
                        options.set_Value("Publish_All_Sheets", 1);

                        Inventor.NameValueMap sheets       = App.TransientObjects.CreateNameValueMap();
                        Inventor.NameValueMap sheetOptions = App.TransientObjects.CreateNameValueMap();

                        sheetOptions.Add("Name", "Sheet:1");
                        sheetOptions.Add("3DModel", false);
                        sheets.set_Value("Sheet1", sheetOptions);

                        options.set_Value("Sheets", sheets);
                    }

                    medium.FileName = filename;

                    translator.SaveCopyAs(doc, ctx, options, medium);

                    return(true);
                }
                catch (Exception e)
                {
                    return(false);
                }
            }
Beispiel #8
0
        /// <summary>
        /// Opens box.ipt and runs SamplePlugin
        /// </summary>
        /// <param name="app"></param>
        private static void DebugSamplePlugin(InventorServer app)
        {
            // get project directory
            //string projectdir = Directory.GetParent(Directory.GetCurrentDirectory()).Parent.FullName;

            // get box.ipt absolute path
            //string boxPath = System.IO.Path.Combine(projectdir, @"inputFiles\", "box.ipt");

            //string boxPathCopy = System.IO.Path.Combine(projectdir, @"inputFiles\", "boxcopy.ipt");

            try
            {
                // delete an existing file
                //System.IO.File.Delete(boxPathCopy);
            }
            catch (IOException)
            {
                Console.WriteLine("The specified file is in use. It might be open by Inventor");
                return;
            }

            // create a copy
            //System.IO.File.Copy(boxPath, boxPathCopy);

            // open box.ipt by Inventor
            //Document doc = app.Documents.Open(boxPathCopy);

            // get params.json absolute path
            //string paramsPath = System.IO.Path.Combine(projectdir, @"inputFiles\", "params.json");

            // create a name value map
            Inventor.NameValueMap map = app.TransientObjects.CreateNameValueMap();

            // add parameters into the map, do not change "_1". You may add more parameters "_2", "_3"...
            //map.Add("_1", paramsPath);

            // create an instance of ExtractParamsPlugin
            ExtractParamsPlugin.SampleAutomation plugin = new ExtractParamsPlugin.SampleAutomation(app);

            // run the plugin
            plugin.IsLocalDebug = true;
            plugin.Run(app.Documents[1]);
        }
        /// <summary>
        /// when [DoBrowserEvents] button is clicked.
        /// </summary>
        /// <param name="Context"></param>
        /// <remarks></remarks>
        private void m_DoBrowserEvents_OnExecute(Inventor.NameValueMap Context)
        {
            if (m_DoBrowserEvents.Pressed == false)
            {
                MessageBox.Show("BrowserEvents Starts!");

                m_DoBrowserEvents.Pressed = true;

                m_BrowserEvents = m_inventorApplication.ActiveDocument.BrowserPanes.BrowserPanesEvents;
            }
            else
            {
                MessageBox.Show("BrowserEvents Stops!");

                m_DoBrowserEvents.Pressed = false;

                m_BrowserEvents = null;
            }
        }
Beispiel #10
0
        /// <summary>
        /// Opens box.ipt and runs SamplePlugin
        /// </summary>
        /// <param name="app"></param>
        private static void DebugSamplePlugin(InventorServer app)
        {
            // get project directory
            string projectdir = Directory.GetParent(Directory.GetCurrentDirectory()).Parent.FullName;

            //// get box.ipt absolute path
            //string boxPath = System.IO.Path.Combine(projectdir, @"inputFiles\", "box.ipt");

            //string boxPathCopy = System.IO.Path.Combine(projectdir, @"inputFiles\", "boxcopy.ipt");

            //try
            //{
            //    // delete an existing file
            //    System.IO.File.Delete(boxPathCopy);
            //}
            //catch (IOException)
            //{
            //    Console.WriteLine("The specified file is in use. It might be open by Inventor");
            //    return;
            //}

            //// create a copy
            //System.IO.File.Copy(boxPath, boxPathCopy);

            // open the top level assmebly in Inventor
            string   assemblyPath = System.IO.Path.Combine(projectdir, @"inputFiles\", "Wrench.iam");
            Document doc          = app.Documents.Open(assemblyPath);

            // get params.json absolute path
            string paramsPath = System.IO.Path.Combine(projectdir, @"inputFiles\", "params.json");

            // create a name value map
            Inventor.NameValueMap map = app.TransientObjects.CreateNameValueMap();

            // add parameters into the map, do not change "_1". You may add more parameters "_2", "_3"...
            map.Add("_1", paramsPath);

            // create an instance of DaWrenchConfigPlugin
            DaWrenchConfigPlugin.SampleAutomation plugin = new DaWrenchConfigPlugin.SampleAutomation(app);

            // run the plugin
            plugin.RunWithArguments(doc, map);
        }
        /// <summary>
        /// When [HierarchicalBrowser] button is clicked
        /// </summary>
        /// <param name="Context"></param>
        /// <remarks></remarks>

        private void m_TreeViewBrowser_OnExecute(Inventor.NameValueMap Context)
        {
            Document oDoc = default(Document);

            oDoc = m_inventorApplication.ActiveDocument;

            BrowserPanes oPanes = default(BrowserPanes);

            oPanes = oDoc.BrowserPanes;

            //Create a standard Microsoft Windows IPictureDisp referencing an icon (.bmp) bitmap file.
            //Change the file referenced here as appropriate - here the code references test.bmp.
            //This is the icon that will be displayed at this node. Add the IPictureDisp to the client node resource.

            ClientNodeResources oRscs = oPanes.ClientNodeResources;

            stdole.IPictureDisp clientNodeIcon = AxHostConverter.ImageToPictureDisp(new Bitmap(@"Resources\test.bmp"));

            ClientNodeResource oRsc = oRscs.Add(m_ClientId, 1, clientNodeIcon);

            BrowserNodeDefinition oDef = (BrowserNodeDefinition)oPanes.CreateBrowserNodeDefinition("Top Node", 3, oRsc);

            //adding a new pane tab to the panes collection, define the top node the pane will contain.
            Inventor.BrowserPane oPane = oPanes.AddTreeBrowserPane("My Pane", m_ClientId, oDef);

            //Add two child nodes to the tree, labeled Node 2 and Node 3.
            BrowserNodeDefinition oDef1  = (BrowserNodeDefinition)oPanes.CreateBrowserNodeDefinition("Node2", 5, oRsc);
            BrowserNode           oNode1 = oPane.TopNode.AddChild(oDef1);

            BrowserNodeDefinition oDef2  = (BrowserNodeDefinition)oPanes.CreateBrowserNodeDefinition("Node3", 6, oRsc);
            BrowserNode           oNode2 = oPane.TopNode.AddChild(oDef2);

            //Add the native node (from root)  of "Model" pane to the tree
            BrowserNode oNativeRootNode = default(BrowserNode);

            oNativeRootNode = oDoc.BrowserPanes["Model"].TopNode;

            oPane.TopNode.AddChild(oNativeRootNode.BrowserNodeDefinition);
        }
        /// <summary>
        /// when [ActiveXBrowser] button is clicked
        /// </summary>
        /// <param name="Context"></param>
        /// <remarks></remarks>

        private void m_ActiveXBrowser_OnExecute(Inventor.NameValueMap Context)
        {
            //get active document
            Document oDoc = m_inventorApplication.ActiveDocument;

            //get the BrowserPanes
            BrowserPanes oPanes = default(BrowserPanes);

            oPanes = oDoc.BrowserPanes;

            //add the BrowserPane with the control
            BrowserPane oPane = default(BrowserPane);

            oPane = oPanes.Add("MyActiveXPane", "BrowserSample.UserControl1");

            //get the control
            m_ActiveX = (UserControl1)oPane.Control;

            //call a method of the control
            m_ActiveX.DrawASketchRectangle(m_inventorApplication);

            //activate the BrowserPane
            oPane.Activate();
        }
 private void m_BrowserEvents_OnBrowserNodeLabelEdit(object BrowserNodeDefinition, string NewLabel, Inventor.EventTimingEnum BeforeOrAfter, Inventor.NameValueMap Context, ref Inventor.HandlingCodeEnum HandlingCode)
 {
     MessageBox.Show("OnBrowserNodeLabelEdit");
 }
        private void m_BrowserEvents_OnBrowserNodeGetDisplayObjects(object BrowserNodeDefinition, ref Inventor.ObjectCollection Objects, Inventor.NameValueMap Context, ref Inventor.HandlingCodeEnum HandlingCode)
        {
            PartDocument            oPartDocument = m_inventorApplication.ActiveDocument as PartDocument;
            PartComponentDefinition oPartDef      = oPartDocument.ComponentDefinition;

            if (oHighlight == null)
            {
                oHighlight = oPartDocument.CreateHighlightSet();
            }
            else
            {
                oHighlight.Clear();
            }

            Inventor.Color oColor = default(Inventor.Color);
            oColor = m_inventorApplication.TransientObjects.CreateColor(128, 22, 22);

            // Set the opacity
            oColor.Opacity   = 0.8;
            oHighlight.Color = oColor;

            if (BrowserNodeDefinition is ClientBrowserNodeDefinition)
            {
                ClientBrowserNodeDefinition oClientB = (ClientBrowserNodeDefinition)BrowserNodeDefinition;
                //highlight all ExtrudeFeature
                if (oClientB.Label == "Node2")
                {
                    foreach (ExtrudeFeature oExtrudeF in oPartDef.Features.ExtrudeFeatures)
                    {
                        oHighlight.AddItem(oExtrudeF);
                    }
                    //highlight all RevolveFeature
                }
                else if (oClientB.Label == "Node3")
                {
                    foreach (RevolveFeature oRevolveF in oPartDef.Features.RevolveFeatures)
                    {
                        oHighlight.AddItem(oRevolveF);
                    }
                }
            }
        }
 /// <summary>
 /// fire when custom node  is activated
 /// </summary>
 /// <param name="BrowserNodeDefinition"></param>
 /// <param name="Context"></param>
 /// <param name="HandlingCode"></param>
 /// <remarks></remarks>
 private void m_BrowserEvents_OnBrowserNodeActivate(object BrowserNodeDefinition, Inventor.NameValueMap Context, ref Inventor.HandlingCodeEnum HandlingCode)
 {
     MessageBox.Show("OnBrowserNodeActivate");
 }
        /// <summary>
        /// delete custom nodes
        /// </summary>
        /// <param name="BrowserNodeDefinition"></param>
        /// <param name="BeforeOrAfter"></param>
        /// <param name="Context"></param>
        /// <param name="HandlingCode"></param>
        /// <remarks></remarks>
        private void m_BrowserEvents_OnBrowserNodeDeleteEntry(object BrowserNodeDefinition, Inventor.EventTimingEnum BeforeOrAfter, Inventor.NameValueMap Context, ref Inventor.HandlingCodeEnum HandlingCode)
        {
            MessageBox.Show("OnBrowserNodeDeleteEntry");
            //do deletion by the client

            if (BeforeOrAfter == EventTimingEnum.kAfter)
            {
                ClientBrowserNodeDefinition oBND = (ClientBrowserNodeDefinition)BrowserNodeDefinition;
                oBND.Delete();
            }
        }
Beispiel #17
0
 private void m_ApplicationEvents_OnOpenDocument(Inventor._Document DocumentObject, string FullDocumentName, Inventor.EventTimingEnum BeforeOrAfter, Inventor.NameValueMap Context, Inventor.HandlingCodeEnum HandlingCode)
 {
     System.Windows.Forms.MessageBox.Show((string)("OnOpenDocument: " + DocumentObject.DisplayName));
 }