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
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
|
'''
Created on 10-Nov-2014
@author: deepa
'''
#from OCC.Display.SimpleGui import init_display
from exampleSimpleGUI import init_display
from OCC._Quantity import Quantity_NOC_BLACK
from ISection import ISection
import numpy
from OCC.Graphic3d import Graphic3d_NOT_2D_ALUMINUM
from weld import Weld
from plate import Plate
from bolt import Bolt
from OCC.Quantity import Quantity_NOC_SADDLEBROWN, Quantity_NOC_CYAN1
from nut import Nut
from OCC.BRepAlgoAPI import BRepAlgoAPI_Fuse
from OCC.AIS import AIS_Shape
from OCC.TopAbs import TopAbs_EDGE
from OCC.TopExp import TopExp_Explorer
from OCC.TopoDS import topods, TopoDS_Shape
from utilities import osdagDisplayShape
display, start_display, add_menu, add_function_to_menu = init_display(backend_str="pyqt4")
# ISection COLUMN
origin1 = numpy.array([0, 0, 0])
uDir1 = numpy.array([1.0, 0, 0])
wDir1 = numpy.array([0.0, 0, 1.0])
t = 8.9
weldThick = 8
iSection1 = ISection(B = 83, T = 14.1, D = 250, t = 11, R1 = 12, R2 = 3.2, alpha = 98, length = 1000)
iSection1.place(origin1, uDir1, wDir1)
# ISection BEAM
uDir2 = numpy.array([0, 1.0, 0])
wDir2 = numpy.array([1.0, 0, 0.0])
d = t/2.0 + weldThick
origin2 = numpy.array([0, 0, 500]) + (d+7.55) * wDir2
iSection2 = ISection(B = 140, T = 16,D = 400,t = 8.9, R1 = 14, R2 = 7, alpha = 98,length = 400)
iSection2.place(origin2, uDir2, wDir2)
# WELD
weld = Weld(L= 300,W =iSection2.t, T = 8)
plateThickness = 10
uDir3 = numpy.array([0, 1.0, 0])
wDir3 = numpy.array([1.0, 0, 0.0])
origin3 = (iSection1.secOrigin +
iSection1.t/2.0 * iSection1.uDir +
iSection1.length/2.0 * iSection1.wDir +
iSection2.t/2.0 * (-iSection2.uDir)+
weld.W/2.0 * (-iSection2.uDir))
#origin3 = numpy.array([0, 0, 500]) + t/2.0 *wDir3 + plateThickness/2.0 * (-iSection2.uDir)
weld.place(origin3, uDir3, wDir3)
# PLATE
plate = Plate(L= weld.L,W =100, T = 10)
uDir4 = numpy.array([0, 1.0, 0])
wDir4 = numpy.array([1.0, 0, 0.0])
origin4 = weld.secOrigin + weld.T * weld.wDir
plate.place(origin4, uDir4, wDir4)
# BOLT BODY
bolt_T = 6.0
origin51 = (plate.secOrigin + (-
plate.T/2.0 - bolt_T) * plate.uDir +
plate.W/2.0 * plate.wDir)
uDir5 = plate.wDir
wDir5 = plate.uDir
## Bolt1
bolt1 = Bolt(R = 10.0,T = bolt_T, H = 35.0, r = 4.0 )
bolt1.place(origin51, uDir5, wDir5)
## Bolt2
bolt2 = Bolt(R = 10.0,T = bolt_T, H = 30.0, r = 4.0 )
origin52 = origin51 + 50 *plate.vDir
bolt2.place(origin52, uDir5, wDir5)
## Bolt3
bolt3 = Bolt(R = 10.0,T = bolt_T, H = 30.0, r = 4.0 )
origin53 = origin51 - 50*plate.vDir
bolt3.place(origin53, uDir5, wDir5)
bolt_list =[bolt1,bolt2,bolt3]
#nutbody = Nut(R = 10.0,T = 10.0, H = 6.1, innerR1 = 6.0, outerR2 = 8.3)
# NUTBODY
## Nut1
nut1 = Nut(R = 10.0,T = 10.0, H = 6.1, innerR1 = 6.0, outerR2 = 8.3)
uDir = uDir5
wDir = wDir5
nut_Origin1 = origin51 + (bolt1.T/2 * plate.uDir)+(plate.T *plate.uDir)+ (iSection2.T/2 * plate.uDir)
nut1.place(nut_Origin1, uDir, wDir)
## Nut2
nut2 = Nut(R = 10.0,T = 10.0, H = 6.1, innerR1 = 6.0, outerR2 = 8.3)
nut_Origin2 = origin52 + (bolt1.T/2 * plate.uDir)+(plate.T *plate.uDir)+ (iSection2.T/2 * plate.uDir)
nut2.place(nut_Origin2, uDir, wDir)
## Nut3
nut3 =Nut(R = 10.0,T = 10.0, H = 6.1, innerR1 = 6.0, outerR2 = 8.3)
nut_Origin3 = origin53 + (bolt1.T/2 * plate.uDir)+(plate.T *plate.uDir)+ (iSection2.T/2 * plate.uDir)
nut3.place(nut_Origin3, uDir5, wDir5)
nut_list = [nut1,nut2,nut3]
def colorTheEdges(box, aDisplay):
#ais_shape = AIS.AIS_Shape(box).GetHandle()
Ex = TopExp_Explorer(box,TopAbs_EDGE)
while Ex.More():
aEdge = topods.Edge(Ex.Current())
ais_shape = AIS_Shape(aEdge).GetHandle()
ctx = aDisplay.Context
ctx.SetColor(ais_shape,Quantity_NOC_BLACK,True)
ctx.SetWidth(ais_shape,3.2)
ctx.Display(ais_shape)
Ex.Next()
ctx.Display(ais_shape)
# Call for createModel
iSectionModel1 = iSection1.createModel()
iSectionModel2 = iSection2.createModel()
weldModel = weld.createModel()
plateModel = plate.createModel()
boltModels = []
colorbolts = []
for bolt in bolt_list:
boltModels.append(bolt.createModel())
for colorbolt in boltModels:
colorTheEdges(colorbolt,aDisplay)
colorbolts.append(colorbolt)
#color = Quantity_NOC_SADDLEBROWN,
nutModels = []
for nut in nut_list:
nutModels.append(nut.createModel())
# def colorTheEdges(box, aDisplay):
# #ais_shape = AIS.AIS_Shape(box).GetHandle()
# Ex = TopExp_Explorer(box,TopAbs_EDGE)
#
# while Ex.More():
# aEdge = topods.Edge(Ex.Current())
# ais_shape = AIS_Shape(aEdge).GetHandle()
# ctx = aDisplay.Context
# ctx.SetColor(ais_shape,Quantity_NOC_BLACK,True)
# ctx.SetWidth(ais_shape,3.2)
# ctx.Display(ais_shape)
# Ex.Next()
#
# Get Context
#
ais_context = display.GetContext().GetObject()
#
# Get Prs3d_drawer from previous context
#
drawer_handle = ais_context.DefaultDrawer()
drawer = drawer_handle.GetObject()
drawer.SetIsoOnPlane(True)
#
la = drawer.LineAspect().GetObject()
la.SetWidth(4)
# le = drawer.SetLineAspect().GetObject()
hla = drawer.HiddenLineAspect().GetObject()
hla.SetWidth(2)
hla.SetColor(Quantity_NOC_CYAN1)
# le.SetLineAspect(Aspect_TOL_DASH,Quantity_NOC_YELLOW,4 )
# increase line width in the current viewer
# This is only viewed in the HLR mode (hit 'e' key for instance)
line_aspect = drawer.SeenLineAspect().GetObject()
drawer.EnableDrawHiddenLine()
line_aspect.SetWidth(4)
#drawer.SetLineAspect('Aspect_TOL_DASH')
#
drawer.SetWireAspect(line_aspect.GetHandle())
# Displys CAD Models.
# Complete CAD Model
isection = BRepAlgoAPI_Fuse(iSectionModel1,iSectionModel2).Shape()
weld_isection = BRepAlgoAPI_Fuse(isection,weldModel).Shape()
plate_weld = BRepAlgoAPI_Fuse(weld_isection,plateModel).Shape()
plate_weld_bolt = plate_weld
for bolt in boltModels:
plate_weld_bolt = BRepAlgoAPI_Fuse(plate_weld_bolt, bolt).Shape()
#bolt_plate = BRepAlgoAPI_Fuse(plate_weld,boltModels).Shape()
final_model = plate_weld_bolt
for nt in nutModels:
final_model = BRepAlgoAPI_Fuse(final_model,nt).Shape()
# colorTheEdges(final_model)
#display.DisplayShape(final_model, update = True)
colorTheEdges(iSectionModel1, display)
display.DisplayShape(iSectionModel1, update=True)
#
# colorTheEdges(iSectionModel2)
#display.DisplayShape(iSectionModel2,material = Graphic3d_NOT_2D_ALUMINUM, update=True)
#
# colorTheEdges(weldModel)
#display.DisplayShape(weldModel,color = 'red', update=True)
#
# colorTheEdges(plateModel)
#display.DisplayShape(plateModel,color = 'blue', update=True)
#
#colorTheEdges(boltModels)
#display.DisplayShape(colorbolts,color = Quantity_NOC_SADDLEBROWN, update=True)
#
# #colorTheEdges(nutModels)
#display.DisplayShape(nutModels,color = Quantity_NOC_SADDLEBROWN, update = True)
#display.SetModeHLR()
display.FitAll()
#display.View_Front()
#display.View_Top()
#display.View_Right()
#display.View_Iso()
#display.FitAll()
start_display()
|