0025570: New Tcl sample scripts created for CAD Assistant
[occt.git] / samples / tcl / snowflake.tcl
CommitLineData
92ac0eb7 1# Creation of 2d drawing
2
3#Category: Modeling
4#Title: Snowflake - creation of 2d geometry
5
6pload MODELING AISV
7
8# make circular elements
9circle c11 5 5 0 5
10circle c12 5 5 0 3
11circle c21 18 7 0 7
12circle c22 18 7 0 5
13circle c31 28.5 5 0 5
14circle c32 28.5 5 0 3
15trim c21 c21 pi/4 -pi/4
16trim c22 c22 pi/4 -pi/4
17trim c31 c31 pi/4 -pi/4
18trim c32 c32 pi/4 -pi/4
19line l21 18 7 0 1 1 0
20line l22 18 7 0 1 -1 0
21line l31 28.5 5 0 1 1 0
22line l32 28.5 5 0 1 -1 0
23trim l21 l21 5 7
24trim l22 l22 5 7
25trim l31 l31 3 5
26trim l32 l32 3 5
27line l1 -6 0 0 0.86602540378443864 0.5 0
28line l2 -6 1 0 1 0 0
29trim l1 l1 0 30
30trim l2 l2 0 45
31mkedge c11 c11
32mkedge c12 c12
33mkedge c21 c21
34mkedge c22 c22
35mkedge c31 c31
36mkedge c32 c32
37mkedge l21 l21
38mkedge l22 l22
39mkedge l31 l31
40mkedge l32 l32
41mkedge l1 l1
42mkedge l2 l2
43wire b11 c11
44wire b12 c12
45orientation b12 R
46
47# build one ray
48plane p -6 0 0 0 0 1
49mkface f1 p b11
50add b12 f1
51wire b2 c21 l21 c22 l22
52mkface f2 p b2
53wire b3 c31 l31 c32 l32
54mkface f3 p b3
55prism f5 l1 -5 8.6602540378443864 0
56prism f4 l2 0 -1 0
57compound f1 f2 f3 bc
58bfuse r bc f4
59explode r Sh
60renamevar r_1 r
61bcut r r f5
62explode r Sh
63renamevar r_1 r
64explode r e
65wire w r_4 r_1 r_7 r_8 r_9 r_10 r_11 r_12 r_13 r_14 r_22 r_23 r_24 r_25 r_19 r_20 r_21 r_26 r_35 r_31 r_32 r_33 r_34 r_36 r_37
66tcopy w w1
67tmirror w1 -6 0 0 0 1 0
68wire w w w1
69mkface w p w
70donly w
71
72# construct complete snowflake
73tcopy w w1
74tcopy w w2
75tcopy w w3
76tcopy w w4
77tcopy w w5
78trotate w1 -6 0 0 0 0 1 60
79trotate w2 -6 0 0 0 0 1 120
80trotate w3 -6 0 0 0 0 1 180
81trotate w4 -6 0 0 0 0 1 240
82trotate w5 -6 0 0 0 0 1 300
83bfuse w w w1
84bfuse w w w2
85bfuse w w w3
86bfuse w w w4
87bfuse w w w5
88unifysamedom r w
89
90# keep only wires in compound
91eval compound [explode r w] snowflake
92tscale snowflake -6 0 0 1.5
93
94# draw frame loosely following GOST 2.104-68
95polyline frame -100 -100 0 172 -100 0 172 100 0 -100 100 0 -100 -100 0
96polyline t1 52 -100 0 52 -45 0 172 -45 0
97polyline t2 52 -60 0 172 -60 0
98polyline t3 52 -85 0 172 -85 0
99polyline t4 122 -100 0 122 -60 0
100polyline t5 122 -80 0 172 -80 0
101polyline t6 122 -65 0 172 -65 0
102polyline t7 142 -80 0 142 -85 0
103polyline t8 137 -80 0 137 -60 0
104polyline t9 154 -80 0 154 -60 0
105compound frame t1 t2 t3 t4 t5 t6 t7 t8 t9 lines
106
107# add text
108text2brep sample "SAMPLE" Arial 10 x=90 y=-55 bolditalic
109text2brep occ "Open CASCADE" Times 6 x=125 y=-95
110text2brep name "Snowflake" Courier 7 x=65 y=-75 italic
111text2brep material "Ice" Courier 7 x=75 y=-95 italic
112text2brep sheets "Sheets 1" Courier 3.5 x=145 y=-83 italic
113text2brep scale "Scale\n\n1:100" Courier 3.5 x=157 y=-63 italic
114text2brep mass "Mass\n\n1 mg" Courier 3.5 x=140 y=-63 italic
115eval compound [explode sample w] sample
116eval compound [explode occ w] occ
117eval compound [explode name w] name
118eval compound [explode material w] material
119eval compound [explode sheets w] sheets
120eval compound [explode scale w] scale
121eval compound [explode mass w] mass
122compound sample occ name material sheets scale mass text
123
124compound snowflake frame text drawing
125
126# display in 3d view
127vinit Driver1/Viewer1/View1 w=1024 h=768
128vdisplay snowflake lines text
129vtop
130vfit