40093367 |
1 | # Script reproducing creation of bottle model as described in OCCT Tutorial |
2 | |
3 | pload MODELING VISUALIZATION |
4 | |
5 | # Construct bottle body |
6 | |
7 | # set basic dimensions |
8 | dset height 70 |
9 | dset width 50 |
10 | dset thickness 30 |
11 | |
12 | # construct base profile (half) |
13 | vertex v1 -width/2 0 0 |
14 | vertex v2 -width/2 -thickness/4 0 |
15 | edge e1 v1 v2 |
16 | |
17 | point p2 -width/2 -thickness/4 0 |
18 | point p3 0 -thickness/2 0 |
19 | point p4 width/2 -thickness/4 0 |
20 | catch {gcarc arc cir p2 p3 p4} |
21 | mkedge e2 arc |
22 | |
23 | vertex v4 width/2 -thickness/4 0 |
24 | vertex v5 width/2 0 0 |
25 | edge e3 v4 v5 |
26 | |
27 | wire w1 e1 e2 e3 |
28 | |
29 | # complete profile by mirror and make a prism |
30 | copy w1 w2 |
31 | tmirror w2 0 0 0 0 1 0 |
32 | |
33 | wire w3 w1 w2 |
34 | mkplane f w3 |
35 | |
36 | prism p f 0 0 height |
37 | |
38 | # fillet all edges |
39 | explode p e |
40 | 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 |
41 | |
42 | # neck dimensions |
43 | dset neckradius thickness/4 |
44 | dset neckheight height/10 |
45 | |
46 | # add neck |
47 | pcylinder c neckradius neckheight |
48 | ttranslate c 0 0 height |
49 | |
50 | bfuse f b c |
51 | |
52 | # make body hollow |
53 | explode c f |
54 | offsetshape body f -thickness/50 1.e-3 c_2 |
55 | |
56 | # Construct threading |
57 | |
58 | # make two cylinders |
59 | cylinder c1 0 0 height 0 0 1 neckradius*0.99 |
60 | cylinder c2 0 0 height 0 0 1 neckradius*1.05 |
61 | |
62 | # define threading dimensions in parametric space |
63 | dset major 2*pi |
64 | dset minor neckheight/10 |
65 | |
66 | # make parametric curves for threading |
67 | ellipse el1 2*pi neckheight/2 2*pi neckheight/4 major minor |
68 | ellipse el2 2*pi neckheight/2 2*pi neckheight/4 major minor/4 |
69 | |
70 | trim arc1 el1 0 pi |
71 | trim arc2 el2 0 pi |
72 | |
73 | 2dcvalue el1 0 x1 y1 |
74 | 2dcvalue el1 pi x2 y2 |
75 | |
76 | line l x1 y1 x2-x1 y2-y1 |
77 | parameters l x2 y2 1.e-9 U |
78 | trim s l 0 U |
79 | |
80 | # construct 3d edges and wires |
81 | mkedge E1OnS1 arc1 c1 0 pi |
82 | mkedge E2OnS1 s c1 0 U |
83 | mkedge E1OnS2 arc2 c2 0 pi |
84 | mkedge E2OnS2 s c2 0 U |
85 | |
86 | wire tw1 E1OnS1 E2OnS1 |
87 | wire tw2 E1OnS2 E2OnS2 |
88 | mkedgecurve tw1 1.e-5 |
89 | mkedgecurve tw2 1.e-5 |
90 | |
91 | # build threading as solid |
92 | thrusections -N thread 1 0 tw1 tw2 |
93 | |
94 | # add threading to the body |
95 | compound body thread bottle |
96 | |
97 | # display result |
98 | vdisplay bottle |
99 | vfit |
100 | vsetdispmode 1 |