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

m
no edit summary
mNo edit summary
mNo edit summary
Line 177: Line 177:
Therefore let's use [https://docs.microsoft.com/de-de/windows/win32/procthread/creating-processes CreateProcess].
Therefore let's use [https://docs.microsoft.com/de-de/windows/win32/procthread/creating-processes CreateProcess].


  #include <windows.h>
  #include <windows.h> // CreateProcess
#include "BPY_extern_run.h" // run py scripts


   char processFile[255];
   char processFile[255];
  char fn[255]; // py file (the more python, the less C)
   STARTUPINFO si;
   STARTUPINFO si;
   PROCESS_INFORMATION pi;
   PROCESS_INFORMATION pi;
Line 211: Line 214:
   
   
             // Wait until child process exits.
             // Wait until child process exits.
             // (in our case this is exactly what we don't want)
             // wait for onisplit to convert files ?
             // WaitForSingleObject(pi.hProcess, INFINITE);
             WaitForSingleObject(pi.hProcess, INFINITE);
   
   
             // Close process and thread handles.
             // Close process and thread handles.
             CloseHandle(pi.hProcess);
             CloseHandle(pi.hProcess);
             CloseHandle(pi.hThread);
             CloseHandle(pi.hThread);
            strcpy(fn, "C:\\blender-git\\oni.py");
            // C (context) looks like some crazy voodoo, this shouldn't even work right now, but it does
            // for Blender specific stuff a context is needed otherwise the program will crash
            // https://wiki.blender.org/wiki/Source/Architecture/Context
            bool ok;
            ok = BPY_run_filepath(C, fn, NULL);
   
   
             printf("file was processed\n");
             printf("file was processed\n");
Line 225: Line 235:
1) replace notepad with own exe (writing more code in C is a pain)
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
2) research path reading in C (get folder/file/extension) so own exe can use relative path when it is placed alongside Blender


3) research Blender import and let the exe decide what py script to use (for example ONCC*.oni -> import_ONCC.py)
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
  <s>blender --background --python myscript.py</s>
  https://blender.stackexchange.com/questions/1365/how-can-i-run-blender-from-command-line-or-a-python-script-without-opening-a-gui
  https://blender.stackexchange.com/questions/1365/how-can-i-run-blender-from-command-line-or-a-python-script-without-opening-a-gui


:: Edit: Then again ... '''Looks like [https://stackoverflow.com/questions/36360876/how-do-i-run-a-python-script-using-an-already-running-blender Blender cannot accept new inputs?]''' <span style="font-size:16pt;">ರ_ರ .................. (ノಠ益ಠ)ノ彡┻━┻</span>
:: Edit: Then again ... '''Looks like [https://stackoverflow.com/questions/36360876/how-do-i-run-a-python-script-using-an-already-running-blender Blender cannot accept new inputs?]''' <span style="font-size:16pt;">ರ_ರ .................. (ノಠ益ಠ)ノ彡┻━┻</span>


::: '''That would mean we either have to bite the sour apple and write much more C or do less with a workaround.'''
::: '''That would mean we either have to bite the sour apple and write much more C <s>or do less with a workaround</s>.'''
::: Possibilities:
::: <s>Possibilities:</s>
::: 1) Blender Server, '''[https://blender.stackexchange.com/questions/41533/how-to-remotely-run-a-python-script-in-an-existing-blender-instance sockets]'''.
::: <s>1) Blender Server, '''[https://blender.stackexchange.com/questions/41533/how-to-remotely-run-a-python-script-in-an-existing-blender-instance sockets]'''.</s>
::: 2) Add a '''new start arg''' and let Blender run as '''[https://www.youtube.com/watch?v=_i9HkIT0Atg single-instance application]'''
::: <s>2) Add a '''new start arg''' and let Blender run as '''[https://www.youtube.com/watch?v=_i9HkIT0Atg single-instance application]'''</s>
::: 3) A '''timer''' that checks every second for '''[https://github.com/zeffii/bpy_externall new commands inside a file]'''.
 
4) Deciding how to distribute this Blender variant.
 
Long-term goals could be to include Delano's addon and provide a way to automate the updating of Blender with these extras.
 
=====Start args=====
  C:\blender-git\blender\source\creator
  C:\blender-git\blender\source\creator


Line 249: Line 252:
  creator.c
  creator.c
  creator_args.c
  creator_args.c
::: <s>3) A '''timer''' that checks every second for '''[https://github.com/zeffii/bpy_externall new commands inside a file]'''.</s>
4) Deciding how to distribute this Blender variant.
Long-term goals could be to include Delano's addon and provide a way to automate the updating of Blender with these extras.
8,452

edits