save plugins Fusion 360
This commit is contained in:
BIN
tamplate/commands/paletteShow/resources/16x16.png
Normal file
BIN
tamplate/commands/paletteShow/resources/16x16.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 340 B |
BIN
tamplate/commands/paletteShow/resources/32x32.png
Normal file
BIN
tamplate/commands/paletteShow/resources/32x32.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 587 B |
BIN
tamplate/commands/paletteShow/resources/64x64.png
Normal file
BIN
tamplate/commands/paletteShow/resources/64x64.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.1 KiB |
39
tamplate/commands/paletteShow/resources/html/index.html
Normal file
39
tamplate/commands/paletteShow/resources/html/index.html
Normal file
@@ -0,0 +1,39 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Title</title>
|
||||
<script src="static/palette.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div>
|
||||
|
||||
<h1>Fusion 360 Palette Sample</h1>
|
||||
<div>
|
||||
<a href="https://help.autodesk.com/view/fusion360/ENU/?guid=GUID-6C0C8148-98D0-4DBC-A4EC-D8E03A8A3B5B">
|
||||
Learn more about working with Palettes in Fusion 360
|
||||
</a>
|
||||
</div>
|
||||
<br><hr>
|
||||
|
||||
<h3>Send Data to HTML Event Handler</h3>
|
||||
<div style='margin-left: 30px;'>
|
||||
<label for="sampleData"><b>Data to send:</b></label>
|
||||
<input type="text" id="sampleData" value="Enter Some Text"><br/><br/>
|
||||
<button type='button' onclick='sendInfoToFusion()' style='background-color: #cccccc; padding: 5px'>
|
||||
<b>Send HTML Event</b>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<h3>HTML Event Response Value:</h3>
|
||||
<div id='returnValue' style='margin-left: 30px;'>Response</div>
|
||||
|
||||
<h3>Message from "Send to Palette" Command</h3>
|
||||
<div style='margin-left: 30px;'>
|
||||
<p id='fusionMessage'>Message from Fusion</p>
|
||||
<br/><br/>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,48 @@
|
||||
function getDateString() {
|
||||
const today = new Date();
|
||||
const date = `${today.getDate()}/${today.getMonth() + 1}/${today.getFullYear()}`;
|
||||
const time = `${today.getHours()}:${today.getMinutes()}:${today.getSeconds()}`;
|
||||
return `Date: ${date}, Time: ${time}`;
|
||||
}
|
||||
|
||||
function sendInfoToFusion() {
|
||||
const args = {
|
||||
arg1: document.getElementById("sampleData").value,
|
||||
arg2: getDateString()
|
||||
};
|
||||
|
||||
// Send the data to Fusion as a JSON string. The return value is a Promise.
|
||||
adsk.fusionSendData("messageFromPalette", JSON.stringify(args)).then((result) =>
|
||||
document.getElementById("returnValue").innerHTML = `${result}`
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
function updateMessage(messageString) {
|
||||
// Message is sent from the add-in as a JSON string.
|
||||
const messageData = JSON.parse(messageString);
|
||||
|
||||
// Update a paragraph with the data passed in.
|
||||
document.getElementById("fusionMessage").innerHTML =
|
||||
`<b>Your text</b>: ${messageData.myText} <br/>` +
|
||||
`<b>Your expression</b>: ${messageData.myExpression} <br/>` +
|
||||
`<b>Your value</b>: ${messageData.myValue}`;
|
||||
}
|
||||
|
||||
window.fusionJavaScriptHandler = {
|
||||
handle: function (action, data) {
|
||||
try {
|
||||
if (action === "updateMessage") {
|
||||
updateMessage(data);
|
||||
} else if (action === "debugger") {
|
||||
debugger;
|
||||
} else {
|
||||
return `Unexpected command type: ${action}`;
|
||||
}
|
||||
} catch (e) {
|
||||
console.log(e);
|
||||
console.log(`Exception caught with command: ${action}, data: ${data}`);
|
||||
}
|
||||
return "OK";
|
||||
},
|
||||
};
|
||||
Reference in New Issue
Block a user