User:Paradox-01/Blender/Research: Difference between revisions

m
no edit summary
mNo edit summary
mNo edit summary
Line 165: Line 165:
blender-with-libraries-3.1.0\blender-3.1.0\source\blender\windowmanager\intern\wm_window.c
blender-with-libraries-3.1.0\blender-3.1.0\source\blender\windowmanager\intern\wm_window.c


A simple test of opening a dropped file with notepad:
By default only one file of dropped ones will be detected.
 
system(processFile); could be used but then Blender hangs until the child has process finished.
 
Therefore let's use [https://docs.microsoft.com/de-de/windows/win32/procthread/creating-processes CreateProcess].
 
#include <windows.h>


   char processFile[255];
   char processFile[255];
Line 174: Line 180:
             printf("drop file %s\n", stra->strings[a]);
             printf("drop file %s\n", stra->strings[a]);
   
   
             strcpy(processFile, "notepad.exe " );
             strcpy(processFile, "C:\\Windows\\system32\\notepad.exe ");
             strcat(processFile, stra->strings[a] );
             strcat(processFile, stra->strings[a]);
             system(processFile);
             // Start the child process.
            CreateProcess(
                // visual studio create only successful code if "L" is used before the strings
                // don't use L with blender
                "C:\\Windows\\system32\\notepad.exe",  // No module name (use command line)
                processFile,                          // Command line
                NULL,  // Process handle not inheritable
                NULL,  // Thread handle not inheritable
                FALSE,  // Set handle inheritance to FALSE
                0,      // No creation flags
                NULL,  // Use parent's environment block
                NULL,  // Use parent's starting directory
                &si,    // Pointer to STARTUPINFO structure
                &pi);  // Pointer to PROCESS_INFORMATION structure
            // Wait until child process exits.
            // (in our case this is exactly what we don't want)
            // WaitForSingleObject(pi.hProcess, INFINITE);
            // Close process and thread handles.
            CloseHandle(pi.hProcess);
            CloseHandle(pi.hThread);
            printf("file was processed");
  ...
  ...
  }
  }


Notepad will open with dropped file. Blender will hang and possible crash if Notepad is not closed.
====Todo====
1) replace notepad with own exe (writing more code in C is a pain)
 
2) research path reading in C (get folder/file/extension) so own exe can use relative path when it is place alongside Blender
 
3) research Blender import and let the exe decide what py script to use (for example ONCC*.oni -> import_ONCC.py)
blender --background --python myscript.py
https://blender.stackexchange.com/questions/1365/how-can-i-run-blender-from-command-line-or-a-python-script-without-opening-a-gui
 
4) Deciding how to distribute this Blender variant.


So, either the dropped files need to be processed right away or that part must be made independent using fork or create process ...
Long-term goals could be to include Delano's addon and provide a way to automate the updating of Blender with these extras.
* https://docs.microsoft.com/de-de/windows/win32/procthread/creating-processes
8,452

edits