Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
Update
  • Loading branch information
WebRTCGame committed Apr 20, 2018
1 parent e6aafa1 commit 5665635
Show file tree
Hide file tree
Showing 9 changed files with 753 additions and 3 deletions.
8 changes: 6 additions & 2 deletions Autodesk.AutoCAD.js
Original file line number Diff line number Diff line change
Expand Up @@ -3984,17 +3984,19 @@ var Autodesk;
if (typeof (jsFunc) !== 'function') {
throw TypeError("jsFunc should be of type function");
}

unregisterCallback(jsFunc);
//syncronously execute the adding of the command, this registers
//the command with Autocad. autocad will fire a synchronous event,
//identified by globalName when the command is typed
var retCode = AutoCAD.EditorInterop.addCommand(groupName, globalName, localName, flags);
console.log(retCode);
if (retCode != Acad.ErrorStatus.eJsOk) {
throw Error("Error: add command failed.");
//throw Error("Error: add command failed.");
}

//now register a callback with the globalName so that js gets called when the command
//is invoked

registerCallback(groupName + "." + globalName, jsFunc);
}
Editor.addCommand = addCommand;
Expand Down Expand Up @@ -6029,10 +6031,12 @@ var Autodesk;
EditorInterop.executeCommand = executeCommand;

function addCommand(groupName, globalName, localName, flags) {

var jsonStr = exec(JSON.stringify({
functionName: 'Ac_EditorInterop.addCommand',
functionParams: { groupName: groupName, globalName: globalName, localName: localName, flags: flags }
}));

var jsonObj = JSON.parse(jsonStr);

if (jsonObj.retCode == undefined)
Expand Down
63 changes: 63 additions & 0 deletions CustomCommand.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="utf-8">
<script type="text/javascript" src="C:\Temp\AJA\Autodesk.AutoCAD.js"></script>
<title>Sample App</title>
<link rel="stylesheet"
href="https://fonts.googleapis.com/css?family=Open+Sans:light">
<link rel="stylesheet" href="acadStyle.css">
<script>
console.clear();
console.log(Acad.Editor);
function callback() { Acad.Editor.executeCommand("_zoom", "e", " ") };
let run = function () {
Acad.Editor.addCommand("JSCOMMAND", "customcommand", "customcommand", Acad.CommandFlag.TRANSPARENT, callback);
}

</script>
</head>

<body>


<div class="grid-container">

<div class="item1">
<div class="clsHeader">Custom Command</div>
</div>

<div class="item2">
<div class="clsMain">
<label class="">something</label>
<p>

</p>
<label class="acadBtn">something else</label>
<p>

</p>
<button class="acadBtn">
stuff
</button>
<input type='button' onclick='window.location.reload()' value='Reload' style="display:inline" />

<input type='button' onclick='run()' value="custom command" />
<p></p>
<label>Click the button then run the command "customcommand"</label>
<p>
</p>
</div>
</div>

<div class="item3">
<div class="clsFooter"><a href="https://www.paypal.me/georgeendrulat"><button type="button">Donate</button></a></div>

</div>

</div>

</body>

</html>
87 changes: 87 additions & 0 deletions acadStyle.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
.acadBtn,
.item1 {
border-style: solid;
border-width: 1px
}

.item1,
.item2,
.item3 {
display: flex
}

body,
html,
iframe {
margin: 0;
height: 100%;
font-family: "Open Sans", serif;
width: 100%;
}

.clsHeader {
margin: auto
}

.acadBtn {
background: #787878;
background: -moz-linear-gradient(top, #787878 0, #545454 100%);
background: -webkit-linear-gradient(top, #787878 0, #545454 100%);
background: linear-gradient(to bottom, #787878 0, #545454 100%);
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#787878', endColorstr='#545454', GradientType=0);
padding: 3px;
margin: 3px;
border-color: #323232;
color: #fff
}

.clsMain {
margin: auto;
background-color: rgba(100, 100, 100, .2);
width: 100%;
}

.clsFooter {
background-color: rgb(87, 87, 87);
width: 100%
}

.item1 {
grid-area: header;
background: #535353;
background: -moz-linear-gradient(top, #535353 0, #464646 100%);
background: -webkit-linear-gradient(top, #535353 0, #464646 100%);
background: linear-gradient(to bottom, #535353 0, #464646 100%);
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#535353', endColorstr='#464646', GradientType=0);
border-color: #535353
}

.item2 {
grid-area: main;
background-color: #5e5e5e;
max-height: 800px;
}

.item3 {
grid-area: footer;
background-color: rgba(255, 255, 255, 1);
text-align: center
}

.grid-container {
position: fixed;
top: 0;
left: 0;
bottom: 0;
right: 0;
display: grid;
grid-template-areas: 'header' 'main' 'footer';
grid-gap: 1px;
background-color: #3E3E3E;
padding: 1px;
font-size: 14px;
grid-template-columns: 1fr;
grid-template-rows: 0.5fr 4fr 0.5fr;
color: #fff;

}
48 changes: 48 additions & 0 deletions app.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="utf-8">
<script type="text/javascript" src="C:\Temp\AJA\Autodesk.AutoCAD.js"></script>
<title>Sample App</title>
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Open+Sans:light">
<link rel="stylesheet" href="acadStyle.css">
<style>
body {
color: #fff;
}
</style>
</head>

<body>
<div class="grid-container">
<div class="item1">
<div class="clsHeader" id="headerText">Pipe Sizes</div>
</div>
<div class="item2">
<div class="clsMain">
<iframe id="fragContainer" src="" frameBorder="0"></iframe>
</div>
</div>
<div class="item3">
<div class="clsFooter">
<a href="https://www.paypal.me/georgeendrulat">
<button type="button">Donate</button>
</a>
</div>
</div>
</div>

<script>
function getURLParameter(name) {
return decodeURIComponent((new RegExp('[?|&]' + name + '=' + '([^&;]+?)(&|#|;|$)').exec(location.search) || [null, ''])[1].replace(/\+/g, '%20')) || null;
}
let title = getURLParameter("Title");
document.getElementById("headerText").innerHTML = title;
let frag = getURLParameter("Frag");
document.getElementById('fragContainer').src = frag + ".html";

</script>
</body>

</html>
2 changes: 1 addition & 1 deletion capture.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<html lang="en">
<head>
<meta charset="utf-8">
<script type="text/javascript" src="C:\Temp\Autodesk.AutoCAD.js"></script>
<script type="text/javascript" src="C:\Temp\AJA\Autodesk.AutoCAD.js"></script>
<title>Sample App</title>
<script>

Expand Down
1 change: 1 addition & 0 deletions loadCapture.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Acad.Application.addPalette("Name of palette", "c:/Temp/AJA/capture.html");
1 change: 1 addition & 0 deletions loadCustomCommand.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Acad.Application.addPalette("Name of palette", "c:/Temp/AJA/CustomCommand.html");
10 changes: 10 additions & 0 deletions loadPipeSizes.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
let title = "test";
let Path = "c:/Temp/AJA/";
let Fragment = "pipeSizesFrag";
let templateFile = "app.html?";
let param1 = "Title="+title;
let param2 = "&Frag=" + Fragment;

let ConcatURL = (Path + templateFile + param1 + param2);
alert(ConcatURL);
Acad.Application.addPalette(title, ConcatURL);
Loading

0 comments on commit 5665635

Please sign in to comment.