Forum: Poser Python Scripting


Subject: Is there a way to support Undo with LoadLibraryPose

yarp opened this issue on Apr 23, 2021 ยท 28 posts


Dizzi posted Sun, 02 May 2021 at 8:00 AM

you can try, if loading files from outside poser still works (that was how the air library from Poser 8 communicated with Poser). Here' some C# code for loading and saving, port should be the one from the poser.ini:

load:

System.Net.WebClient Client = new System.Net.WebClient();

            Client.Encoding = Encoding.UTF8;

            Client.QueryString.Add("id", Util.EncodeUtfUriComponent(filename));
            Client.QueryString.Add("op", "addItem");
            
            Stream strm = Client.OpenRead(new Uri("http://localhost:11530/apps/lms/api.py"));
            StreamReader sr = new StreamReader(strm);
            string line;
            do {
                line = sr.ReadLine();
                Console.WriteLine(line);
            }
            while (line != null);
            strm.Close();

save:

string Path = SaveDialog.GetSavePath(); if (Path == null) return; System.Net.WebClient Client = new System.Net.WebClient(); Client.Encoding = Encoding.UTF8; Client.QueryString.Add("op", "saveItem"); Client.QueryString.Add("categoryId", Category); Client.QueryString.Add("folderId", Util.EncodeUtfUriComponent(Path));

        //Stream strm =
        IntPtr poserHandle = Util.GetPoserWindowHandle(this);
        if (poserHandle != IntPtr.Zero)
            SetForegroundWindow(poserHandle);
        try {
            Client.OpenRead(new Uri("http://localhost:11530/apps/lms/api.py"));