public PMEntityTestBase()
 {
     // Initialise PowerMill
     if (_powerMILL == null)
     {
         _powerMILL = new PMAutomation(InstanceReuse.UseExistingInstance);
     }
 }
        /// <summary>
        /// Creates a new tool based on its type.
        /// </summary>
        /// <param name="powerMILL">The base instance to interact with PowerMILL.</param>
        /// <param name="name">The new instance name.</param>
        /// <returns>The new tool instance</returns>
        internal static PMTool CreateEntity(PMAutomation powerMILL, string name)
        {
            var result = powerMILL.DoCommandEx("PRINT PAR terse \"entity('tool', '" + name + "').type\"").ToString().Trim();

            switch (result)
            {
            case "end_mill":
                return(new PMToolEndMill(powerMILL, name));

            case "ball_nosed":
                return(new PMToolBallNosed(powerMILL, name));

            case "tip_radiused":
                return(new PMToolTipRadiused(powerMILL, name));

            case "taper_spherical":
                return(new PMToolTaperedSpherical(powerMILL, name));

            case "taper_tipped":
                return(new PMToolTaperedTipped(powerMILL, name));

            case "drill":
                return(new PMToolDrill(powerMILL, name));

            case "tipped_disc":
                return(new PMToolTippedDisc(powerMILL, name));

            case "off_centre_tip_rad":
                return(new PMToolOffCentreTipRadiused(powerMILL, name));

            case "tap":
                return(new PMToolTap(powerMILL, name));

            case "thread_mill":
                return(new PMToolThreadMill(powerMILL, name));

            case "form":
                return(new PMToolForm(powerMILL, name));

            case "routing":
                return(new PMToolRouting(powerMILL, name));

            case "barrel":
                return(new PMToolBarrel(powerMILL, name));

            case "dovetail":
                return(new PMToolDovetail(powerMILL, name));

            case "turn_profiling":
                return(new PMToolProfilingTurning(powerMILL, name));

            case "turn_grooving":
                return(new PMToolGroovingTurning(powerMILL, name));

            default:
                return(new PMTool(powerMILL, name));
            }
        }
Beispiel #3
0
        public void CreateNewInstanceTest()
        {
            PMAutomation automation = new PMAutomation(InstanceReuse.CreateNewInstance,
                                                       new Version(_powerMill.Version.Major, 0, 0),
                                                       new Version(_powerMill.Version.Major, 0, 99));

            Assert.IsNotNull(automation, "PowerMILL has not been started");
            automation.Quit();
        }
Beispiel #4
0
        public void AttachToCOMObjectTest()
        {
            var comObject =
                _powerMill.GetType().GetField("_powerMILL", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(_powerMill);
            var powerMill = new PMAutomation(comObject);

            powerMill.LoadProject(Files.TestFiles.SimplePmProject1);
            Assert.That(powerMill.ActiveProject.Directory.Path, Is.EqualTo(_powerMill.ActiveProject.Directory.Path));
        }
        public void ProcessIdTest()
        {
            var singleInstance = new PMAutomation(InstanceReuse.CreateNewInstance);
            var newProcessId   = singleInstance.ProcessId;

            singleInstance.Quit();

            Assert.That(newProcessId, Is.Not.EqualTo(_powerMill.ProcessId));
        }
Beispiel #6
0
 /// <summary>
 /// This operation creates instance objects based on an item's identifier in PowerMill
 /// </summary>
 public static PMEntity CreateEntity(PMAutomation powerMill, string identifier, string name)
 {
     if (identifier == PMBoundary.BOUNDARY_IDENTIFIER)
     {
         return(PMBoundaryEntityFactory.CreateEntity(powerMill, name));
     }
     if (identifier == PMFeatureSet.FEATURESET_IDENTIFIER)
     {
         return(new PMFeatureSet(powerMill, name));
     }
     if (identifier == PMGroup.GROUP_IDENTIFIER)
     {
         return(new PMGroup(powerMill, name));
     }
     if (identifier == PMLevelOrSet.LEVEL_OR_SET_IDENTIFIER)
     {
         return(new PMLevelOrSet(powerMill, name));
     }
     if (identifier == PMModel.MODEL_IDENTIFIER)
     {
         return(new PMModel(powerMill, name));
     }
     if (identifier == PMNCProgram.NC_PROGRAM_IDENTIFIER)
     {
         return(new PMNCProgram(powerMill, name));
     }
     if (identifier == PMPattern.PATTERN_IDENTIFIER)
     {
         return(new PMPattern(powerMill, name));
     }
     if (identifier == PMStockModel.STOCKMODEL_IDENTIFIER)
     {
         return(new PMStockModel(powerMill, name));
     }
     if (identifier == PMToolpath.TOOLPATH_IDENTIFIER)
     {
         return(PMToolpathEntityFactory.CreateEntity(powerMill, name));
     }
     if (identifier == PMTool.TOOL_IDENTIFIER)
     {
         return(PMToolEntityFactory.CreateEntity(powerMill, name));
     }
     if (identifier == PMWorkplane.WORKPLANE_IDENTIFIER)
     {
         return(new PMWorkplane(powerMill, name));
     }
     if (identifier == PMMachineTool.MACHINE_TOOL_IDENTIFIER)
     {
         return(new PMMachineTool(powerMill, name));
     }
     return(null);
 }
Beispiel #7
0
        public void GetListOfPmComObjectsTest()
        {
            //Creating 1 more PowerMill instance
            PMAutomation automation2 = new PMAutomation(InstanceReuse.CreateNewInstance);

            //Get the number of Com Object instances
            List <object> instances = PMAutomation.GetListOfPmComObjects();

            Assert.That(instances.Count, Is.EqualTo(2));

            //Quit
            automation2.Quit();
        }
        public void TestFixtureSetup()
        {
            _powerMill = new PMAutomation(InstanceReuse.UseExistingInstance);
            _powerMill.DialogsOff();
            _powerMill.CloseProject();

            var tempFolder = Directory.CreateTemporaryDirectory();

            TestFiles.SimplePmProject1.Copy(tempFolder);
            _powerMill.LoadProject(tempFolder);
            _tempFoldersToDelete.Add(tempFolder);

            _defaultModel = _powerMill.ActiveProject.Models[0];
        }
Beispiel #9
0
        public void CreateSingleInstanceTest()
        {
            var previousProcessId = _powerMill.ProcessId;

            var singleInstance = new PMAutomation(InstanceReuse.CreateSingleInstance,
                                                  new Version(_powerMill.Version.Major, 0, 0),
                                                  new Version(_powerMill.Version.Major, 0, 99));

            _powerMill = singleInstance;

            var processesIds = Process.GetProcesses().Select(p => p.Id);

            Assert.That(processesIds, Has.None.EqualTo(previousProcessId));
            Assert.That(processesIds, Contains.Item(singleInstance.ProcessId));
        }
Beispiel #10
0
        public void Quit()
        {
            var newInstance = new PMAutomation(InstanceReuse.CreateNewInstance,
                                               new Version(_powerMill.Version.Major, 0, 0),
                                               new Version(_powerMill.Version.Major, 0, 99));

            Assert.IsNotNull(newInstance, "PowerMILL has not been started");

            newInstance.Quit();

            var processes = Process.GetProcessesByName("pmill");

            Assert.That(processes.Select(p => p.Id).ToList(),
                        Has.None.EqualTo(newInstance.ProcessId),
                        "Expected PowerMILL process to have terminated.");
        }
Beispiel #11
0
        public void MultipleVersionsTest_WhenUsing2018Notation()
        {
            var versionUnderTest = _powerMill.Version;
            var twenty17         = new PMAutomation(InstanceReuse.CreateNewInstance, new Version(21, 0, 0), new Version(21, 0, 99));

            Assert.That(twenty17.Version.Major, Is.EqualTo(21));
            twenty17.Quit();
            var twenty18 = new PMAutomation(InstanceReuse.CreateNewInstance, new Version(2018, 0, 0), new Version(2018, 0, 99));

            Assert.That(twenty18.Version.Major, Is.EqualTo(2018));
            twenty18.Quit();

            // Ensure that the version under test is properly registered as the current version so other tests carry on ok...
            var testVersion = new PMAutomation(InstanceReuse.CreateNewInstance, versionUnderTest);

            testVersion.Quit();
        }
        public static List <object> PConn()
        {
            //This is the powermill method that returns a list of com objects
            List <object> comList = PMAutomation.GetListOfPmComObjects();

            return(comList);

            //PMAutomation projectUse = new PMAutomation(comList[2]);
            //PMProject s = projectUse.ActiveProject;

            //Autodesk.FileSystem.File importFile = new Autodesk.FileSystem.File("L:\\CAM-Library\\Niigata\\FCSComponents\\GaugePlate_R1.dgk");
            //PMModel myModel = s.Models.CreateModel(importFile);

            //powerMill.DialogsOff;

            //powerMill.DialogsOn;
        }
Beispiel #13
0
        private void Connect(bool x, int index, Button xButton)
        {
            if (x)
            {
                //Connect to Powermill instance
                projectUse = new PMAutomation(comList[index]);

                //Change the color of the button in use to red
                //And change the color of all other buttons to green
                SetButtonColor(x, index, xButton);

                //create project instance from instance
                session = projectUse.ActiveProject;

                int i = 0;
                //Add the name of the file to the text box
                setProjectLabel(x, index, xButton, i);
            }
        }
Beispiel #14
0
 public void LeavingAutomationTest()
 {
     _powerMill = new PMAutomation(InstanceReuse.UseExistingInstance);
 }
Beispiel #15
0
 public void MyTestInitialize()
 {
     _powerMill = new PMAutomation(InstanceReuse.UseExistingInstance);
 }
 /// <summary>
 /// Initialises the item.
 /// </summary>
 /// <param name="powerMILL">The base instance to interact with PowerMILL.</param>
 /// <param name="name">The new instance name.</param>
 internal PMStockModel(PMAutomation powerMILL, string name) : base(powerMILL, name)
 {
 }
Beispiel #17
0
 /// <summary>
 /// Initialises the item.
 /// </summary>
 /// <param name="powerMILL">The base instance to interact with PowerMILL.</param>
 internal PMToolpathBliskAreaClearance(PMAutomation powerMILL) : base(powerMILL)
 {
 }
 /// <summary>
 /// Initialises the item.
 /// </summary>
 /// <param name="powerMILL">The base instance to interact with PowerMILL.</param>
 internal PMToolpathProfileFinishing(PMAutomation powerMILL) : base(powerMILL)
 {
 }
Beispiel #19
0
 /// <summary>
 /// Initialises the item.
 /// </summary>
 /// <param name="powerMILL">The base instance to interact with PowerMILL.</param>
 /// <param name="name">The new instance name.</param>
 internal PMToolpathOptimisedConstantZFinishing(PMAutomation powerMILL, string name) : base(powerMILL, name)
 {
 }
 /// <summary>
 /// Initialises the item.
 /// </summary>
 /// <param name="powerMILL">The base instance to interact with PowerMILL.</param>
 /// <param name="name">The new instance name.</param>
 internal PMToolpathPortSpiralFinishing(PMAutomation powerMILL, string name) : base(powerMILL, name)
 {
 }
 /// <summary>
 /// Initialises the item.
 /// </summary>
 /// <param name="powerMILL">The base instance to interact with PowerMILL.</param>
 internal PMToolpathPortSpiralFinishing(PMAutomation powerMILL) : base(powerMILL)
 {
 }
Beispiel #22
0
 /// <summary>
 /// Initialises the item.
 /// </summary>
 /// <param name="powerMILL">The base instance to interact with PowerMILL.</param>
 /// <param name="name">The new instance name.</param>
 internal PMToolGroovingTurning(PMAutomation powerMILL, string name) : base(powerMILL, name)
 {
 }
Beispiel #23
0
 /// <summary>
 /// Initialises the item.
 /// </summary>
 /// <param name="powerMILL">The base instance to interact with PowerMILL.</param>
 internal PMToolGroovingTurning(PMAutomation powerMILL) : base(powerMILL)
 {
 }
 public void TestFixtureSetup()
 {
     _powerMill = new PMAutomation(InstanceReuse.UseExistingInstance);
     _powerMill.DialogsOff();
     _powerMill.CloseProject();
 }
 /// <summary>
 /// Creates a PMToolpathConstantZFinishing instance.
 /// </summary>
 /// <param name="powerMILL">The base instance to interact with PowerMILL.</param>
 internal PMToolpathConstantZFinishing(PMAutomation powerMILL) : base(powerMILL)
 {
 }
Beispiel #26
0
 /// <summary>
 /// Initialises the item.
 /// </summary>
 /// <param name="powerMILL">The base instance to interact with PowerMILL.</param>
 /// <param name="name">The new instance name.</param>
 internal PMToolRouting(PMAutomation powerMILL, string name) : base(powerMILL, name)
 {
 }
 /// <summary>
 /// Initialises the item.
 /// </summary>
 /// <param name="powerMILL">The base instance to interact with PowerMILL.</param>
 /// <param name="name">The new instance name.</param>
 internal PMToolpathProfileFinishing(PMAutomation powerMILL, string name) : base(powerMILL, name)
 {
 }
Beispiel #28
0
 /// <summary>
 /// Initialises the item.
 /// </summary>
 /// <param name="powerMILL">The base instance to interact with PowerMILL.</param>
 internal PMToolRouting(PMAutomation powerMILL) : base(powerMILL)
 {
 }
Beispiel #29
0
 /// <summary>
 /// Initialises the item.
 /// </summary>
 /// <param name="powerMILL">The base instance to interact with PowerMILL.</param>
 /// <param name="name">The new instance name.</param>
 internal PMToolpathBliskAreaClearance(PMAutomation powerMILL, string name) : base(powerMILL, name)
 {
 }
 /// <summary>
 /// Initialises the item.
 /// </summary>
 /// <param name="powerMILL">The base instance to interact with PowerMILL.</param>
 internal PMStockModel(PMAutomation powerMILL) : base(powerMILL)
 {
 }