Esempio n. 1
0
        //On RhinoDoc.Idle, push previously recorded changes in selection to Illustrator.
        //Clear all S series .nata files when Illustrator finishes.
        public static void selectionToIllustrator(int state)
        {
            //Reset S00 so that RhinoApp.Idle doesn't repeat this process.
            string statePath = utils.file_structure.getPathFor("S00");

            System.IO.File.WriteAllText(statePath, "0");
            //int state = Convert.ToInt32(System.IO.File.ReadAllText(statePath));

            //Debug util: record state currently being passed as an argument.
            string stateDebugPath = utils.file_structure.getPathFor("x00");

            File.WriteAllText(stateDebugPath, "Current selection delta state: " + state.ToString());

            //Determine filepath for illustrator extendscript processes.
            string jsxPath = utils.file_structure.getJavascriptPath();

            //Determine current document runtime to send to interop.
            string runtime = utils.file_structure.getDocRuntime();

            //Generate copies of current data that Illustrator will read.
            string S10_Path = utils.file_structure.getPathFor("S10");
            string S20_Path = utils.file_structure.getPathFor("S20");

            if (File.Exists(S10_Path) == false)
            {
                File.WriteAllText(S10_Path, "empty");
            }
            else if (File.Exists(S10_Path) == true && File.ReadAllText(S10_Path) == "")
            {
                File.WriteAllText(S10_Path, "empty");
            }
            if (File.Exists(S20_Path) == false)
            {
                File.WriteAllText(S20_Path, "empty");
            }
            else if (File.Exists(S20_Path) == true && File.ReadAllText(S20_Path) == "")
            {
                File.WriteAllText(S20_Path, "empty");
            }

            string S11_Path = utils.file_structure.getPathFor("S11");
            string S21_Path = utils.file_structure.getPathFor("S21");

            File.WriteAllText(S11_Path, File.ReadAllText(S10_Path));
            File.WriteAllText(S21_Path, File.ReadAllText(S20_Path));

            string nataPath   = utils.file_structure.getNataPath();
            int    conversion = utils.units.conversion();

            //Clear original .nata file data.
            clearSelectionNata();

            //Tell illustrator to run selection update script, based on state.
            echo.interop echo = new echo.interop();
            echo.selection(state, jsxPath, runtime, nataPath, conversion);
        }
Esempio n. 2
0
        //Streamlined deselection process triggered on a full deselection or object deletion.
        public static int selectionReset()
        {
            //Set state file S00 to 3: selection reset.
            string statePath = utils.file_structure.getPathFor("S00");

            System.IO.File.WriteAllText(statePath, "3");

            string jsxPath    = utils.file_structure.getJavascriptPath();
            string runtime    = utils.file_structure.getDocRuntime();
            string nataPath   = utils.file_structure.getNataPath();
            int    conversion = utils.units.conversion();

            echo.interop echo = new echo.interop();
            echo.selection(3, jsxPath, runtime, nataPath, conversion);

            return(2);
        }