forked from xibyte/jsketcher
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsnipets-for-modeling-api.js
163 lines (125 loc) · 4.1 KB
/
snipets-for-modeling-api.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
//Make a pipe------------------------------------------------------------------------------------------------------
{
const ctx = __CAD_APP;
const {commandInterface: oci, io} = ctx.occService;
oci.beziercurve("spine", "4",
"0", "0", "0",
"10", "0", "0",
"10", "10", "0",
"40", "10", "0",
"80", "60", "60"
);
oci.mkedge("spine", "spine");
oci.wire("spine", "spine");
oci.circle("profile", "0", "0", "0", "1", "0", "0", "2");
oci.mkedge("profile", "profile");
oci.wire("profile", "profile");
oci.mkplane("profile", "profile");
oci.pipe("p", "spine", "profile");
ctx.services.exposure.addOnScene(io.getShell("p"));
}
//Doing a sweep ---------------------------------------------------------------------------------------------------
{
const ctx = __CAD_APP;
const {commandInterface: oci, io} = ctx.occService;
oci.beziercurve("p", "4",
"0", "0", "0",
"10", "0", "0",
"20", "10", "0",
"20", "10", "0");
oci.mkedge("p", "p");
oci.wire("p", "p");
//oci.circle("c","0","0","0","1","0","0","0.2")
oci.polyline("c",
"0", "0", "0",
"0", "0", "1",
"0", "2", "2",
"0", "1", "0",
"0", "0", "0");
oci.wire("w", "c");
//does not seem to work if I convert the profile in to a plane.
//Need to figure this out to get a body and not just surfaces.
//oci.mkplane("w", "w")
oci.mksweep("p");
oci.addsweep("w");
oci.buildsweep("r", "-S");
ctx.services.exposure.addOnScene(io.getShell("r"));
}
//Revolve ------------------------------------------------------------------------------------------------------
{
const ctx = __CAD_APP;
const {commandInterface: oci, io} = ctx.occService;
oci.polyline("p", "0", "0", "0", "1", "0", "0", "1", "2", "0", "0", "1", "0", "0", "0", "0");
oci.mkplane("p", "p"); //make the input in to a face first so that we get capped ends
oci.revol("r", "p", "3", "0", "0", "0", "1", "0", "280");
ctx.services.exposure.addOnScene(io.getShell("r"));
}
//fillet -------------------------------------------------------------------------------------------------------
{
const ctx = __CAD_APP;
const {commandInterface: oci, io} = ctx.occService;
oci.box("b", "20", "20", "20");
oci.explode("b", "e");
oci.blend("b", "b", "5", "b_2");
ctx.services.exposure.addOnScene(io.getShell("b"));
}
//champher ----------------------------------------------------------------------------------------------------
{
const ctx = __CAD_APP;
const {commandInterface: oci, io} = ctx.occService;
oci.box("b", "1", "2", "3");
oci.explode("b", "e");
const bla = ["ch", "b", "b_1", "0.2", "b_2", "0.2"];
oci.chamf.call(bla);
ctx.services.exposure.addOnScene(io.getShell("ch"));
}
//shell -------------------------------------------------------------------------------------------------------
{
const ctx = __CAD_APP;
const {commandInterface: oci, io} = ctx.occService;
oci.box("b", "10", "20", "30");
oci.explode("b", "f")
oci.offsetshape("body", "b", "-1", "1.e-3", "b_2", "b_3")
ctx.services.exposure.addOnScene(io.getShell("body"));
}
//loft --------------------------------------------------------------------------------------------------------
{
const ctx = __CAD_APP;
const {commandInterface: oci, io} = ctx.occService;
oci.polyline("w1",
"0", "0", "0",
"5", "0", "0",
"5", "5", "0",
"2", "3", "0",
"0", "0", "0",
);
oci.polyline("w2",
"0", "1", "3",
"4", "1", "3",
"4", "4", "3",
"1", "3", "3",
"0", "1", "3",
);
oci.polyline("w3",
"0", "0", "5",
"5", "0", "5",
"5", "5", "5",
"2", "3", "5",
"0", "0", "5",
);
//# create the shape
oci.thrusections("th", "issolid", "isruled", "w1", "w2", "w3");
ctx.services.exposure.addOnScene(io.getShell("th"));
}
//Boolean operations ---------------------------------------------------------------------
{
const ctx = __CAD_APP;
const {commandInterface: oci, io} = ctx.occService;
oci.box("b1", "10", "10", "10");
oci.psphere("sp", "5");
oci.bop("b1", "sp");
oci.bopcommon("result");
//oci.bopfuse("result");
//oci.bopcut("result");
ctx.services.exposure.addOnScene(io.getShell("result"));
}