Skip to content

Commit 5665635

Browse files
committed
Update
Update
1 parent e6aafa1 commit 5665635

9 files changed

+753
-3
lines changed

Autodesk.AutoCAD.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3984,17 +3984,19 @@ var Autodesk;
39843984
if (typeof (jsFunc) !== 'function') {
39853985
throw TypeError("jsFunc should be of type function");
39863986
}
3987-
3987+
unregisterCallback(jsFunc);
39883988
//syncronously execute the adding of the command, this registers
39893989
//the command with Autocad. autocad will fire a synchronous event,
39903990
//identified by globalName when the command is typed
39913991
var retCode = AutoCAD.EditorInterop.addCommand(groupName, globalName, localName, flags);
3992+
console.log(retCode);
39923993
if (retCode != Acad.ErrorStatus.eJsOk) {
3993-
throw Error("Error: add command failed.");
3994+
//throw Error("Error: add command failed.");
39943995
}
39953996

39963997
//now register a callback with the globalName so that js gets called when the command
39973998
//is invoked
3999+
39984000
registerCallback(groupName + "." + globalName, jsFunc);
39994001
}
40004002
Editor.addCommand = addCommand;
@@ -6029,10 +6031,12 @@ var Autodesk;
60296031
EditorInterop.executeCommand = executeCommand;
60306032

60316033
function addCommand(groupName, globalName, localName, flags) {
6034+
60326035
var jsonStr = exec(JSON.stringify({
60336036
functionName: 'Ac_EditorInterop.addCommand',
60346037
functionParams: { groupName: groupName, globalName: globalName, localName: localName, flags: flags }
60356038
}));
6039+
60366040
var jsonObj = JSON.parse(jsonStr);
60376041

60386042
if (jsonObj.retCode == undefined)

CustomCommand.html

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
4+
<head>
5+
<meta charset="utf-8">
6+
<script type="text/javascript" src="C:\Temp\AJA\Autodesk.AutoCAD.js"></script>
7+
<title>Sample App</title>
8+
<link rel="stylesheet"
9+
href="https://fonts.googleapis.com/css?family=Open+Sans:light">
10+
<link rel="stylesheet" href="acadStyle.css">
11+
<script>
12+
console.clear();
13+
console.log(Acad.Editor);
14+
function callback() { Acad.Editor.executeCommand("_zoom", "e", " ") };
15+
let run = function () {
16+
Acad.Editor.addCommand("JSCOMMAND", "customcommand", "customcommand", Acad.CommandFlag.TRANSPARENT, callback);
17+
}
18+
19+
</script>
20+
</head>
21+
22+
<body>
23+
24+
25+
<div class="grid-container">
26+
27+
<div class="item1">
28+
<div class="clsHeader">Custom Command</div>
29+
</div>
30+
31+
<div class="item2">
32+
<div class="clsMain">
33+
<label class="">something</label>
34+
<p>
35+
36+
</p>
37+
<label class="acadBtn">something else</label>
38+
<p>
39+
40+
</p>
41+
<button class="acadBtn">
42+
stuff
43+
</button>
44+
<input type='button' onclick='window.location.reload()' value='Reload' style="display:inline" />
45+
46+
<input type='button' onclick='run()' value="custom command" />
47+
<p></p>
48+
<label>Click the button then run the command "customcommand"</label>
49+
<p>
50+
</p>
51+
</div>
52+
</div>
53+
54+
<div class="item3">
55+
<div class="clsFooter"><a href="https://www.paypal.me/georgeendrulat"><button type="button">Donate</button></a></div>
56+
57+
</div>
58+
59+
</div>
60+
61+
</body>
62+
63+
</html>

acadStyle.css

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
.acadBtn,
2+
.item1 {
3+
border-style: solid;
4+
border-width: 1px
5+
}
6+
7+
.item1,
8+
.item2,
9+
.item3 {
10+
display: flex
11+
}
12+
13+
body,
14+
html,
15+
iframe {
16+
margin: 0;
17+
height: 100%;
18+
font-family: "Open Sans", serif;
19+
width: 100%;
20+
}
21+
22+
.clsHeader {
23+
margin: auto
24+
}
25+
26+
.acadBtn {
27+
background: #787878;
28+
background: -moz-linear-gradient(top, #787878 0, #545454 100%);
29+
background: -webkit-linear-gradient(top, #787878 0, #545454 100%);
30+
background: linear-gradient(to bottom, #787878 0, #545454 100%);
31+
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#787878', endColorstr='#545454', GradientType=0);
32+
padding: 3px;
33+
margin: 3px;
34+
border-color: #323232;
35+
color: #fff
36+
}
37+
38+
.clsMain {
39+
margin: auto;
40+
background-color: rgba(100, 100, 100, .2);
41+
width: 100%;
42+
}
43+
44+
.clsFooter {
45+
background-color: rgb(87, 87, 87);
46+
width: 100%
47+
}
48+
49+
.item1 {
50+
grid-area: header;
51+
background: #535353;
52+
background: -moz-linear-gradient(top, #535353 0, #464646 100%);
53+
background: -webkit-linear-gradient(top, #535353 0, #464646 100%);
54+
background: linear-gradient(to bottom, #535353 0, #464646 100%);
55+
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#535353', endColorstr='#464646', GradientType=0);
56+
border-color: #535353
57+
}
58+
59+
.item2 {
60+
grid-area: main;
61+
background-color: #5e5e5e;
62+
max-height: 800px;
63+
}
64+
65+
.item3 {
66+
grid-area: footer;
67+
background-color: rgba(255, 255, 255, 1);
68+
text-align: center
69+
}
70+
71+
.grid-container {
72+
position: fixed;
73+
top: 0;
74+
left: 0;
75+
bottom: 0;
76+
right: 0;
77+
display: grid;
78+
grid-template-areas: 'header' 'main' 'footer';
79+
grid-gap: 1px;
80+
background-color: #3E3E3E;
81+
padding: 1px;
82+
font-size: 14px;
83+
grid-template-columns: 1fr;
84+
grid-template-rows: 0.5fr 4fr 0.5fr;
85+
color: #fff;
86+
87+
}

app.html

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
4+
<head>
5+
<meta charset="utf-8">
6+
<script type="text/javascript" src="C:\Temp\AJA\Autodesk.AutoCAD.js"></script>
7+
<title>Sample App</title>
8+
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Open+Sans:light">
9+
<link rel="stylesheet" href="acadStyle.css">
10+
<style>
11+
body {
12+
color: #fff;
13+
}
14+
</style>
15+
</head>
16+
17+
<body>
18+
<div class="grid-container">
19+
<div class="item1">
20+
<div class="clsHeader" id="headerText">Pipe Sizes</div>
21+
</div>
22+
<div class="item2">
23+
<div class="clsMain">
24+
<iframe id="fragContainer" src="" frameBorder="0"></iframe>
25+
</div>
26+
</div>
27+
<div class="item3">
28+
<div class="clsFooter">
29+
<a href="https://www.paypal.me/georgeendrulat">
30+
<button type="button">Donate</button>
31+
</a>
32+
</div>
33+
</div>
34+
</div>
35+
36+
<script>
37+
function getURLParameter(name) {
38+
return decodeURIComponent((new RegExp('[?|&]' + name + '=' + '([^&;]+?)(&|#|;|$)').exec(location.search) || [null, ''])[1].replace(/\+/g, '%20')) || null;
39+
}
40+
let title = getURLParameter("Title");
41+
document.getElementById("headerText").innerHTML = title;
42+
let frag = getURLParameter("Frag");
43+
document.getElementById('fragContainer').src = frag + ".html";
44+
45+
</script>
46+
</body>
47+
48+
</html>

capture.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<html lang="en">
33
<head>
44
<meta charset="utf-8">
5-
<script type="text/javascript" src="C:\Temp\Autodesk.AutoCAD.js"></script>
5+
<script type="text/javascript" src="C:\Temp\AJA\Autodesk.AutoCAD.js"></script>
66
<title>Sample App</title>
77
<script>
88

loadCapture.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Acad.Application.addPalette("Name of palette", "c:/Temp/AJA/capture.html");

loadCustomCommand.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Acad.Application.addPalette("Name of palette", "c:/Temp/AJA/CustomCommand.html");

loadPipeSizes.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
let title = "test";
2+
let Path = "c:/Temp/AJA/";
3+
let Fragment = "pipeSizesFrag";
4+
let templateFile = "app.html?";
5+
let param1 = "Title="+title;
6+
let param2 = "&Frag=" + Fragment;
7+
8+
let ConcatURL = (Path + templateFile + param1 + param2);
9+
alert(ConcatURL);
10+
Acad.Application.addPalette(title, ConcatURL);

0 commit comments

Comments
 (0)