40093367 |
1 | # Script reproducing creation of bottle model as described in OCCT Tutorial |
ab91ab6f |
2 | #Category: Modeling |
3 | #Title: OCCT Tutorial bottle shape |
40093367 |
4 | |
5 | pload MODELING VISUALIZATION |
6 | |
821edd22 |
7 | puts "Constructing bottle body..." |
40093367 |
8 | |
9 | # set basic dimensions |
10 | dset height 70 |
11 | dset width 50 |
12 | dset thickness 30 |
13 | |
14 | # construct base profile (half) |
15 | vertex v1 -width/2 0 0 |
16 | vertex v2 -width/2 -thickness/4 0 |
17 | edge e1 v1 v2 |
18 | |
19 | point p2 -width/2 -thickness/4 0 |
20 | point p3 0 -thickness/2 0 |
21 | point p4 width/2 -thickness/4 0 |
22 | catch {gcarc arc cir p2 p3 p4} |
23 | mkedge e2 arc |
24 | |
25 | vertex v4 width/2 -thickness/4 0 |
26 | vertex v5 width/2 0 0 |
27 | edge e3 v4 v5 |
28 | |
29 | wire w1 e1 e2 e3 |
30 | |
31 | # complete profile by mirror and make a prism |
32 | copy w1 w2 |
33 | tmirror w2 0 0 0 0 1 0 |
34 | |
35 | wire w3 w1 w2 |
36 | mkplane f w3 |
37 | |
38 | prism p f 0 0 height |
39 | |
40 | # fillet all edges |
41 | explode p e |
42 | blend b p thickness/12 p_1 thickness/12 p_2 thickness/12 p_3 thickness/12 p_4 thickness/12 p_5 thickness/12 p_6 thickness/12 p_7 thickness/12 p_8 thickness/12 p_9 thickness/12 p_10 thickness/12 p_11 thickness/12 p_12 thickness/12 p_13 thickness/12 p_14 thickness/12 p_15 thickness/12 p_16 thickness/12 p_17 thickness/12 p_18 |
43 | |
44 | # neck dimensions |
45 | dset neckradius thickness/4 |
46 | dset neckheight height/10 |
47 | |
48 | # add neck |
49 | pcylinder c neckradius neckheight |
50 | ttranslate c 0 0 height |
51 | |
52 | bfuse f b c |
53 | |
54 | # make body hollow |
55 | explode c f |
56 | offsetshape body f -thickness/50 1.e-3 c_2 |
57 | |
821edd22 |
58 | puts "Constructing threading..." |
40093367 |
59 | |
60 | # make two cylinders |
61 | cylinder c1 0 0 height 0 0 1 neckradius*0.99 |
62 | cylinder c2 0 0 height 0 0 1 neckradius*1.05 |
63 | |
64 | # define threading dimensions in parametric space |
65 | dset major 2*pi |
66 | dset minor neckheight/10 |
67 | |
68 | # make parametric curves for threading |
69 | ellipse el1 2*pi neckheight/2 2*pi neckheight/4 major minor |
70 | ellipse el2 2*pi neckheight/2 2*pi neckheight/4 major minor/4 |
71 | |
72 | trim arc1 el1 0 pi |
73 | trim arc2 el2 0 pi |
74 | |
75 | 2dcvalue el1 0 x1 y1 |
76 | 2dcvalue el1 pi x2 y2 |
77 | |
78 | line l x1 y1 x2-x1 y2-y1 |
79 | parameters l x2 y2 1.e-9 U |
80 | trim s l 0 U |
81 | |
82 | # construct 3d edges and wires |
83 | mkedge E1OnS1 arc1 c1 0 pi |
84 | mkedge E2OnS1 s c1 0 U |
85 | mkedge E1OnS2 arc2 c2 0 pi |
86 | mkedge E2OnS2 s c2 0 U |
87 | |
88 | wire tw1 E1OnS1 E2OnS1 |
89 | wire tw2 E1OnS2 E2OnS2 |
90 | mkedgecurve tw1 1.e-5 |
91 | mkedgecurve tw2 1.e-5 |
92 | |
93 | # build threading as solid |
94 | thrusections -N thread 1 0 tw1 tw2 |
95 | |
821edd22 |
96 | puts "Putting together and writing \"Open CASCADE\"..." |
97 | |
b514beda |
98 | # define text |
ac84fcf6 |
99 | text2brep text2d OpenCASCADE -font Times-Roman -height 8 -aspect bold -composite off |
b514beda |
100 | prism text text2d 0 0 2 |
101 | trotate text 0 0 0 0 1 0 90 |
102 | ttranslate text 24.75 -2 65 |
103 | |
104 | # cut operation |
821edd22 |
105 | bcut bodytext body text |
7cb89917 |
106 | bop bodytext thread |
107 | bopfuse bottle |
821edd22 |
108 | |
109 | puts "Showing result..." |
40093367 |
110 | |
111 | # display result |
112 | vdisplay bottle |
113 | vfit |
114 | vsetdispmode 1 |
63fad07e |
115 | vaspects -isoontriangulation 1 |