Beispiel #1
0
        public void Uninitialise()
        {
            MySerialization.Save(this);

            m_services = null;
            GC.Collect();
        }
Beispiel #2
0
        public void Initialise(string Token, PowerMILL.PluginServices pServices, int ParentWindow)
        {
            m_token         = Token;
            m_services      = pServices;
            m_parent_window = ParentWindow;


            MySerialization.Load(this);
        }
Beispiel #3
0
        public static string getMainModel(string m_token, PowerMILL.PluginServices m_services)
        {
            List <string> modelList = getEntitySorting("Model", m_token, m_services);

            if (modelList.Count > 0)
            {
                return(modelList[0]);
            }
            return(null);
        }
Beispiel #4
0
        public Options(string m_token, PowerMILL.PluginServices m_services, Plugin plg)
        {
            this.m_token    = m_token;
            this.m_services = m_services;
            _plg            = plg;

            InitializeComponent();

            label1.Text = plg.PathPS;
            label2.Text = plg.SerializePath;
        }
Beispiel #5
0
        public PMInteraction(string m_token, PowerMILL.PluginServices m_services)
        {
            this.m_token    = m_token;
            this.m_services = m_services;



            m_services.QueueCommand(m_token, @"ECHO OFF DCPDEBUG UNTRACE COMMAND ACCEPT");

            _dialogy = m_services.RequestInformation("MessagesDisplayed") == "true";
            _error   = m_services.RequestInformation("ErrorsDisplayed") == "true";

            m_services.QueueCommand(m_token, "DIALOGS MESSAGE OFF");
            m_services.QueueCommand(m_token, "DIALOGS ERROR OFF");
        }
Beispiel #6
0
        public DoWork(string m_token, PowerMILL.PluginServices m_services, string _pSPath)
        {
            this._pSPath = _pSPath;

            bool   selectedSurfaces = false;
            object oSelectedSurfaces;

            m_services.DoCommandEx(m_token, "print selsurface", out oSelectedSurfaces);

            if (!string.IsNullOrEmpty(oSelectedSurfaces.ToString()))
            {
                selectedSurfaces = true;
            }

            m_services.DoCommand(m_token, @"STRING $modelNameForApp = """"");
            m_services.DoCommand(m_token, @"$modelNameForApp = """"");
            m_services.DoCommand(m_token, @"$modelNameForApp =  INPUT ENTITY MODEL ""Vyber model pro export""");

            object modelName;

            m_services.DoCommandEx(m_token, "print $modelNameForApp", out modelName);

            if (!string.IsNullOrEmpty(modelName.ToString()))
            {
                if (!CreateConection())
                {
                    if (!startPSandConnect())
                    {
                        System.Windows.Forms.MessageBox.Show("Connection to PS failed");
                    }
                }

                object modelPath;
                m_services.DoCommandEx(m_token, @"print $entity(""Model"",""" + modelName + @""").Path", out modelPath);

                if (!File.Exists(modelPath.ToString()) || selectedSurfaces)
                {
                    modelPath = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + @"\" + modelName + ".dgk";
                    m_services.DoCommand(m_token, @"EXPORT MODEL """ + modelName + @""" FILESAVE """ + modelPath + @"""");
                    ImportModel(modelPath.ToString());
                    File.Delete(modelPath.ToString());
                }
                else
                {
                    ImportModel(modelPath.ToString());
                }
            }
        }
Beispiel #7
0
        public static bool getActiveEntityParameterBool(string entity, string parameter, string m_token, PowerMILL.PluginServices m_services)
        {
            string str = Gets.getActiveEntityParameterString(entity, parameter, m_token, m_services);

            return(str.Trim() == "1");
        }
Beispiel #8
0
        /*public static string getMainWorkplane(PowerMILL.Application oAppliacation)
         * {
         *      List<string> jmenaWorkplanes = Gets.getEntitySorting("Workplane",oAppliacation);
         *      if (jmenaWorkplanes.Count > 0)
         *              return jmenaWorkplanes[0];
         *      return null;
         *
         * }
         *
         * public static string getNamedEntityParameterString(string entity,string jmeno, string parameter,PowerMILL.Application oAppliacation)
         * {
         *
         *      int err = 0;
         *      string returnValue = null;
         *      oAppliacation.ExecuteEx(@"print $entity("""+entity+@""","""+jmeno+@""")."+parameter,out err,out returnValue);
         *      returnValue = returnValue.Replace(Environment.NewLine,"").Trim();
         *
         *      return returnValue;
         * }
         *
         * public static bool getNamedEntityParameterBool(string entity,string jmeno, string parameter,PowerMILL.Application oAppliacation)
         * {
         *      string str = Gets.getNamedEntityParameterString(entity,jmeno,parameter,oAppliacation);
         *      return str.Trim() == "1";
         * }
         *
         * public static int getNamedEntityParameterInt(string entity,string jmeno, string parameter,PowerMILL.Application oAppliacation)
         * {
         *      string str = Gets.getNamedEntityParameterString(entity,jmeno,parameter,oAppliacation);
         *      return  int.Parse(str.Trim());
         * }
         *
         * public static double getNamedEntityParameterDouble(string entity,string jmeno, string parameter,PowerMILL.Application oAppliacation)
         * {
         *      string str = Gets.getNamedEntityParameterString(entity,jmeno,parameter,oAppliacation);
         *      return  double.Parse(str.Trim());
         * }
         *
         * public static double[] getNamedEntityParameterVector3(string entity,string jmeno, string parameter,PowerMILL.Application oAppliacation)
         * {
         *      double d0 = Gets.getNamedEntityParameterDouble(entity,jmeno,parameter+"[0]",oAppliacation);
         *      double d1 = Gets.getNamedEntityParameterDouble(entity,jmeno,parameter+"[1]",oAppliacation);
         *      double d2 = Gets.getNamedEntityParameterDouble(entity,jmeno,parameter+"[2]",oAppliacation);
         *
         *      return  new double[] {d0,d1,d2 };
         *
         * }*/

        public static string getActiveEntityParameterString(string entity, string parameter, string m_token, PowerMILL.PluginServices m_services)
        {
            object returnValueO = null;

            m_services.DoCommandEx(m_token, @"print $entity(""" + entity + @""","""")." + parameter, out returnValueO);
            string returnValue = returnValueO.ToString().Replace(Environment.NewLine, "");

            return(returnValue);
        }
Beispiel #9
0
        public static List <string> getEntitySorting(string entityType, string m_token, PowerMILL.PluginServices m_services)
        {
            List <string> returnValue = null;

            try {
                string pathMacroTemp = getCestaMakroTemp();

                using (var writeMacro = new StreamWriter(pathMacroTemp, false, Encoding.Default)) {
                    writeMacro.WriteLine(@"FOREACH $x IN FOLDER(""" + entityType + @""") {");
                    writeMacro.WriteLine("print $x.Name");
                    writeMacro.WriteLine("}");
                }

                object resultO = null;
                m_services.DoCommandEx(m_token, @"macro """ + pathMacroTemp + @"""", out resultO);
                string   result     = resultO.ToString().Replace(Environment.NewLine, "@");
                string[] resultList = result.Split('@');
                returnValue = new List <string>();
                foreach (string ft in resultList)
                {
                    if (!string.IsNullOrEmpty(ft))
                    {
                        returnValue.Add(ft);
                    }
                }
            } catch { returnValue = null; System.Windows.Forms.MessageBox.Show("Chyba čtení temp makra!"); }

            return(returnValue);
        }
Beispiel #10
0
        public static double[] getGlobalParameterVector3(string parameter, string m_token, PowerMILL.PluginServices m_services)
        {
            double d0 = Gets.getGlobalParameterDouble(parameter + "[0]", m_token, m_services);
            double d1 = Gets.getGlobalParameterDouble(parameter + "[1]", m_token, m_services);
            double d2 = Gets.getGlobalParameterDouble(parameter + "[2]", m_token, m_services);

            return(new double[] { d0, d1, d2 });
        }
Beispiel #11
0
        public static double getGlobalParameterDouble(string parameter, string m_token, PowerMILL.PluginServices m_services)
        {
            string str = Gets.getGlobalParameterString(parameter, m_token, m_services);

            return(getCultureInvariantDouble(str));
        }
Beispiel #12
0
 /// <summary>
 /// new instance of the class
 /// </summary>
 /// <param name="comms"></param>
 public PowerMILLAutomation(IPluginCommunicationsInterface comms)
 {
     oPServices = comms.Services;
     oToken     = comms.Token;
 }
Beispiel #13
0
        public static bool getGlobalParameterBool(string parameter, string m_token, PowerMILL.PluginServices m_services)
        {
            string str = Gets.getGlobalParameterString(parameter, m_token, m_services);

            return(str.Trim() == "1");
        }
 public static void SetVariables(IPluginCommunicationsInterface comms)
 {
     oPServices = comms.Services;
     oToken     = comms.Token;
 }
Beispiel #15
0
        public static int getActiveEntityParameterInt(string entity, string parameter, string m_token, PowerMILL.PluginServices m_services)
        {
            string str = Gets.getActiveEntityParameterString(entity, parameter, m_token, m_services);

            return(int.Parse(str.Trim()));
        }
Beispiel #16
0
        public static double getActiveEntityParameterDouble(string entity, string parameter, string m_token, PowerMILL.PluginServices m_services)
        {
            string str = Gets.getActiveEntityParameterString(entity, parameter, m_token, m_services);

            return(getCultureInvariantDouble(str));
        }
Beispiel #17
0
        public static int getGlobalParameterInt(string parameter, string m_token, PowerMILL.PluginServices m_services)
        {
            string str = Gets.getGlobalParameterString(parameter, m_token, m_services);

            return(int.Parse(str.Trim()));
        }