Previewing Solidworks files from Linux: Difference between revisions
Created page with "You can add very superficial viewing capability in Linux for Solidworks files. Firstly, add a mime type, by creating a file <tt>$HOME/.local/share/mime/packages/x-solidworks...." |
No edit summary |
||
| (9 intermediate revisions by the same user not shown) | |||
| Line 1: | Line 1: | ||
<div style="width: 60%; padding-top:8px;padding-bottom:12px; border:solid 2pt gray;background-color:#ffdddd;margin-top:5px;margin-bottom:5px;padding:8px">'''Update:''' since changes were made to SolidWorks 2015, it is no longer possible to use the following instructions to preview Solidworks files. This is because Solidworks is no longer using a standard structured file format that <tt>gsf</tt> can read. If you figure out a solution to this, [[Support|let us know]]. Some info [http://michaellord.me/2014/09/22/solidworks-2015-the-how-why-of-reduced-file-sizes-solidworks-sw2015/ here].</div> | |||
This page gives some brief instructions on how to get basic preview support for [http://www.solidworks.com/ Solidworks] files in Linux. The instructions should work on any Freedesktop-based linux, eg Ubuntu, Fedora, etc. This approach only lets you see a low/medium resolution image of the object from a single point of view; you can't manipulate the object, but at least you can see more or less what the file contains. | |||
Before you start, you will need to install some packages: | |||
sudo apt-get install libgsf-bin imagemagick | |||
Firstly, add a mime type, by creating a file <tt>$HOME/.local/share/mime/packages/x-solidworks.xml</tt>: | Firstly, add a mime type, by creating a file <tt>$HOME/.local/share/mime/packages/x-solidworks.xml</tt>: | ||
| Line 59: | Line 65: | ||
Now associate this thumbnailer with the mime type, by creating a file <tt>$HOME/.local/share/thumbnailers/solidworks.thumbnailer</tt>: | Now associate this thumbnailer with the mime type, by creating a file <tt>$HOME/.local/share/thumbnailers/solidworks.thumbnailer</tt>: | ||
<source lang= | <source lang=ini> | ||
[Thumbnailer Entry] | [Thumbnailer Entry] | ||
TryExec=/usr/local/bin/solidworks-thumbnailer | TryExec=/usr/local/bin/solidworks-thumbnailer | ||
| Line 66: | Line 72: | ||
</source> | </source> | ||
You need to restart Nautilus using <tt>nautilus -q</tt>. After that, you should be seeing little thumbnails for all your solidworks files. | You need to restart Nautilus using <tt>nautilus -q</tt>. After that, you should be seeing little thumbnails for all your solidworks files, similar to below: | ||
[[Image:Thumbnail-solidworks.png]] | |||
This tiny thumbnail is lower than the resolution embedded in the solidworks file. We can also set up a viewer so that the full resolution preview image is displayed. | |||
Firstly, create <tt>/usr/local/bin/solidworks-viewer</tt> with the following content. Set the file to executable using <tt>chmod +x /usr/local/bin/solidworks-viewer</tt>. | |||
<source lang=py> | |||
#!/usr/bin/env python | |||
import subprocess | |||
import sys | |||
inputname = sys.argv[1] | |||
P1 = subprocess.Popen(['/usr/bin/gsf','cat',inputname,'PreviewPNG'],stdout=subprocess.PIPE) | |||
P2 = subprocess.Popen(["/usr/bin/display"],stdin=P1.stdout) | |||
P2.wait() | |||
</source> | |||
Secondly, create a file <tt>$HOME/.local/share/applications/solidworks.desktop</tt> containing the following (and also set this file as executable): | |||
<source lang=ini> | |||
[Desktop Entry] | |||
Encoding=UTF-8 | |||
Version=1.0 | |||
Type=Application | |||
Exec=/usr/local/bin/solidworks-viewer %f | |||
MimeType=application/x-solidworks; | |||
Name=Solidworks Preview | |||
Name[en]=Solidworks Preview | |||
GenericName=Solidworks Preview | |||
Comment=Solidworks Preview | |||
Icon=solidworks | |||
Categories=Education | |||
StartupNotify=false | |||
</source> | |||
Next, update you desktop database using <tt>update-desktop-database ~/.local/share/applications/</tt>. You will need to restart nautilus again (<tt>nautilus -q</tt>), then a double-click on your Solidworks file should pop up an image viewing window: | |||
[[Image:Solidworks-preview.png]] | |||
For some notes on possibly getting more information from these files, see [https://groups.google.com/forum/#!topic/openmanufacturing/Fv2Ovmxnfyw here]. Perhaps it might be possible to convert the solidworks file into some format that allows more detail to be visible. But that would be a much bigger job. | |||
[[Category:Miscellany]] | |||
Latest revision as of 07:57, 10 December 2015
This page gives some brief instructions on how to get basic preview support for Solidworks files in Linux. The instructions should work on any Freedesktop-based linux, eg Ubuntu, Fedora, etc. This approach only lets you see a low/medium resolution image of the object from a single point of view; you can't manipulate the object, but at least you can see more or less what the file contains.
Before you start, you will need to install some packages:
sudo apt-get install libgsf-bin imagemagick
Firstly, add a mime type, by creating a file $HOME/.local/share/mime/packages/x-solidworks.xml:
<?xml version="1.0" encoding="utf-8"?> <mime-info xmlns="http://www.freedesktop.org/standards/shared-mime-info"> <mime-type type="application/x-solidworks"> <glob pattern="*.sldprt"/> <glob pattern="*.sldasm"/> <glob pattern="*.slddrw"/> </mime-type> </mime-info>
Next, run update-mime-database $HOME/.local/share/mime
Check that your mime type is working with some solidworks file you have:
mimetype partfile.SLDPRT
and you should see application/x-solidworks in the output.
Next, add a thumbnailer for this type. First create the following script file and save it in /usr/local/bin/solidworks-thumbnailer:
Invalid language.
You need to specify a language like this: <source lang="html">...</source>
Supported languages for syntax highlighting:
a4c, abap, abc, abnf, actionscript, ada, agda, alan, algol, ampl, amtrix, applescript, arc, arm, as400cl, ascend, asciidoc, asp, aspect, assembler, ats, autohotkey, autoit, avenue, awk, ballerina, bat, bbcode, bcpl, bibtex, biferno, bison, blitzbasic, bms, bnf, boo, c, carbon, ceylon, charmm, chill, chpl, clean, clearbasic, clipper, clojure, clp, cmake, cobol, coffeescript, coldfusion, conf, cpp2, critic, crk, crystal, cs_block_regex, csharp, css, d, dart, delphi, diff, dockerfile, dts, dylan, ebnf, ebnf2, eiffel, elixir, elm, email, erb, erlang, euphoria, exapunks, excel, express, factor, fame, fasm, felix, fish, fortran77, fortran90, frink, fsharp, fstab, fx, gambas, gdb, gdscript, go, graphviz, haml, hare, haskell, haxe, hcl, html, httpd, hugo, icon, idl, idlang, inc_luatex, informix, ini, innosetup, interlis, io, jam, jasmin, java, javascript, js_regex, json, jsp, jsx, julia, kotlin, ldif, less, lhs, lilypond, limbo, lindenscript, lisp, logtalk, lotos, lotus, lua, luban, makefile, maple, markdown, matlab, maya, mercury, meson, miranda, mod2, mod3, modelica, moon, ms, msl, mssql, mxml, n3, nasal, nbc, nemerle, netrexx, nginx, nice, nim, nix, nsis, nxc, oberon, objc, ocaml, octave, oorexx, org, os, oz, paradox, pas, pdf, perl, php, pike, pl1, plperl, plpython, pltcl, po, polygen, pony, pov, powershell, pro, progress, ps, psl, pure, purebasic, purescript, pyrex, python, q, qmake, qml, qu, r, rebol, rego, rexx, rnc, rpg, rpl, rst, ruby, rust, s, sam, sas, scad, scala, scilab, scss, shellscript, slim, small, smalltalk, sml, snmp, snobol, solidity, spec, spn, sql, squirrel, styl, svg, swift, sybase, tcl, tcsh, terraform, tex, toml, tsql, tsx, ttcn3, txt, typescript, upc, vala, vb, verilog, vhd, vimscript, vue, wat, whiley, wren, xml, xpp, yaiff, yaml, yaml_ansible, yang, zig, znn
Set the file executable:
chmod +x /usr/local/bin/solidworks-thumbnailer
Now associate this thumbnailer with the mime type, by creating a file $HOME/.local/share/thumbnailers/solidworks.thumbnailer:
[Thumbnailer Entry] TryExec=/usr/local/bin/solidworks-thumbnailer Exec=/usr/local/bin/solidworks-thumbnailer %i %o %s MimeType=application/x-solidworks;
You need to restart Nautilus using nautilus -q. After that, you should be seeing little thumbnails for all your solidworks files, similar to below:
This tiny thumbnail is lower than the resolution embedded in the solidworks file. We can also set up a viewer so that the full resolution preview image is displayed.
Firstly, create /usr/local/bin/solidworks-viewer with the following content. Set the file to executable using chmod +x /usr/local/bin/solidworks-viewer.
Invalid language.
You need to specify a language like this: <source lang="html">...</source>
Supported languages for syntax highlighting:
a4c, abap, abc, abnf, actionscript, ada, agda, alan, algol, ampl, amtrix, applescript, arc, arm, as400cl, ascend, asciidoc, asp, aspect, assembler, ats, autohotkey, autoit, avenue, awk, ballerina, bat, bbcode, bcpl, bibtex, biferno, bison, blitzbasic, bms, bnf, boo, c, carbon, ceylon, charmm, chill, chpl, clean, clearbasic, clipper, clojure, clp, cmake, cobol, coffeescript, coldfusion, conf, cpp2, critic, crk, crystal, cs_block_regex, csharp, css, d, dart, delphi, diff, dockerfile, dts, dylan, ebnf, ebnf2, eiffel, elixir, elm, email, erb, erlang, euphoria, exapunks, excel, express, factor, fame, fasm, felix, fish, fortran77, fortran90, frink, fsharp, fstab, fx, gambas, gdb, gdscript, go, graphviz, haml, hare, haskell, haxe, hcl, html, httpd, hugo, icon, idl, idlang, inc_luatex, informix, ini, innosetup, interlis, io, jam, jasmin, java, javascript, js_regex, json, jsp, jsx, julia, kotlin, ldif, less, lhs, lilypond, limbo, lindenscript, lisp, logtalk, lotos, lotus, lua, luban, makefile, maple, markdown, matlab, maya, mercury, meson, miranda, mod2, mod3, modelica, moon, ms, msl, mssql, mxml, n3, nasal, nbc, nemerle, netrexx, nginx, nice, nim, nix, nsis, nxc, oberon, objc, ocaml, octave, oorexx, org, os, oz, paradox, pas, pdf, perl, php, pike, pl1, plperl, plpython, pltcl, po, polygen, pony, pov, powershell, pro, progress, ps, psl, pure, purebasic, purescript, pyrex, python, q, qmake, qml, qu, r, rebol, rego, rexx, rnc, rpg, rpl, rst, ruby, rust, s, sam, sas, scad, scala, scilab, scss, shellscript, slim, small, smalltalk, sml, snmp, snobol, solidity, spec, spn, sql, squirrel, styl, svg, swift, sybase, tcl, tcsh, terraform, tex, toml, tsql, tsx, ttcn3, txt, typescript, upc, vala, vb, verilog, vhd, vimscript, vue, wat, whiley, wren, xml, xpp, yaiff, yaml, yaml_ansible, yang, zig, znn
Secondly, create a file $HOME/.local/share/applications/solidworks.desktop containing the following (and also set this file as executable):
[Desktop Entry] Encoding=UTF-8 Version=1.0 Type=Application Exec=/usr/local/bin/solidworks-viewer %f MimeType=application/x-solidworks; Name=Solidworks Preview Name[en]=Solidworks Preview GenericName=Solidworks Preview Comment=Solidworks Preview Icon=solidworks Categories=Education StartupNotify=false
Next, update you desktop database using update-desktop-database ~/.local/share/applications/. You will need to restart nautilus again (nautilus -q), then a double-click on your Solidworks file should pop up an image viewing window:
For some notes on possibly getting more information from these files, see here. Perhaps it might be possible to convert the solidworks file into some format that allows more detail to be visible. But that would be a much bigger job.
