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.

This commit is contained in:
daid 2012-07-26 11:30:39 +02:00
parent 0f31ca9b4b
commit e698fb067d
6 changed files with 21 additions and 7 deletions

View File

@ -46,9 +46,10 @@ def main():
parser = OptionParser(usage="usage: %prog [options] <filename>.stl") parser = OptionParser(usage="usage: %prog [options] <filename>.stl")
parser.add_option("-i", "--ini", action="store", type="string", dest="profileini", help="Load settings from a profile ini file") 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("-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("-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("-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() (options, args) = parser.parse_args()
if options.profile != None: if options.profile != None:
profile.loadGlobalProfileFromString(options.profile) profile.loadGlobalProfileFromString(options.profile)
@ -67,9 +68,11 @@ def main():
printWindow.startPrintInterface(options.printfile) printWindow.startPrintInterface(options.printfile)
return return
if len( args ) > 0: if options.slice != None:
sliceRun.runSlice(args) sliceRun.runSlice(args)
else: else:
if len(args) > 0:
profile.putPreference('lastFile', ';'.join(args))
from gui import mainWindow from gui import mainWindow
mainWindow.main() mainWindow.main()

View File

@ -168,7 +168,7 @@ def getSliceCommand(filename):
mainScriptFile = os.path.abspath(os.path.join(os.path.dirname(os.path.abspath(__file__)), "../..", "cura_sf.zip")) mainScriptFile = os.path.abspath(os.path.join(os.path.dirname(os.path.abspath(__file__)), "../..", "cura_sf.zip"))
else: else:
mainScriptFile = os.path.abspath(os.path.join(os.path.dirname(os.path.abspath(__file__)), "..", os.path.split(sys.argv[0])[1])) 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": if platform.system() == "Windows":
try: try:
cmd.append(str(filename)) cmd.append(str(filename))

View File

@ -20,5 +20,5 @@ if [ $? != 0 ]; then
fi fi
SCRIPT_DIR=`dirname $0` SCRIPT_DIR=`dirname $0`
python ${SCRIPT_DIR}/Cura/cura.py python ${SCRIPT_DIR}/Cura/cura.py $@

View File

@ -29,5 +29,5 @@ if [ $? != 0 ]; then
fi fi
SCRIPT_DIR=`dirname $0` SCRIPT_DIR=`dirname $0`
python ${SCRIPT_DIR}/Cura/cura.py python ${SCRIPT_DIR}/Cura/cura.py $@

View File

@ -1 +1,2 @@
@python\python.exe Cura\cura.py @python\python.exe Cura\cura.py %*

View File

@ -37,6 +37,8 @@ SetCompressor /SOLID lzma
!define MUI_HEADERIMAGE_RIGHT !define MUI_HEADERIMAGE_RIGHT
!define MUI_HEADERIMAGE_BITMAP "header.bmp" !define MUI_HEADERIMAGE_BITMAP "header.bmp"
!define MUI_HEADERIMAGE_BITMAP_NOSTRETCH !define MUI_HEADERIMAGE_BITMAP_NOSTRETCH
; Don't show the component description box
!define MUI_COMPONENTSPAGE_NODESC
;Do not leave (Un)Installer page automaticly ;Do not leave (Un)Installer page automaticly
!define MUI_FINISHPAGE_NOAUTOCLOSE !define MUI_FINISHPAGE_NOAUTOCLOSE
@ -45,6 +47,7 @@ SetCompressor /SOLID lzma
; Pages ; Pages
;!insertmacro MUI_PAGE_WELCOME ;!insertmacro MUI_PAGE_WELCOME
!insertmacro MUI_PAGE_DIRECTORY !insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_PAGE_COMPONENTS
!insertmacro MUI_PAGE_INSTFILES !insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_PAGE_FINISH !insertmacro MUI_PAGE_FINISH
!insertmacro MUI_UNPAGE_CONFIRM !insertmacro MUI_UNPAGE_CONFIRM
@ -63,7 +66,7 @@ ReserveFile "header.bmp"
;-------------------------------- ;--------------------------------
; The stuff to install ; The stuff to install
Section "Cura Installer" Section "Cura ${VERSION}"
SectionIn RO SectionIn RO
@ -103,6 +106,13 @@ Section "Cura Installer"
SectionEnd 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 ; Uninstaller