-
-
Save stephensmitchell/b5868592d03f2d5ae748bf1ca39b80f2 to your computer and use it in GitHub Desktop.
fusion-custom-palette-html
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!DOCTYPE html> | |
| <html> | |
| <head> | |
| <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"> | |
| <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> | |
| <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script> | |
| </head> | |
| <body> | |
| <div class="row"> | |
| <div class="col-sm-2"></div> | |
| <div class="col-sm-8"> | |
| <div class="form-group"> | |
| <label>Name:</label> | |
| <input type="text" class="form-control" id="txtFileName"> | |
| </div> | |
| <div class="dropdown"> | |
| <button class="btn btn-primary dropdown-toggle" type="button" data-toggle="dropdown" >Type | |
| <span class="caret"></span></button> | |
| <ul class="dropdown-menu" id="dropdownfiletype"> | |
| <li><a href="#">Archive Files (*f3d)</a></li> | |
| <li><a href="#">IGES Files (*igs *iges)</a></li> | |
| <li><a href="#">SAT Files (*sat)</a></li> | |
| <li><a href="#">SMT Files (*smt)</a></li> | |
| <li><a href="#">STEP Files (*stp *step)</a></li> | |
| </ul> | |
| <label id="lableFileType">Archive Files (*f3d)</label> | |
| </div> | |
| <div class="checkbox"> | |
| <label> | |
| <input type="checkbox" value=""> | |
| <span class="cr"><i class="cr-icon glyphicon glyphicon-arrow-right"></i></span> | |
| Save to a project in the cloud (not yet implemented) | |
| </label> | |
| <input type="text" class="form-control" id="txtCloudPath"> | |
| </div> | |
| <div class="checkbox"> | |
| <label> | |
| <input type="checkbox" value="" checked> | |
| <span class="cr"><i class="cr-icon glyphicon glyphicon-arrow-right"></i></span> | |
| Save to my computer | |
| </label> | |
| <input type="text" class="form-control" disabled id="txtLocalPath" value="C:/temp"> | |
| <input type="file" id="FileUpload" webkitdirectory="" directory=""/> | |
| <div> | |
| <h3>Image Gallery</h3> | |
| <div class="col-md-4"> | |
| <div class="thumbnail"> | |
| <a href="https://gallery.autodesk.com/fusion360/projects/fusion-shaver-holder-normal-and-exploded"> | |
| <img src="images/shaverholder.png" alt="Lights" style="width:100%;"> | |
| <div class="caption"> | |
| <p>Shaver Holder</p> | |
| </div> | |
| </a> | |
| </div> | |
| </div> | |
| <div class="col-md-4"> | |
| <div class="thumbnail"> | |
| <a href="https://gallery.autodesk.com/fusion360/projects/marble-machine-clock"> | |
| <img src="images/machineclock.png" alt="Nature" style="width:100%"> | |
| <div class="caption"> | |
| <p>Machine Clock</p> | |
| </div> | |
| </a> | |
| </div> | |
| </div> | |
| <div class="col-md-4"> | |
| <div class="thumbnail"> | |
| <a href="hhttps://gallery.autodesk.com/fusion360/projects/olsryd-9-cylinder-radial-engine"> | |
| <img src="images/radialengine.png" alt="Fjords" style="width:100%"> | |
| <div class="caption"> | |
| <p>Radial Engine</p> | |
| </div> | |
| </a> | |
| </div> | |
| </div> | |
| </div> | |
| </div> | |
| <div> | |
| <button type="button" class="btn btn-warning pull-right" id="btnCancel" onclick=btnCancelClick();>Cancel</button> | |
| <button type="button" class="btn btn-info pull-right" id="btnSave" onclick=btnSaveClick();>Save</button> | |
| </div> | |
| </div> | |
| <div class="col-sm-2"></div> | |
| </div> | |
| </body> | |
| <script> | |
| //******send data from HTML to Fusion 360******** | |
| //when [save] button is clicked | |
| function btnSaveClick(){ | |
| //will save the file and close the palette | |
| var filename = document.getElementById('txtFileName').value; | |
| var filetype = document.getElementById('lableFileType').textContent; | |
| var filepath = document.getElementById('txtLocalPath').value; | |
| //var localpath = | |
| var sendStrJson = { | |
| action : "save", | |
| arguments : {filename:filename,filetype:filetype,filepath:filepath} | |
| }; | |
| adsk.fusionSendData('send', JSON.stringify(sendStrJson)); | |
| } | |
| //when [cancel] button is clicked | |
| function btnCancelClick(){ | |
| //will close the palette only | |
| var sendStrJson = { | |
| action : "cancel", | |
| arguments : null | |
| }; | |
| adsk.fusionSendData('send', JSON.stringify(sendStrJson)); | |
| } | |
| // when [type] dropdown button is clicked | |
| //by jquery | |
| $(".dropdown-menu a").on("click",function(e){ | |
| if(this.parentNode.parentNode.id == 'dropdownfiletype') | |
| { | |
| $("#lableFileType").text(this.innerText); | |
| } | |
| }); | |
| $('input[type=file]').change(function () { | |
| //not working currently... | |
| console.log(this.files[0].webkitdirectory); | |
| document.getElementById('txtLocalPath').value = this.files[0].webkitdirectory; | |
| }); | |
| //************************************** | |
| //******receive data from Fusion 360******** | |
| window.fusionJavaScriptHandler = {handle: function(action, data){ | |
| try { | |
| switch (action) { | |
| case 'initialFilePath': | |
| // set the intial value of file path | |
| document.getElementById('p1').innerHTML = data | |
| break; | |
| case 'debugger': | |
| debugger; | |
| break; | |
| } | |
| } catch (e) { | |
| console.log(e); | |
| console.log('exception caught with action: ' + action + ', data: ' + data); | |
| return 'FAILED'; | |
| } | |
| return 'OK'; | |
| }}; | |
| </script> | |
| </html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment