-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMyr-CutBeam.mcr
223 lines (174 loc) · 4.82 KB
/
Myr-CutBeam.mcr
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
#Version 8
#BeginDescription
Last modified by: Alberto Jena (aj@hsb-cad.com)
23.02.2009 - version 1.00
#End
#Type O
#NumBeamsReq 0
#NumPointsGrip 0
#DxaOut 1
#ImplInsert 1
#FileState 1
#MajorVersion 1
#MinorVersion 0
#KeyWords
#BeginContents
/// <summary Lang=en>
/// Create areas to apply sheeting distribution.
/// </summary>
/// <insert>
/// Select a set of elements
/// </insert>
/// <remark Lang=en>
/// .
/// </remark>
/// <version value="1.00" date="23 February 2009"></version>
/// <history>
/// AJ - 1.00 - 23.02.2009 - Pilot version
/// </history>
//Script uses mm
Unit (1,"mm");
double dEps = U(.001,"mm");
PropDouble dMaxBmLengthFront (0, U(1102.5), T("Max Length Front Panel"));
PropDouble dMaxBmLengthBack (1, U(277.5), T("Max Length Back Panel"));
String sArBmCode[]={"BRS1","None"};
String sArBmCodeBlocking[]={"BK1","None"};
double dBmMinGap=500;
if (_bOnDbCreated) setPropValuesFromCatalog(_kExecuteKey);
//Insert
if( _bOnInsert )
{
//Erase after 1 cycle
if( insertCycleCount() > 1 ){
eraseInstance();
return;
}
//Showdialog
if (_kExecuteKey=="")
showDialog();
PrEntity ssE(T("|Select one or more elements|"), ElementRoof());
if (ssE.go())
{
_Element = ssE.elementSet();
}
return;
}//End bOnInsert
Element arAllElements[0];
arAllElements =_Element;
for( int e=0;e<arAllElements.length();e++ )
{
ElementRoof el = (ElementRoof)arAllElements[e];
if( !el.bIsValid() ){
continue;
}
//CoordSys
CoordSys csEl = el.coordSys();csEl.vis();
Vector3d vxEl = csEl.vecX();
Vector3d vyEl = csEl.vecY();
Vector3d vzEl = csEl.vecZ();
_Pt0=csEl.ptOrg();
Plane plnZ (csEl.ptOrg(), vzEl);
Beam bmAll[]=el.beam();
LineSeg ls=el.segmentMinMax();
double dElLength=abs(vyEl.dotProduct(ls.ptStart()-ls.ptEnd()));
if (bmAll.length()<1)
{
eraseInstance();
return;
}
Beam bmAllBlocking[0];
Beam bmToSplit[0];
for (int i=0; i<bmAll.length(); i++)
{
if (sArBmCode.find(bmAll[i].beamCode().token(0), -1)!=-1)
bmToSplit.append(bmAll[i]);
if (sArBmCodeBlocking.find(bmAll[i].beamCode().token(0), -1)!=-1)
bmAllBlocking.append(bmAll[i]);
}
for (int i=0; i<bmToSplit.length(); i++)
{
Beam bm=bmToSplit[i];
double dLen=bm.solidLength();
if (dElLength-dLen<dBmMinGap)
{
continue;
}
PlaneProfile ppBm (csEl);
ppBm=bm.realBody().shadowProfile(plnZ);
ppBm.shrink(U(2));
LineSeg ls=ppBm.extentInDir(vyEl);
Point3d ptB=ls.ptStart();
Point3d ptT=ls.ptEnd();
if (abs(vyEl.dotProduct(csEl.ptOrg()-ptT))<abs(vyEl.dotProduct(csEl.ptOrg()-ptB)))
{
Point3d ptAux=ptT;
ptT=ptB;
ptB=ptAux;
}
ptT.vis(1);
ptB.vis(2);
//PlaneProfile ppTandB (csEl);
LineSeg lsTop(ptT-vyEl*U(dMaxBmLengthBack)-vxEl*U(10), ptT+vxEl*U(10));
PLine plTop(vzEl);
plTop.createRectangle(lsTop, vxEl, vyEl);
plTop.vis(1);
PlaneProfile ppTop(csEl);
ppTop.joinRing(plTop, FALSE);
//ppTandB.joinRing(plTop, FALSE);
LineSeg lsBottom(ptB+vyEl*U(dMaxBmLengthFront)-vxEl*U(10), ptB+vxEl*U(10));
PLine plBottom(vzEl);
plBottom.createRectangle(lsBottom, vxEl, vyEl);
plBottom.vis(2);
PlaneProfile ppBottom(csEl);
ppBottom.joinRing(plBottom, FALSE);
//ppTandB.joinRing(plBottom, FALSE);
//
Beam bmArValidBlockingTop[0];
Beam bmArValidBlockingBottom[0];
for (int j=0; j<bmAllBlocking.length(); j++)
{
Beam bmBlock=bmAllBlocking[j];
PlaneProfile ppBmBlock (csEl);
PlaneProfile ppAux (csEl);
ppBmBlock=bmBlock.realBody().shadowProfile(plnZ);
ppBmBlock.shrink(U(2));
ppAux=ppBmBlock;
ppBmBlock.intersectWith(ppTop);
ppAux.intersectWith(ppBottom);
if (ppBmBlock.area()>U(1)*U(1))
{
bmArValidBlockingTop.append(bmBlock);
bmBlock.vecX().vis(bmBlock.ptCen(), 1);
}
if (ppAux.area()>U(1)*U(1))
{
bmArValidBlockingBottom.append(bmBlock);
bmBlock.vecX().vis(bmBlock.ptCen(), 1);
}
}
bmArValidBlockingTop=bm.vecX().filterBeamsPerpendicularSort(bmArValidBlockingTop);
bmArValidBlockingBottom=bm.vecX().filterBeamsPerpendicularSort(bmArValidBlockingBottom);
if (bmArValidBlockingTop.length()<1 || bmArValidBlockingBottom.length()<1)
{
continue;
}
Beam bmTop=bmArValidBlockingTop[bmArValidBlockingTop.length()-1];
Beam bmBot=bmArValidBlockingBottom[0];
Point3d ptSplitTop=bmTop.ptCen()-bmTop.vecD(vyEl) * bmTop.dD(vyEl) * 0.5; ptSplitTop.vis(2);
Point3d ptSplitBottom=bmBot.ptCen()+bmBot.vecD(vyEl) * bmBot.dD(vyEl) * 0.5; ptSplitBottom.vis(1);
if (bm.vecX().dotProduct(ptSplitTop-ptSplitBottom)>0)
{
bm.dbSplit(ptSplitTop, ptSplitBottom);
}
else
{
bm.dbSplit(ptSplitBottom, ptSplitTop);
}
}
}
//Erase this tsl.
eraseInstance();
return;
#End
#BeginThumbnail
#End