From e698fb067dfcf8d666ec63d42fda4aa358a6be42 Mon Sep 17 00:00:00 2001 From: daid Date: Thu, 26 Jul 2012 11:30:39 +0200 Subject: [PATCH] Allow you to give an STL file on the command line so it opens the file in Cura. #184 Also add file association on stl files for Windows. --- Cura/cura.py | 7 +++++-- Cura/util/sliceRun.py | 2 +- scripts/linux/cura.sh | 2 +- scripts/osx64/cura.command | 2 +- scripts/win32/cura.bat | 3 ++- scripts/win32/installer.nsi | 12 +++++++++++- 6 files changed, 21 insertions(+), 7 deletions(-) diff --git a/Cura/cura.py b/Cura/cura.py index 195029f6..2374f988 100644 --- a/Cura/cura.py +++ b/Cura/cura.py @@ -46,9 +46,10 @@ def main(): parser = OptionParser(usage="usage: %prog [options] .stl") parser.add_option("-i", "--ini", action="store", type="string", dest="profileini", help="Load settings from a profile ini file") parser.add_option("-P", "--project", action="store_true", dest="openprojectplanner", help="Open the project planner") - parser.add_option("-F", "--flat", action="store_true", dest="openflatslicer", help="Open the 2D SVG slicer") + parser.add_option("-F", "--flat", action="store_true", dest="openflatslicer", help="Open the 2D SVG slicer (unfinished)") parser.add_option("-r", "--print", action="store", type="string", dest="printfile", help="Open the printing interface, instead of the normal cura interface.") parser.add_option("-p", "--profile", action="store", type="string", dest="profile", help="Internal option, do not use!") + parser.add_option("-s", "--slice", action="store_true", dest="slice", help="Slice the given files instead of opening them in Cura") (options, args) = parser.parse_args() if options.profile != None: profile.loadGlobalProfileFromString(options.profile) @@ -67,9 +68,11 @@ def main(): printWindow.startPrintInterface(options.printfile) return - if len( args ) > 0: + if options.slice != None: sliceRun.runSlice(args) else: + if len(args) > 0: + profile.putPreference('lastFile', ';'.join(args)) from gui import mainWindow mainWindow.main() diff --git a/Cura/util/sliceRun.py b/Cura/util/sliceRun.py index 1b561692..824aa1e0 100644 --- a/Cura/util/sliceRun.py +++ b/Cura/util/sliceRun.py @@ -168,7 +168,7 @@ def getSliceCommand(filename): mainScriptFile = os.path.abspath(os.path.join(os.path.dirname(os.path.abspath(__file__)), "../..", "cura_sf.zip")) else: mainScriptFile = os.path.abspath(os.path.join(os.path.dirname(os.path.abspath(__file__)), "..", os.path.split(sys.argv[0])[1])) - cmd = [pypyExe, mainScriptFile, '-p', profile.getGlobalProfileString()] + cmd = [pypyExe, mainScriptFile, '-p', profile.getGlobalProfileString(), '-s'] if platform.system() == "Windows": try: cmd.append(str(filename)) diff --git a/scripts/linux/cura.sh b/scripts/linux/cura.sh index 6ddee071..53c16d0d 100755 --- a/scripts/linux/cura.sh +++ b/scripts/linux/cura.sh @@ -20,5 +20,5 @@ if [ $? != 0 ]; then fi SCRIPT_DIR=`dirname $0` -python ${SCRIPT_DIR}/Cura/cura.py +python ${SCRIPT_DIR}/Cura/cura.py $@ diff --git a/scripts/osx64/cura.command b/scripts/osx64/cura.command index 2248b06c..f594f3bd 100755 --- a/scripts/osx64/cura.command +++ b/scripts/osx64/cura.command @@ -29,5 +29,5 @@ if [ $? != 0 ]; then fi SCRIPT_DIR=`dirname $0` -python ${SCRIPT_DIR}/Cura/cura.py +python ${SCRIPT_DIR}/Cura/cura.py $@ diff --git a/scripts/win32/cura.bat b/scripts/win32/cura.bat index 74c36151..42771b20 100644 --- a/scripts/win32/cura.bat +++ b/scripts/win32/cura.bat @@ -1 +1,2 @@ -@python\python.exe Cura\cura.py +@python\python.exe Cura\cura.py %* + diff --git a/scripts/win32/installer.nsi b/scripts/win32/installer.nsi index b1db3d44..69f807e3 100644 --- a/scripts/win32/installer.nsi +++ b/scripts/win32/installer.nsi @@ -37,6 +37,8 @@ SetCompressor /SOLID lzma !define MUI_HEADERIMAGE_RIGHT !define MUI_HEADERIMAGE_BITMAP "header.bmp" !define MUI_HEADERIMAGE_BITMAP_NOSTRETCH +; Don't show the component description box +!define MUI_COMPONENTSPAGE_NODESC ;Do not leave (Un)Installer page automaticly !define MUI_FINISHPAGE_NOAUTOCLOSE @@ -45,6 +47,7 @@ SetCompressor /SOLID lzma ; Pages ;!insertmacro MUI_PAGE_WELCOME !insertmacro MUI_PAGE_DIRECTORY +!insertmacro MUI_PAGE_COMPONENTS !insertmacro MUI_PAGE_INSTFILES !insertmacro MUI_PAGE_FINISH !insertmacro MUI_UNPAGE_CONFIRM @@ -63,7 +66,7 @@ ReserveFile "header.bmp" ;-------------------------------- ; The stuff to install -Section "Cura Installer" +Section "Cura ${VERSION}" SectionIn RO @@ -103,6 +106,13 @@ Section "Cura Installer" SectionEnd +Section "Open STL files with Cura" + WriteRegStr HKCR .stl "" "STL file" + ;WriteRegStr HKCR "STL file\DefaultIcon" "" "$INSTDIR\stl.ico,0" + WriteRegStr HKCR "STL file\shell" "" "open" + WriteRegStr HKCR "STL file\shell\open\command" "" '"$INSTDIR\cura.bat" "%1"' +SectionEnd + ;-------------------------------- ; Uninstaller -- 2.30.2