Web: Added sketchfab exporter
This commit is contained in:
@@ -13,3 +13,11 @@ INSTALL(
|
||||
DESTINATION
|
||||
Mod/Web
|
||||
)
|
||||
|
||||
INSTALL(
|
||||
FILES
|
||||
Webscripts/__init__.py
|
||||
Webscripts/Sketchfab.py
|
||||
DESTINATION
|
||||
Mod/Web/Webscripts
|
||||
)
|
||||
|
||||
@@ -237,6 +237,35 @@ bool CmdWebBrowserZoomOut::isActive(void)
|
||||
return getGuiApplication()->sendHasMsgToActiveView("ZoomOut");
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
// CmdWebSketchfab
|
||||
//===========================================================================
|
||||
|
||||
DEF_STD_CMD_A(CmdWebSketchfab);
|
||||
|
||||
CmdWebSketchfab::CmdWebSketchfab()
|
||||
: Command("Web_Sketchfab")
|
||||
{
|
||||
sAppModule = "Web";
|
||||
sGroup = QT_TR_NOOP("Web");
|
||||
sMenuText = QT_TR_NOOP("Sketchfab");
|
||||
sToolTipText = QT_TR_NOOP("Uploads a model to your sketchfab account");
|
||||
sWhatsThis = sToolTipText;
|
||||
sStatusTip = sToolTipText;
|
||||
sPixmap = "actions/web-sketchfab";
|
||||
}
|
||||
|
||||
void CmdWebSketchfab::activated(int iMsg)
|
||||
{
|
||||
Q_UNUSED(iMsg);
|
||||
doCommand(Command::Gui,"from Webscripts import Sketchfab");
|
||||
doCommand(Command::Gui,"FreeCADGui.Control.showDialog(Sketchfab.SketchfabTaskPanel())");
|
||||
}
|
||||
|
||||
bool CmdWebSketchfab::isActive(void)
|
||||
{
|
||||
return hasActiveDocument();
|
||||
}
|
||||
|
||||
void CreateWebCommands(void)
|
||||
{
|
||||
@@ -249,4 +278,5 @@ void CreateWebCommands(void)
|
||||
rcCmdMgr.addCommand(new CmdWebBrowserStop());
|
||||
rcCmdMgr.addCommand(new CmdWebBrowserZoomIn());
|
||||
rcCmdMgr.addCommand(new CmdWebBrowserZoomOut());
|
||||
rcCmdMgr.addCommand(new CmdWebSketchfab());
|
||||
}
|
||||
|
||||
@@ -8,7 +8,10 @@
|
||||
<file>icons/actions/web-stop.svg</file>
|
||||
<file>icons/actions/web-zoom-in.svg</file>
|
||||
<file>icons/actions/web-zoom-out.svg</file>
|
||||
<file>icons/actions/web-sketchfab.svg</file>
|
||||
<file>icons/WebWorkbench.svg</file>
|
||||
<file>icons/Sketchfab.svg</file>
|
||||
<file>ui/TaskDlgSketchfab.ui</file>
|
||||
<file>translations/Web_de.qm</file>
|
||||
<file>translations/Web_af.qm</file>
|
||||
<file>translations/Web_zh-CN.qm</file>
|
||||
|
||||
@@ -0,0 +1,133 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!-- Created with Inkscape (http://www.inkscape.org/) -->
|
||||
|
||||
<svg
|
||||
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||
xmlns:cc="http://creativecommons.org/ns#"
|
||||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns:svg="http://www.w3.org/2000/svg"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||
version="1.1"
|
||||
id="svg2"
|
||||
xml:space="preserve"
|
||||
width="2664.7544"
|
||||
height="551.00934"
|
||||
viewBox="0 0 2664.7543 551.00933"
|
||||
sodipodi:docname="Sketchfab.svg"
|
||||
inkscape:version="0.92.1 r15371"><metadata
|
||||
id="metadata8"><rdf:RDF><cc:Work
|
||||
rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type
|
||||
rdf:resource="http://purl.org/dc/dcmitype/StillImage" /><dc:title></dc:title></cc:Work></rdf:RDF></metadata><defs
|
||||
id="defs6"><clipPath
|
||||
clipPathUnits="userSpaceOnUse"
|
||||
id="clipPath18"><path
|
||||
d="M 0,2000 H 2000 V 0 H 0 Z"
|
||||
id="path16"
|
||||
inkscape:connector-curvature="0" /></clipPath></defs><sodipodi:namedview
|
||||
pagecolor="#ffffff"
|
||||
bordercolor="#666666"
|
||||
borderopacity="1"
|
||||
objecttolerance="10"
|
||||
gridtolerance="10"
|
||||
guidetolerance="10"
|
||||
inkscape:pageopacity="0"
|
||||
inkscape:pageshadow="2"
|
||||
inkscape:window-width="1920"
|
||||
inkscape:window-height="1051"
|
||||
id="namedview4"
|
||||
showgrid="false"
|
||||
fit-margin-top="0"
|
||||
fit-margin-left="0"
|
||||
fit-margin-right="0"
|
||||
fit-margin-bottom="0"
|
||||
inkscape:zoom="0.25031579"
|
||||
inkscape:cx="1793.2844"
|
||||
inkscape:cy="393.10003"
|
||||
inkscape:window-x="0"
|
||||
inkscape:window-y="0"
|
||||
inkscape:window-maximized="1"
|
||||
inkscape:current-layer="g14" /><g
|
||||
id="g10"
|
||||
inkscape:groupmode="layer"
|
||||
inkscape:label="logo-sketchfab-grey"
|
||||
transform="matrix(1.3333333,0,0,-1.3333333,0,1609.455)"><g
|
||||
id="g12"><g
|
||||
id="g14"
|
||||
clip-path="url(#clipPath18)"><g
|
||||
id="g20"
|
||||
transform="translate(602.8265,1079.0248)"
|
||||
style="stroke:#000000;stroke-width:4.89975023;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"><path
|
||||
d="m 0,0 c -25.223,0 -37.835,-8.331 -37.835,-24.992 0,-7.405 3.124,-13.074 9.372,-17.008 6.248,-3.934 20.876,-9.62 43.901,-17.008 23.025,-7.405 39.174,-15.802 48.43,-25.157 9.256,-9.372 13.884,-23.769 13.884,-43.223 0,-24.761 -7.521,-43.505 -22.562,-56.215 -15.058,-12.744 -34.711,-19.091 -59.008,-19.091 -18.05,0 -40.149,2.777 -66.298,8.33 l -12.496,2.43 4.86,37.141 c 31.008,-4.182 54.727,-6.265 71.157,-6.265 24.529,0 36.793,10.182 36.793,30.562 0,7.389 -2.826,13.19 -8.512,17.355 -5.686,4.166 -16.942,8.678 -33.835,13.538 -26.843,7.636 -45.768,16.71 -56.76,27.239 -10.992,10.529 -16.496,25.157 -16.496,43.918 0,23.603 7.173,41.19 21.521,52.76 14.347,11.57 34.016,17.355 59.008,17.355 17.124,0 38.876,-2.314 65.256,-6.942 L 72.876,32.297 69.074,-5.57 C 36.446,-1.868 13.422,0 0,0"
|
||||
style="fill:#555555;fill-opacity:1;fill-rule:nonzero;stroke:#000000;stroke-width:4.89975023;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
||||
id="path22"
|
||||
inkscape:connector-curvature="0" /></g><g
|
||||
id="g24"
|
||||
transform="translate(761.4546,880.4793)"
|
||||
style="stroke:#000000;stroke-width:4.89975023;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"><path
|
||||
d="M 0,0 H -46.512 V 242.975 H 0 V 104.826 l 17.702,3.124 34.364,65.604 h 52.066 L 59.008,91.289 106.562,0 H 54.149 L 19.091,67.686 0,64.579 Z"
|
||||
style="fill:#555555;fill-opacity:1;fill-rule:nonzero;stroke:#000000;stroke-width:4.89975023;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
||||
id="path26"
|
||||
inkscape:connector-curvature="0" /></g><g
|
||||
id="g28"
|
||||
transform="translate(988.4628,982.876)"
|
||||
style="stroke:#000000;stroke-width:4.89975023;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"><path
|
||||
d="m 0,0 c 0,13.884 -2.198,23.537 -6.595,28.975 -4.397,5.438 -12.099,8.149 -23.074,8.149 -11.009,0 -18.744,-2.826 -23.257,-8.496 C -57.438,22.959 -59.818,13.405 -60.05,0 Z m -51.19,-58.496 c 5.438,-4.744 13.24,-7.124 23.421,-7.124 21.521,0 40.728,0.694 57.62,2.083 l 9.736,1.041 0.677,-34.363 c -26.611,-6.48 -50.677,-9.719 -72.198,-9.719 -26.149,0 -45.124,6.942 -56.925,20.826 -11.802,13.884 -17.703,36.446 -17.703,67.686 0,62.248 25.57,93.372 76.711,93.372 50.446,0 75.669,-26.149 75.669,-78.447 L 42.364,-35.422 H -59.703 c 0.232,-10.628 3.058,-18.33 8.513,-23.074"
|
||||
style="fill:#555555;fill-opacity:1;fill-rule:nonzero;stroke:#000000;stroke-width:4.89975023;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
||||
id="path30"
|
||||
inkscape:connector-curvature="0" /></g><g
|
||||
id="g32"
|
||||
transform="translate(1163.7521,1014.4628)"
|
||||
style="stroke:#000000;stroke-width:4.89975023;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"><path
|
||||
d="m 0,0 h -42.694 v -71.157 c 0,-6.942 0.182,-11.868 0.512,-14.76 0.347,-2.893 1.62,-5.372 3.818,-7.455 2.199,-2.083 5.604,-3.124 10.232,-3.124 l 26.38,0.694 2.083,-37.124 c -15.505,-3.487 -27.29,-5.206 -35.405,-5.206 -20.827,0 -35.058,4.677 -42.695,14.066 -7.636,9.355 -11.454,26.661 -11.454,51.901 V 0.033 h -20.463 V 39.57 h 20.463 v 48.248 h 46.512 V 39.57 H -0.016 V 0 Z"
|
||||
style="fill:#555555;fill-opacity:1;fill-rule:nonzero;stroke:#000000;stroke-width:4.89975023;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
||||
id="path34"
|
||||
inkscape:connector-curvature="0" /></g><g
|
||||
id="g36"
|
||||
transform="translate(1258.8596,1058.1984)"
|
||||
style="stroke:#000000;stroke-width:4.89975023;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"><path
|
||||
d="m 0,0 c 12.049,0 27.421,-1.851 46.182,-5.554 l 9.355,-2.082 -1.388,-36.794 c -18.281,1.851 -31.819,2.777 -40.612,2.777 -15.967,0 -26.545,-3.421 -31.752,-10.248 -5.207,-6.826 -7.818,-19.719 -7.818,-38.694 0,-18.975 2.595,-32.017 7.818,-39.058 5.19,-7.058 15.901,-10.595 32.099,-10.595 l 40.265,2.777 1.388,-37.124 c -24.76,-4.876 -43.62,-7.289 -56.578,-7.289 -25.686,0 -44.149,7.239 -55.372,21.686 -11.223,14.446 -16.843,37.652 -16.843,69.603 0,31.934 5.785,55.008 17.355,69.24 C -44.33,-7.124 -25.686,0 0,0"
|
||||
style="fill:#555555;fill-opacity:1;fill-rule:nonzero;stroke:#000000;stroke-width:4.89975023;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
||||
id="path38"
|
||||
inkscape:connector-curvature="0" /></g><g
|
||||
id="g40"
|
||||
transform="translate(1395.2727,880.4793)"
|
||||
style="stroke:#000000;stroke-width:4.89975023;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"><path
|
||||
d="M 0,0 H -46.512 V 242.975 H 0 v -77.752 c 15.967,8.331 30.314,12.496 43.041,12.496 23.141,0 39.108,-6.826 47.901,-20.479 8.777,-13.653 13.19,-34.711 13.19,-63.174 V 0 H 57.62 v 93.025 c 0,14.578 -1.719,25.388 -5.19,32.446 -3.471,7.058 -10.413,10.595 -20.827,10.595 -9.025,0 -18.066,-1.388 -27.091,-4.165 L 0.016,130.512 V 0 Z"
|
||||
style="fill:#555555;fill-opacity:1;fill-rule:nonzero;stroke:#000000;stroke-width:4.89975023;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
||||
id="path42"
|
||||
inkscape:connector-curvature="0" /></g><g
|
||||
id="g44"
|
||||
transform="translate(1595.5537,1014.4628)"
|
||||
style="stroke:#000000;stroke-width:4.89975023;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"><path
|
||||
d="M 0,0 V -133.983 H -46.512 V 0 h -18.744 v 39.57 h 18.744 v 7.62 c 0,24.992 3.702,42.231 11.107,51.719 7.405,9.488 20.595,14.231 39.587,14.231 8.33,0 19.091,-1.157 32.281,-3.471 l 7.272,-1.041 -0.694,-37.835 C 32.859,71.256 24.297,71.488 17.355,71.488 10.413,71.488 5.785,69.636 3.471,65.934 1.141,62.231 0,55.868 0,46.843 V 39.554 H 42 V -0.017 H 0 Z"
|
||||
style="fill:#555555;fill-opacity:1;fill-rule:nonzero;stroke:#000000;stroke-width:4.89975023;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
||||
id="path46"
|
||||
inkscape:connector-curvature="0" /></g><g
|
||||
id="g48"
|
||||
transform="translate(1719.4711,954.0661)"
|
||||
style="stroke:#000000;stroke-width:4.89975023;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"><path
|
||||
d="m 0,0 c -12.959,-1.157 -19.438,-8.099 -19.438,-20.826 0,-12.744 5.669,-19.091 16.992,-19.091 8.793,0 18.396,1.388 28.81,4.165 l 5.206,1.388 V 2.777 Z M 78.099,45.818 V -26.38 c 0.463,-5.57 1.389,-9.438 2.777,-11.636 1.388,-2.199 4.281,-3.769 8.678,-4.678 l -1.389,-35.058 c -11.801,0 -21.239,0.81 -28.297,2.413 -7.058,1.637 -14.165,4.876 -21.339,9.736 -16.661,-8.099 -33.67,-12.149 -51.025,-12.149 -35.884,0 -53.801,18.959 -53.801,56.926 0,18.495 4.975,31.636 14.909,39.388 9.967,7.752 25.223,12.331 45.818,13.719 l 37.14,2.777 v 10.76 c 0,7.174 -1.636,12.083 -4.859,14.761 -3.24,2.661 -8.463,3.983 -15.62,3.983 l -65.256,-2.777 -1.388,32.281 c 24.76,6.711 48.313,10.066 70.628,10.066 22.347,0 38.413,-4.628 48.248,-13.884 9.867,-9.256 14.776,-24.083 14.776,-44.43"
|
||||
style="fill:#555555;fill-opacity:1;fill-rule:nonzero;stroke:#000000;stroke-width:4.89975023;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
||||
id="path50"
|
||||
inkscape:connector-curvature="0" /></g><g
|
||||
id="g52"
|
||||
transform="translate(1909.686,917.9504)"
|
||||
style="stroke:#000000;stroke-width:4.89975023;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"><path
|
||||
d="m 0,0 c 15.504,0 25.901,3.769 31.24,11.289 5.338,7.521 7.967,21.008 7.967,40.447 0,31.239 -9.719,46.842 -29.157,46.842 -9.257,0 -18.05,-1.157 -26.381,-3.471 L -21.19,94.066 V 1.388 C -10.546,0.463 -3.488,0 0,0 m 16.297,140.248 c 24.298,0 42.067,-6.645 53.29,-19.967 C 80.81,106.959 86.43,83.19 86.43,48.942 86.43,14.711 79.95,-8.959 66.992,-22.033 54.033,-35.107 31.686,-41.653 0,-41.653 c -9.967,0 -28.116,1.157 -54.513,3.471 l -13.19,1.389 v 242.297 h 46.513 v -74.628 c 14.81,6.248 27.306,9.372 37.487,9.372"
|
||||
style="fill:#555555;fill-opacity:1;fill-rule:nonzero;stroke:#000000;stroke-width:4.89975023;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
||||
id="path54"
|
||||
inkscape:connector-curvature="0" /></g><g
|
||||
id="g56"
|
||||
transform="translate(206.6116,1192.843)"><path
|
||||
d="m 0,0 c -106.512,0 -192.826,-86.347 -192.826,-192.843 0,-106.496 86.314,-192.843 192.826,-192.843 106.512,0 192.843,86.347 192.843,192.843 C 192.843,-86.347 106.512,0 0,0"
|
||||
style="fill:#ffffff;fill-opacity:1;fill-rule:nonzero;stroke:none"
|
||||
id="path58"
|
||||
inkscape:connector-curvature="0" /></g><g
|
||||
id="g60"
|
||||
transform="translate(310,928.7273)"><path
|
||||
d="M 0,0 -88.744,-51.24 V 55.405 L 0,103.355 Z m -105.471,80.231 -105.388,55.868 105.388,60.86 105.405,-60.86 z m -15.868,-131.454 -89.074,51.421 v 103.736 l 89.074,-48.116 z m 17.951,329.587 C -217.504,278.364 -310,185.851 -310,71.736 c 0,-114.116 92.496,-206.629 206.612,-206.629 114.115,0 206.611,92.513 206.611,206.629 0.017,114.115 -92.479,206.628 -206.611,206.628"
|
||||
style="fill:#1caad9;fill-opacity:1;fill-rule:nonzero;stroke:none"
|
||||
id="path62"
|
||||
inkscape:connector-curvature="0" /></g></g></g></g></svg>
|
||||
|
After Width: | Height: | Size: 11 KiB |
@@ -0,0 +1,77 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!-- Created with Inkscape (http://www.inkscape.org/) -->
|
||||
|
||||
<svg
|
||||
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||
xmlns:cc="http://creativecommons.org/ns#"
|
||||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns:svg="http://www.w3.org/2000/svg"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||
width="64"
|
||||
height="64"
|
||||
viewBox="0 0 16.933329 16.933333"
|
||||
version="1.1"
|
||||
id="svg4526"
|
||||
inkscape:version="0.92.1 r15371"
|
||||
sodipodi:docname="web-sketchfab.svg">
|
||||
<defs
|
||||
id="defs4520" />
|
||||
<sodipodi:namedview
|
||||
id="base"
|
||||
pagecolor="#ffffff"
|
||||
bordercolor="#666666"
|
||||
borderopacity="1.0"
|
||||
inkscape:pageopacity="0.0"
|
||||
inkscape:pageshadow="2"
|
||||
inkscape:zoom="2.8"
|
||||
inkscape:cx="62.910611"
|
||||
inkscape:cy="2.0041616"
|
||||
inkscape:document-units="mm"
|
||||
inkscape:current-layer="layer1"
|
||||
showgrid="false"
|
||||
units="px"
|
||||
width="49px"
|
||||
inkscape:window-width="1360"
|
||||
inkscape:window-height="739"
|
||||
inkscape:window-x="1920"
|
||||
inkscape:window-y="0"
|
||||
inkscape:window-maximized="1" />
|
||||
<metadata
|
||||
id="metadata4523">
|
||||
<rdf:RDF>
|
||||
<cc:Work
|
||||
rdf:about="">
|
||||
<dc:format>image/svg+xml</dc:format>
|
||||
<dc:type
|
||||
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
|
||||
<dc:title></dc:title>
|
||||
</cc:Work>
|
||||
</rdf:RDF>
|
||||
</metadata>
|
||||
<g
|
||||
inkscape:label="Layer 1"
|
||||
inkscape:groupmode="layer"
|
||||
id="layer1"
|
||||
transform="translate(0,-280.06667)">
|
||||
<g
|
||||
id="g56"
|
||||
transform="matrix(0.03906056,0,0,-0.03906056,8.4531576,281.04755)">
|
||||
<path
|
||||
d="m 0,0 c -106.512,0 -192.826,-86.347 -192.826,-192.843 0,-106.496 86.314,-192.843 192.826,-192.843 106.512,0 192.843,86.347 192.843,192.843 C 192.843,-86.347 106.512,0 0,0"
|
||||
style="fill:#ffffff;fill-opacity:1;fill-rule:nonzero;stroke:none"
|
||||
id="path58"
|
||||
inkscape:connector-curvature="0" />
|
||||
</g>
|
||||
<g
|
||||
id="g60"
|
||||
transform="matrix(0.03906056,0,0,-0.03906056,12.491566,291.36405)">
|
||||
<path
|
||||
d="M 0,0 -88.744,-51.24 V 55.405 L 0,103.355 Z m -105.471,80.231 -105.388,55.868 105.388,60.86 105.405,-60.86 z m -15.868,-131.454 -89.074,51.421 v 103.736 l 89.074,-48.116 z m 17.951,329.587 C -217.504,278.364 -310,185.851 -310,71.736 c 0,-114.116 92.496,-206.629 206.612,-206.629 114.115,0 206.611,92.513 206.611,206.629 0.017,114.115 -92.479,206.628 -206.611,206.628"
|
||||
style="fill:#1caad9;fill-opacity:1;fill-rule:nonzero;stroke:none"
|
||||
id="path62"
|
||||
inkscape:connector-curvature="0" />
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 2.7 KiB |
@@ -0,0 +1,228 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>Form</class>
|
||||
<widget class="QWidget" name="Form">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>218</width>
|
||||
<height>548</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Sketchfab exporter</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>200</width>
|
||||
<height>43</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="pixmap">
|
||||
<pixmap resource="../Web.qrc">:/icons/Sketchfab.svg</pixmap>
|
||||
</property>
|
||||
<property name="scaledContents">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_7">
|
||||
<property name="text">
|
||||
<string>What to upload?</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QRadioButton" name="Radio_Selection">
|
||||
<property name="text">
|
||||
<string>Selection</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QRadioButton" name="Radio_Document">
|
||||
<property name="text">
|
||||
<string>All visible objects</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Fixed</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="text">
|
||||
<string>Model name</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item alignment="Qt::AlignRight">
|
||||
<widget class="QCheckBox" name="Check_Private">
|
||||
<property name="text">
|
||||
<string>Private</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="Text_Name"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="text">
|
||||
<string>Description</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="Text_Description"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_5">
|
||||
<property name="text">
|
||||
<string>Tags (separated by commas)</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_4">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_8">
|
||||
<property name="text">
|
||||
<string>freecad,</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="Text_Tags">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_6">
|
||||
<property name="text">
|
||||
<string>Format</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="Combo_Filetype">
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>OBJ + MTL (Arch exporter)</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>OBJ (standard Mesh exporter)</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>DAE (Collada)</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>STL</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>IGES (shapes only)</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>IV (buggy)</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>Sketchfab API token</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QLineEdit" name="Text_Token">
|
||||
<property name="echoMode">
|
||||
<enum>QLineEdit::Password</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="Button_Token">
|
||||
<property name="text">
|
||||
<string>Obtain</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="Button_Upload">
|
||||
<property name="text">
|
||||
<string>Upload</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QProgressBar" name="ProgressBar">
|
||||
<property name="value">
|
||||
<number>25</number>
|
||||
</property>
|
||||
<property name="format">
|
||||
<string>uploading</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="Button_View">
|
||||
<property name="text">
|
||||
<string>Success! View uploaded online</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources>
|
||||
<include location="../Web.qrc"/>
|
||||
</resources>
|
||||
<connections/>
|
||||
</ui>
|
||||
@@ -333,7 +333,9 @@ Gui::ToolBarItem* Workbench::setupToolBars() const
|
||||
<< "Web_BrowserStop"
|
||||
<< "Separator"
|
||||
<< "Web_BrowserZoomIn"
|
||||
<< "Web_BrowserZoomOut";
|
||||
<< "Web_BrowserZoomOut"
|
||||
<< "Separator"
|
||||
<< "Web_Sketchfab";
|
||||
|
||||
return root;
|
||||
|
||||
|
||||
@@ -0,0 +1,194 @@
|
||||
#***************************************************************************
|
||||
#* *
|
||||
#* Copyright (c) 2017 - Yorik van Havre <[email protected]> *
|
||||
#* *
|
||||
#* This program is free software; you can redistribute it and/or modify *
|
||||
#* it under the terms of the GNU Lesser General Public License (LGPL) *
|
||||
#* as published by the Free Software Foundation; either version 2 of *
|
||||
#* the License, or (at your option) any later version. *
|
||||
#* for detail see the LICENCE text file. *
|
||||
#* *
|
||||
#* This program is distributed in the hope that it will be useful, *
|
||||
#* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
#* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
#* GNU Library General Public License for more details. *
|
||||
#* *
|
||||
#* You should have received a copy of the GNU Library General Public *
|
||||
#* License along with this program; if not, write to the Free Software *
|
||||
#* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 *
|
||||
#* USA *
|
||||
#* *
|
||||
#***************************************************************************
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
__title__ = "Sketchfab uploader"
|
||||
__author__ = "Yorik van Havre"
|
||||
__url__ = "http://www.freecadweb.org"
|
||||
|
||||
import FreeCAD, FreeCADGui, WebGui, os, zipfile, requests, tempfile
|
||||
from PySide import QtCore, QtGui
|
||||
|
||||
# \cond
|
||||
try:
|
||||
def translate(context, text, disambig=None):
|
||||
return QtGui.QApplication.translate(context, text, disambig, QtGui.QApplication.UnicodeUTF8)
|
||||
except AttributeError:
|
||||
def translate(context, text, disambig=None):
|
||||
return QtGui.QApplication.translate(context, text, disambig)
|
||||
# \endcond
|
||||
|
||||
SKETCHFAB_UPLOAD_URL = "https://api.sketchfab.com/v1/models"
|
||||
SKETCHFAB_TOKEN_URL = "https://sketchfab.com/settings/password"
|
||||
SKETCHFAB_MODEL_URL = "https://sketchfab.com/show/"
|
||||
|
||||
|
||||
class SketchfabTaskPanel:
|
||||
|
||||
'''The TaskPanel for Sketchfab upload'''
|
||||
|
||||
def __init__(self):
|
||||
|
||||
self.url = None
|
||||
self.form = FreeCADGui.PySideUic.loadUi(":/ui/TaskDlgSketchfab.ui")
|
||||
self.form.ProgressBar.hide()
|
||||
self.form.Button_View.hide()
|
||||
QtCore.QObject.connect(self.form.Button_Token,QtCore.SIGNAL("pressed()"),self.getToken)
|
||||
QtCore.QObject.connect(self.form.Button_Upload,QtCore.SIGNAL("pressed()"),self.upload)
|
||||
QtCore.QObject.connect(self.form.Button_View,QtCore.SIGNAL("pressed()"),self.viewModel)
|
||||
self.form.Text_Name.setText(FreeCAD.ActiveDocument.Label)
|
||||
self.form.Text_Token.setText(FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/Web").GetString("SketchfabToken",""))
|
||||
|
||||
def isAllowedAlterSelection(self):
|
||||
|
||||
return True
|
||||
|
||||
def isAllowedAlterView(self):
|
||||
|
||||
return True
|
||||
|
||||
def getStandardButtons(self):
|
||||
|
||||
return int(QtGui.QDialogButtonBox.Close)
|
||||
|
||||
def accept(self):
|
||||
|
||||
FreeCADGui.ActiveDocument.resetEdit()
|
||||
return True
|
||||
|
||||
def getToken(self):
|
||||
|
||||
QtGui.QDesktopServices.openUrl(SKETCHFAB_TOKEN_URL)
|
||||
|
||||
def saveFile(self):
|
||||
|
||||
import FreeCADGui
|
||||
if self.form.Radio_Selection.isChecked():
|
||||
objects = FreeCADGui.Selection.getSelection()
|
||||
else:
|
||||
objects = [obj for obj in FreeCAD.ActiveDocument.Objects if obj.ViewObject.isVisible()]
|
||||
if not objects:
|
||||
QtGui.QMessageBox.critical(None,translate("Web","Nothing to upload"),translate("The selection of the document contains no object to upload"))
|
||||
return None
|
||||
filename = os.path.join(tempfile._get_default_tempdir(),next(tempfile._get_candidate_names()))
|
||||
filetype = self.form.Combo_Filetype.currentIndex()
|
||||
# 0 = obj + mtl, 1 = obj, 2 = dae, 3 = stl, 4 = IGES, 5 = iv (currently not working)
|
||||
if filetype == 0: # OBJ + MTL
|
||||
import importOBJ
|
||||
importOBJ.export(objects,filename+".obj")
|
||||
return self.packFiles(filename,[filename+".obj",filename+".mtl"])
|
||||
elif filetype == 1: # OBJ (mesh exporter)
|
||||
import Mesh
|
||||
Mesh.export(objects,filename+".obj")
|
||||
return self.packFiles(filename,[filename+".obj"])
|
||||
elif filetype == 2: # DAE
|
||||
import importDAE
|
||||
importDAE.export(objects,filename+".dae")
|
||||
return self.packFiles(filename,[filename+".dae"])
|
||||
elif filetype == 3: # STL
|
||||
import Mesh
|
||||
Mesh.export(objects,filename+".stl")
|
||||
return self.packFiles(filename,[filename+".stl"])
|
||||
elif filetype == 4: # IGES
|
||||
import Part
|
||||
Part.export(objects,filename+".iges")
|
||||
return self.packFiles(filename,[filename+".iges"])
|
||||
elif filetype == 5: # STL
|
||||
import FreeCADGui
|
||||
FreeCADGui.export(objects,filename+".iv")
|
||||
return self.packFiles(filename,[filename+".iv"])
|
||||
|
||||
def packFiles(self,filename,fileslist):
|
||||
|
||||
originalname = os.path.basename(fileslist[0])
|
||||
for f in fileslist:
|
||||
if not os.path.exists(f):
|
||||
return None
|
||||
z = zipfile.ZipFile(filename+".zip","w")
|
||||
for f in fileslist:
|
||||
z.write(f)
|
||||
z.close()
|
||||
for f in fileslist:
|
||||
os.remove(f)
|
||||
s = os.path.getsize(filename+".zip")
|
||||
if s > 1048576:
|
||||
size = str(s >> 20)+" MB"
|
||||
else:
|
||||
size = str(s >> 10)+" KB"
|
||||
return (filename+".zip",originalname,size)
|
||||
|
||||
def upload(self):
|
||||
|
||||
if not self.form.Text_Name.text():
|
||||
QtGui.QMessageBox.critical(None,translate("Web","Model name is empty"),translate("You must provide a name for your model"))
|
||||
return
|
||||
if not self.form.Text_Token.text():
|
||||
QtGui.QMessageBox.critical(None,translate("Web","No token provided"),translate("The token is empty. Please press the Obtain button to get your user API token from Sketchfab, then copy / paste the API token to the field below"))
|
||||
return
|
||||
FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/Web").SetString("SketchfabToken",self.form.Text_Token.text())
|
||||
pack = self.saveFile()
|
||||
if not pack:
|
||||
QtGui.QMessageBox.critical(None,translate("Web","File packing error"),translate("Unable to save and zip a file for upload"))
|
||||
return
|
||||
data = {
|
||||
"title": self.form.Text_Name.text(),
|
||||
"description": self.form.Text_Description.text(),
|
||||
"filename": pack[1],
|
||||
"tags": "freecad,"+self.form.Text_Tags.text(),
|
||||
"private": self.form.Check_Private.isChecked(),
|
||||
"token": self.form.Text_Token.text(),
|
||||
"source": "freecad",
|
||||
}
|
||||
files = {
|
||||
"fileModel": open(pack[0], 'rb'),
|
||||
}
|
||||
self.form.Button_Upload.hide()
|
||||
# for now this is a fake progress bar, it won't move, just to show the user that the upload is in progress
|
||||
self.form.ProgressBar.setFormat(translate("Web","Uploading")+" "+pack[2]+"...")
|
||||
self.form.ProgressBar.show()
|
||||
try:
|
||||
r = requests.post(SKETCHFAB_UPLOAD_URL, data=data, files=files, verify=False)
|
||||
except requests.exceptions.RequestException as e:
|
||||
QtGui.QMessageBox.critical(None,translate("Web","Upload error"),translate("Upload failed:")+" "+str(e))
|
||||
self.form.ProgressBar.hide()
|
||||
self.form.Button_Upload.show()
|
||||
return
|
||||
result = r.json()
|
||||
if r.status_code != requests.codes.ok:
|
||||
QtGui.QMessageBox.critical(None,translate("Web","Upload error"),translate("Upload failed:")+" "+result["error"])
|
||||
self.form.ProgressBar.hide()
|
||||
self.form.Button_Upload.show()
|
||||
return
|
||||
self.url = SKETCHFAB_MODEL_URL + result["result"]["id"]
|
||||
self.form.ProgressBar.hide()
|
||||
self.form.Button_View.show()
|
||||
|
||||
def viewModel(self):
|
||||
|
||||
if self.url:
|
||||
QtGui.QDesktopServices.openUrl(self.url)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user