-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMyr-202.mcr
1483 lines (1259 loc) · 43.5 KB
/
Myr-202.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
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#Version 8
#BeginDescription
Last modified by: Myresjohus
1.17 - 18.09.2019 - Look in MapX for Door/Window
#End
#Type O
#NumBeamsReq 0
#NumPointsGrip 0
#DxaOut 1
#ImplInsert 1
#FileState 1
#MajorVersion 1
#MinorVersion 17
#KeyWords
#BeginContents
/// <summary Lang=en>
/// takse care of the dimension in the 202/206 layout
/// </summary>
/// <insert>
/// Select a set of elements
/// </insert>
/// <remark Lang=en>
///
/// </remark>
/// <version value="1.17" date="18.09.2019"></version>
/// <history>
/// 0.01 - 17.04.2009 - Pilot version
/// 1.00 - 27.11.2008 - Rewrite the tsl
/// 1.01 - 27.11.2008 - Implement joining of SY beams; Recognize openings
/// 1.02 - 28.11.2008 - Outside dimension lines implemented
/// 1.03 - 28.11.2008 - Length of sylls added
/// 1.04 - 01.12.2008 - Add dimension for T-Connection
/// 1.05 - 02.12.2008 - Add dimension line for openings and diagonals
/// 1.06 - 04.12.2008 - Store state in dwg
/// 1.07 - 10.12.2008 - Extra catalog added for diagonal dimension lines
/// 1.08 - 09.02.2009 - Openings from same element on same dimline
/// 1.09 - 09.02.2009 - Extra properties added for 206 layout; Floor information taken from 205 layout
/// 1.10 - 14.07.2009 - Set the readdirection the same for all dimension lines
/// Update text at end and middle of the single dimline after the default values are set.
/// 1.11 - 15.07.2009 - Add a check for the 205 layout. 205 needs to be present in the floorgroup for the slabs
/// 1.12 - 02.10.2009 - Remove dimension of floorplan.
/// 1.13 - 02.10.2009 - Reload SY beams after joining
/// 1.14 - 02.10.2009 - Add colors for text as a property
/// 1.15 - 07.10.2011 - Change to P544
/// 1.16 - 22.05.2019 - Added representation for loadbearing walls and posts
/// 1.17 - 18.09.2019 - Look in MapX for Door/Window
/// </hsitory>
double dEps = U(.1,"mm");
//Outer walls
String arSCodeOuterWalls[]={
"CA",
"CC",
"CF",
"CL",
"CP",
"CT",
"Add codes for outer walls here"
};
//BeamCodes to use
String arSBmCodeSY[] = {
"SY"
};
String sLineType = "DASHED";
String arSBeamCodesToDisplay[] = {
"BP-BI",
"Stolpe"
};
//Floorgroup to dimension
String arSNameFloorGroup[0];
Group arFloorGroup[0];
Group arAllGroups[] = Group().allExistingGroups();
for( int i=0;i<arAllGroups.length();i++ ){
Group grp = arAllGroups[i];
if( grp.namePart(2) == "" && grp.namePart(1) != ""){
arSNameFloorGroup.append(grp.name());
arFloorGroup.append(grp);
}
}
PropString sNameFloorGroup(0, arSNameFloorGroup, T("|Floorgroup|"));
//Offset outside dimlines
PropDouble dOffsetOutside(0, U(1000), T("|Offset outside dimensionlines|"));
//Offset T-connection dimlines
PropDouble dOffsetTConnection(1, U(200), T("|Offset T-Connection dimensionlines|"));
//Offset opening dimlines
PropDouble dOffsetOpening(2, U(500), T("|Offset opening dimensionlines|"));
//Offset outside dimlines
PropDouble dOffsetText(3, U(200), T("|Offset text|"));
//Reference points for diagonal dimenioning
String arSReferenceDiagonal[] = {
T("|Top-left|"),
T("|Left-top|"),
T("|Left-Bottom|"),
T("|Bottom-left|"),
T("|Bottom-right|"),
T("|Right-bottom|"),
T("|Right-top|"),
T("|Top-right|")
};
PropString sReferenceDiagonal(1, arSReferenceDiagonal, T("|Reference point diagonal dimensioning|"));
//Available catalog entries for the dimension line
String arSCatalogEntries[] = TslInst().getListOfCatalogNames("Myr-DimensionLine");
//Catalog key outside dimlines
PropString sCatalogKeyOutside(2, arSCatalogEntries, T("|Catalog key for outside dimension lines|"));
//Catalog key diagonal dimlines
PropString sCatalogKeyDialog(3, arSCatalogEntries, T("|Catalog key for diagonal dimension lines|"));
//Show in display representation
PropString sShowInDispRep(4, _ThisInst.dispRepNames() , T("|Show in display representation|"));
//With dimension style
PropString sDimStyle(5, _DimStyles, T("|Dimension style|"));
//Show as a 206 layout (borders taken from slabs below)
String arSYesNo[] = {T("|Yes|"), T("|No|")};
int arNYesNo[] = {_kYes, _kNo};
PropString sShowAs206Layout(6, arSYesNo, T("|Show as 206 layout|"),1);
int bShowAs206Layout = arNYesNo[arSYesNo.find(sShowAs206Layout,1)];
//Floorgroup with slabs for 206 layout
PropString sFloorGroupFor206(7, arSNameFloorGroup, T("|Group with slabs for this 206|"));
//Offset floorplan dimlines
PropDouble dOffsetFloorPlan(4, U(1300), T("|Offset floor dimensionlines|"));
// color text
PropInt nColorText(0, 1, T("|Color text|"));
//Maximum distance between beams
double dMaximumJoiningDistance = U(5);
//Maximum distance to T-connection
double dMaximumDistanceToTConnection = U(500);
//Show or hide dimlines
int bOutsideLeft = TRUE;
int bOutsideRight = TRUE;
int bOutsideBottom = TRUE;
int bOutsideTop = TRUE;
int bFloorPlanLeft = FALSE;
int bFloorPlanRight = FALSE;
int bFloorPlanBottom = FALSE;
int bFloorPlanTop = FALSE;
//Insert
if( _bOnInsert ){
if( insertCycleCount() > 1 ){
eraseInstance();
return;
}
_Pt0 = getPoint(T("|Select a point|"));
showDialog();
return;
}
int nColorBeam =1;
Display dpBeam(nColorBeam);
dpBeam.lineType(sLineType, 0.002);
dpBeam.showInDispRep(sShowInDispRep);
//CoordSys of world
CoordSys csWorld(_PtW, _XW, _YW, _ZW);
Vector3d vx = _XW;
Vector3d vy = _YW;
Vector3d vz = _ZW;
Plane pnZ(_Pt0, vz);
//visualize _Pt0
Display dp(nColorText);
dp.dimStyle(sDimStyle);
dp.showInDispRep(sShowInDispRep);
Display dpFloorPlan(-1);
dpFloorPlan.dimStyle(sDimStyle);
dpFloorPlan.showInDispRep(sShowInDispRep);
dpFloorPlan.lineType("DASHED2");
//Lines used to sort points and calculate extreme vertices
Line lnX(_Pt0, vx);
Line lnY(_Pt0, vy);
//FloorGroup
Group grpFloor = arFloorGroup[arSNameFloorGroup.find(sNameFloorGroup)];
grpFloor.addEntity(_ThisInst, TRUE, 0, 'D');
//FloorGroup Slabs for 206 layout
Group grpFloor206 = arFloorGroup[arSNameFloorGroup.find(sFloorGroupFor206)];
//Find the corrseponding floorGroupLayout tsl
TslInst tsl205;
int tsl205Found = FALSE;
PLine plOutlineFloor(_ZW);
if( bShowAs206Layout ){
Entity arEntTsl[] = grpFloor206.collectEntities(TRUE, TslInst(), _kModelSpace);
for( int i=0;i<arEntTsl.length();i++ ){
TslInst tsl = (TslInst)arEntTsl[i];
if( tsl.scriptName() == "Myr-205" ){
tsl205 = tsl;
tsl205Found = TRUE;
break;
}
}
if( !tsl205Found ){
reportWarning(
TN("|Cannot find Myr-205 in the group with the slabs for this layout (|")+grpFloor206.name()+")!"+
TN("This tsl needs to be applied first, or the right group with slabs needs to be selected in the Myr-202 tsl!|")
);
dp.draw(scriptName(), _Pt0, _XW, _YW, 0, 0);
return;
}
plOutlineFloor = tsl205.map().getPLine("FLOOR");
bFloorPlanLeft = TRUE;
bFloorPlanRight = TRUE;
bFloorPlanBottom = TRUE;
bFloorPlanTop = TRUE;
dpFloorPlan.draw(plOutlineFloor);
}
//TSL arguments
String strScriptName = "Myr-DimensionLine"; // name of the script
Vector3d vecUcsX(1,0,0);
Vector3d vecUcsY(0,1,0);
Beam lstBeams[0];
Element lstElements[0];
Point3d lstPoints[0];
int lstPropInt[0];
double lstPropDouble[0];
String lstPropString[0];
//Collect all beams
Entity arEntBm[] = grpFloor.collectEntities(TRUE, Beam(), _kModelSpace);
//Filter the SY beams
Beam arBmSY[0];
for( int i=0;i<arEntBm.length();i++ ){
Beam bm = (Beam)arEntBm[i];
if( !bm.bIsValid() )continue;
//get beamcode...
String sBmCode = bm.name("beamCode").token(0);
sBmCode = sBmCode.trimLeft(); sBmCode = sBmCode.trimRight();
//...and check if its a SY-beam
if( arSBmCodeSY.find(sBmCode) != -1 ){
//Add it to the array of SY-beams
arBmSY.append(bm);
} else if( arSBeamCodesToDisplay.find(sBmCode) != -1 ){
PlaneProfile ppBm = bm.envelopeBody().shadowProfile(pnZ);
dpBeam.draw(ppBm);
//Draw infromation
Vector3d vxText = bm.vecX();
Vector3d vOffset = vz.crossProduct(bm.vecX());
if( vOffset.dotProduct(_XW+_YW) < 0 ){
vxText = -vxText;
vOffset = -vOffset;
}
dpBeam.draw(bm.information(), bm.ptCen() + vOffset * U(50), vxText, vOffset, 0, 1);
}
}
//Join SY-beams
for( int i=0;i<arBmSY.length();i++ ){
Beam bmSY = arBmSY[i];
//Check if its a valid beam
if( !bmSY.bIsValid() )continue;
//Extreme points of this beam
Point3d ptBmSYMin = bmSY.ptRef() + bmSY.vecX() * bmSY.dLMin();
Point3d ptBmSYMax = bmSY.ptRef() + bmSY.vecX() * bmSY.dLMax();
//Filter all beams not this
Beam arBmNotThisSY[] = bmSY.filterGenBeamsNotThis(arBmSY);
for( int j=0;j<arBmNotThisSY.length();j++ ){
Beam bmNotThisSY = arBmNotThisSY[j];
//Check if its a valid beam
if( !bmNotThisSY.bIsValid() )continue;
//Beams must be in same direction...
if( !bmSY.vecX().isParallelTo(bmNotThisSY.vecX()) )continue;
//...and in line with each other
if( bmSY.vecX().dotProduct(bmSY.ptCen() - bmNotThisSY.ptCen()) > 0 )continue;
//Extreme points of this beam
Point3d ptBmNotThisSYMin = bmNotThisSY.ptRef() + bmNotThisSY.vecX() * bmNotThisSY.dLMin();
Point3d ptBmNotThisSYMax = bmNotThisSY.ptRef() + bmNotThisSY.vecX() * bmNotThisSY.dLMax();
//Check the distances between
if(
(ptBmSYMin - ptBmNotThisSYMin).length() < dMaximumJoiningDistance ||
(ptBmSYMin - ptBmNotThisSYMax).length() < dMaximumJoiningDistance ||
(ptBmSYMax - ptBmNotThisSYMin).length() < dMaximumJoiningDistance ||
(ptBmSYMax - ptBmNotThisSYMax).length() < dMaximumJoiningDistance
){
//Join beams - bmNotThisSY becomes invalid
bmSY.dbJoin(bmNotThisSY);
i--;
break;
}
}
}
//Collect all beams
arEntBm = grpFloor.collectEntities(TRUE, Beam(), _kModelSpace);
arBmSY.setLength(0);
for( int i=0;i<arEntBm.length();i++ ){
Beam bm = (Beam)arEntBm[i];
if( !bm.bIsValid() )continue;
//get beamcode...
String sBmCode = bm.name("beamCode").token(0);
sBmCode = sBmCode.trimLeft(); sBmCode = sBmCode.trimRight();
//...and check if its a SY-beam
if( arSBmCodeSY.find(sBmCode) != -1 ){
//Add it to the array of SY-beams
arBmSY.append(bm);
}
}
//Plane for SY beams
Plane pnSY;
//Create a planeProfile of all SY beams
PlaneProfile ppSY(csWorld);
for( int i=0;i<arBmSY.length();i++ ){
Beam bmSY = arBmSY[i];
//Check if its a valid beam
if( !bmSY.bIsValid() )continue;
//Create plane
pnSY = Plane(bmSY.ptCen(), _ZW);
//Add beams to floorgroup
grpFloor.addEntity(bmSY, TRUE, 0, 'Z');
//Create plane profile
ppSY.unionWith(bmSY.realBody().shadowProfile(Plane(_Pt0, vz)));
}
//Collect all openings
Entity arEntOp[] = grpFloor.collectEntities(TRUE, Opening(), _kModelSpace);
//Opening in outside walls
OpeningSF arOp[0];
//Filter the SY beams
for( int i=0;i<arEntOp.length();i++ ){
OpeningSF op = (OpeningSF)arEntOp[i];
if( !op.bIsValid() )continue;
//Check if its a door
Map revitIDMap = op.subMapX("REVITID");
String sOpeningType = revitIDMap.getString("Category");
//String sOpeningType = op.type().token(0);
if( sOpeningType.makeUpper() != "DOORS" )continue;
//get the element of the opening and check if its an outer wall
Element el = op.element();
if( arSCodeOuterWalls.find(el.code()) != -1 ){
Body bdOp = Body(op.plShape(), el.vecZ() * el.zone(0).dH(), 0);
//bdOp.vis();
ppSY.unionWith(bdOp.shadowProfile(Plane(_Pt0, vz)));
//Add to list of openings
arOp.append(op);
}
}
ppSY.vis();
//Create describing planeprofile from house
PlaneProfile ppHouse(csWorld);
ppHouse.unionWith(ppSY);
ppHouse.shrink(-U(250));
//ppHouse.vis(1);
PLine arPlHouse[] = ppHouse.allRings();
int arPlHouseIsOpening[] = ppHouse.ringIsOpening();
if( arPlHouse.length() > 0 )ppHouse = PlaneProfile(arPlHouse[0]);
ppHouse.shrink(U(255));
ppHouse.vis(3);
//Points for diagonal lines
Point3d arPtPossibleDiagonal[0];
//Points for dimlines outside elements (UTV. SYLL =)
Point3d arPtOutsideLeft[0];
Point3d arPtOutsideRight[0];
Point3d arPtOutsideTop[0];
Point3d arPtOutsideBottom[0];
//Points for dimlines floorplan (UTV. KASSETT =)
Point3d arPtFloorPlanLeft[0];
Point3d arPtFloorPlanRight[0];
Point3d arPtFloorPlanTop[0];
Point3d arPtFloorPlanBottom[0];
//Points used to calculate extreme vertices
Point3d arPtAllVertices[0];
for( int i=0;i<arBmSY.length();i++ ){
Beam bmSY = arBmSY[i];
//Check if its a valid beam
if( !bmSY.bIsValid() )continue;
//Show beam on debug
if( _bOnDebug ){
bmSY.realBody().vis();
}
//Add points of bm.realBody to list of all points.. calculate extremes with these points
arPtAllVertices.append(bmSY.realBody().allVertices());
//CoordSys
CoordSys csBm = bmSY.coordSys();
Vector3d vxBm = csBm.vecX();
//Line used to find possible T-Connections
Line lnBmX(bmSY.ptCen(), vxBm);
//Vector pointing outside
Vector3d vOutside = vz.crossProduct(vxBm);
if( vOutside.dotProduct(bmSY.ptCen() - _Pt0) < 0 ){
vOutside = -vOutside;
}
//Point that should be dimensioned in one or two of the dimension lines
Point3d ptOutside = bmSY.ptCen() + vOutside * .5 * bmSY.dD(vOutside);
//Check ptOutside again
if( ppHouse.pointInProfile(ptOutside) == _kPointInProfile ){
vOutside = -vOutside;
ptOutside = bmSY.ptCen() + vOutside * .5 * bmSY.dD(vOutside);
}
//Extreme points of this beam
Point3d ptBmSYMin = bmSY.ptRef() + vxBm * bmSY.dLMin();
Point3d ptBmSYMax = bmSY.ptRef() + vxBm * bmSY.dLMax();
Point3d arPtBmSYExtreme[] = {ptBmSYMin, ptBmSYMax};
//Add ptOutside to the right dimension line(s)
if( abs(vxBm.dotProduct(vx)) > U(.9) ){
//Horizontal wall
if( bShowAs206Layout ){
if( vy.dotProduct(bmSY.ptCen() - _Pt0) > 0 ){
arPtOutsideTop.append(arPtBmSYExtreme);
}
else{
arPtOutsideBottom.append(arPtBmSYExtreme);
}
}
else{
//Check if the beam should be dimensioned left and right...
if( (vx.dotProduct(_Pt0 - ptBmSYMin) * vx.dotProduct(_Pt0 - ptBmSYMax)) < 0 ){
arPtOutsideLeft.append(ptOutside);
arPtOutsideRight.append(ptOutside);
}
else{
//...or only on the left
if( vx.dotProduct(_Pt0 - ptBmSYMin) > 0 ){
arPtOutsideLeft.append(ptOutside);
}
else{//...or only on the right
arPtOutsideRight.append(ptOutside);
}
}
}
}
else if( abs(vxBm.dotProduct(vy)) > U(.9) ){
//Vertical wall
if( bShowAs206Layout ){
if( vx.dotProduct(bmSY.ptCen() - _Pt0) > 0 ){
arPtOutsideRight.append(arPtBmSYExtreme);
}
else{
arPtOutsideLeft.append(arPtBmSYExtreme);
}
}
else{
//Check if the beam should be dimensioned bottom and top...
if( (vy.dotProduct(_Pt0 - ptBmSYMin) * vy.dotProduct(_Pt0 - ptBmSYMax)) < 0 ){
arPtOutsideBottom.append(ptOutside);
arPtOutsideTop.append(ptOutside);
}
else{
//...or only on the bottom
if( vy.dotProduct(_Pt0 - ptBmSYMin) > 0 ){
arPtOutsideBottom.append(ptOutside);
}
else{//...or only on the top
arPtOutsideTop.append(ptOutside);
}
}
}
}
//Dimension points for wall-to-wall connections
Beam arBmPossibleT[] = bmSY.filterBeamsTConnection(arBmSY, dMaximumDistanceToTConnection, TRUE);
int nIndex = -1;
for( int j=-1;j<2;j+=2 ){
Vector3d vT = j * vxBm;
nIndex++;
Point3d ptBmSYExtreme = arPtBmSYExtreme[nIndex];
Beam arBmT[] = bmSY.filterBeamsHalfLineIntersectSort(arBmPossibleT, bmSY.ptCen(), vT);
//Check if there are T-Connections on this side
if( arBmT.length() == 0 ) continue;
//Closest beam with possible T-Connection
Beam bmT = arBmT[0];
bmT.realBody().vis();
//Find intersection point.
Point3d ptT = lnBmX.intersect(Plane(bmT.ptCen(), bmT.vecD(vT)), -.5 * bmT.dD(vT));
ptT.vis(1);
//Points to dimension
Point3d arPtTConnection[2];
arPtTConnection[0] = ptT;
//Check if its a valid point
if( abs(vxBm.dotProduct(ptT - ptBmSYExtreme)) < dMaximumDistanceToTConnection ){
arPtTConnection[1] = ptBmSYExtreme;
if( !bShowAs206Layout )
arPtPossibleDiagonal.append(lnBmX.intersect(Plane(bmT.ptCen(), bmT.vecD(vT)), .5 * bmT.dD(vT)) + vOutside * .5 * bmSY.dD(vOutside));
double dOffset = dOffsetTConnection;
int bRecalcRequested = TRUE;
String sDimensionKey = "WallToWall-"+bmSY.handle()+"-"+j;
if( _Map.hasEntity(sDimensionKey) ){
Entity ent = _Map.getEntity(sDimensionKey);
TslInst tsl = (TslInst)ent;
if( tsl.bIsValid() ){
Map mapTsl = tsl.map();
int nExecutionMode = mapTsl.getInt("ExecutionMode");
if( nExecutionMode != 2 ){//not equal to request recalc
bRecalcRequested = FALSE;
}
else{
ent.dbErase();
_Map.removeAt(sDimensionKey, TRUE);
}
}
else{
_Map.removeAt(sDimensionKey, TRUE);
}
}
if( bRecalcRequested ){
Line ln(ptOutside, vT);
arPtTConnection = ln.projectPoints(arPtTConnection);
arPtTConnection = ln.orderPoints(arPtTConnection);
Point3d ptOrigin = arPtTConnection[0] + vOutside * dOffset - vT * U(100);
Vector3d vyDim = -vOutside;
if( vyDim.dotProduct(_YW - _XW) < 0 )
vyDim = vOutside;
Vector3d vxDim = vyDim.crossProduct(_ZW);
Map mapDim;
mapDim.setInt("ExecutionMode", 0);
mapDim.setEntity("Parent", _ThisInst);
mapDim.setVector3d("vxDim", vxDim);
mapDim.setVector3d("vyDim", vyDim);
mapDim.setPoint3d("Pt0", ptOrigin, _kAbsolute);
lstPoints.setLength(0);
lstPoints.append(ptOrigin);
lstPoints.append(arPtTConnection);
TslInst tsl;
tsl.dbCreate(strScriptName, vecUcsX,vecUcsY,lstBeams, lstElements, lstPoints, lstPropInt, lstPropDouble, lstPropString, _kModelSpace, mapDim ); // create new instance
int nValuesSet = tsl.setPropValuesFromCatalog(sCatalogKeyOutside);
tsl.setPropString(T("|Floorgroup|"), sNameFloorGroup);
tsl.setPropString(T("|Text at middle of dimension line|"), "<>");
tsl.setPropString(T("|Text at end of dimension line|"), "<>");
if( nValuesSet )tsl.transformBy(_XW*0);
grpFloor.addEntity(tsl, TRUE, 0, 'D');
_Map.setEntity(sDimensionKey, tsl);
}
}
}
}
if( arPtOutsideLeft.length() == 0 )
bOutsideLeft = FALSE;
if( arPtOutsideBottom.length() == 0 )
bOutsideBottom = FALSE;
if( arPtOutsideRight.length() == 0 )
bOutsideRight = FALSE;
if( arPtOutsideTop.length() == 0 )
bOutsideTop = FALSE;
//Diagonal dimension line
if( bShowAs206Layout ){
arPtPossibleDiagonal.append(plOutlineFloor.vertexPoints(TRUE));
PlaneProfile ppFloorPlan(csWorld);
ppFloorPlan.joinRing(plOutlineFloor, _kAdd);
Point3d arPtFloor[] = plOutlineFloor.vertexPoints(FALSE);
for( int i=0;i<(arPtFloor.length() - 1);i++ ){
Point3d ptThis = arPtFloor[i];
Point3d ptNext = arPtFloor[i+1];
LineSeg lnSeg(ptThis, ptNext);
Point3d ptLnSegMid = lnSeg.ptMid();
Point3d ptL = ptLnSegMid - vx * U(1);
Point3d ptB = ptLnSegMid - vy * U(1);
Point3d ptR = ptLnSegMid + vx * U(1);
Point3d ptT = ptLnSegMid + vy * U(1);
if( ppFloorPlan.pointInProfile(ptL) == _kPointOutsideProfile ){
//Left
arPtFloorPlanLeft.append(ptThis);
arPtFloorPlanLeft.append(ptNext);
}
if( ppFloorPlan.pointInProfile(ptB) == _kPointOutsideProfile ){
//Bottom
arPtFloorPlanBottom.append(ptThis);
arPtFloorPlanBottom.append(ptNext);
}
if( ppFloorPlan.pointInProfile(ptR) == _kPointOutsideProfile ){
//Right
arPtFloorPlanRight.append(ptThis);
arPtFloorPlanRight.append(ptNext);
}
if( ppFloorPlan.pointInProfile(ptT) == _kPointOutsideProfile ){
//Top
arPtFloorPlanTop.append(ptThis);
arPtFloorPlanTop.append(ptNext);
}
}
}
Point3d ptPrev;
//Ordered points
Point3d arPtPossibleDiagonalX[] = lnX.orderPoints(arPtPossibleDiagonal);
Point3d arPtPossibleDiagonalY[] = lnY.orderPoints(arPtPossibleDiagonal);
//Left
Point3d ptLT;
Point3d ptLB;
ptPrev = arPtPossibleDiagonalX[0];
Point3d arPtL[] = {ptPrev};
for( int i=1;i<arPtPossibleDiagonalX.length();i++ ){
Point3d ptThis = arPtPossibleDiagonalX[i];
if( abs(_XW.dotProduct(ptThis - ptPrev)) > dEps ){
Point3d arPtLY[] = lnY.orderPoints(arPtL);
ptLB = arPtLY[0];
ptLT = arPtLY[arPtLY.length() - 1];
break;
}
else{
arPtL.append(ptThis);
}
}
//Bottom
Point3d ptBL;
Point3d ptBR;
ptPrev = arPtPossibleDiagonalY[0];
Point3d arPtB[] = {ptPrev};
for( int i=1;i<arPtPossibleDiagonalY.length();i++ ){
Point3d ptThis = arPtPossibleDiagonalY[i];
if( abs(_YW.dotProduct(ptThis - ptPrev)) > dEps ){
Point3d arPtBX[] = lnX.orderPoints(arPtB);
ptBL = arPtBX[0];
ptBR = arPtBX[arPtBX.length() - 1];
break;
}
else{
arPtB.append(ptThis);
}
}
//Right
Point3d ptRT;
Point3d ptRB;
ptPrev = arPtPossibleDiagonalX[arPtPossibleDiagonalX.length() - 1];
Point3d arPtR[] = {ptPrev};
for( int i=(arPtPossibleDiagonalX.length() - 2);i>-1;i-- ){
Point3d ptThis = arPtPossibleDiagonalX[i];
if( abs(_XW.dotProduct(ptThis - ptPrev)) > dEps ){
Point3d arPtRY[] = lnY.orderPoints(arPtR);
ptRB = arPtRY[0];
ptRT = arPtRY[arPtRY.length() - 1];
break;
}
else{
arPtR.append(ptThis);
}
}
//Top
Point3d ptTL;
Point3d ptTR;
ptPrev = arPtPossibleDiagonalY[arPtPossibleDiagonalY.length() - 1];
Point3d arPtT[] = {ptPrev};
for( int i=(arPtPossibleDiagonalY.length() - 2);i>-1;i-- ){
Point3d ptThis = arPtPossibleDiagonalY[i];
if( abs(_YW.dotProduct(ptThis - ptPrev)) > dEps ){
Point3d arPtTX[] = lnX.orderPoints(arPtT);
ptTL = arPtTX[0];
ptTR = arPtTX[arPtTX.length() - 1];
break;
}
else{
arPtT.append(ptThis);
}
}
//Dimension points
Point3d arPtDimReferenceDiagonal[0]; Point3d arPtDimDiagonal01[0]; Point3d arPtDimDiagonal02[0]; Vector3d arVReadDirection[0];
arPtDimReferenceDiagonal.append(ptTL); arPtDimDiagonal01.append(ptBR); arPtDimDiagonal02.append(ptRB); arVReadDirection.append(_XW + _YW);
arPtDimReferenceDiagonal.append(ptLT); arPtDimDiagonal01.append(ptBR); arPtDimDiagonal02.append(ptRB); arVReadDirection.append(_XW + _YW);
arPtDimReferenceDiagonal.append(ptLB); arPtDimDiagonal01.append(ptTR); arPtDimDiagonal02.append(ptRT); arVReadDirection.append(-_XW + _YW);
arPtDimReferenceDiagonal.append(ptBL); arPtDimDiagonal01.append(ptTR); arPtDimDiagonal02.append(ptRT); arVReadDirection.append(-_XW + _YW);
arPtDimReferenceDiagonal.append(ptBR); arPtDimDiagonal01.append(ptTL); arPtDimDiagonal02.append(ptLT); arVReadDirection.append(_XW + _YW);
arPtDimReferenceDiagonal.append(ptRB); arPtDimDiagonal01.append(ptTL); arPtDimDiagonal02.append(ptLT); arVReadDirection.append(_XW + _YW);
arPtDimReferenceDiagonal.append(ptRT); arPtDimDiagonal01.append(ptBL); arPtDimDiagonal02.append(ptLB); arVReadDirection.append(-_XW + _YW);
arPtDimReferenceDiagonal.append(ptTR); arPtDimDiagonal01.append(ptBL); arPtDimDiagonal02.append(ptLB); arVReadDirection.append(-_XW + _YW);
//Diagonal dimension points
int nIndexDiagonal = arSReferenceDiagonal.find(sReferenceDiagonal);
Point3d arPtDiagonal[2];
arPtDiagonal[0] = arPtDimReferenceDiagonal[nIndexDiagonal];
Point3d arPtSecondDiagonalPoint[] = {arPtDimDiagonal01[nIndexDiagonal]};
if( (arPtDimDiagonal01[nIndexDiagonal] - arPtDimDiagonal02[nIndexDiagonal]).length() > U(5) ){
arPtSecondDiagonalPoint.append(arPtDimDiagonal02[nIndexDiagonal]);
}
Vector3d vReadDirection = arVReadDirection[nIndexDiagonal];
for( int i=0;i<arPtSecondDiagonalPoint.length();i++ ){
arPtDiagonal[1] = arPtSecondDiagonalPoint[i];
arPtDiagonal[1].vis(4);
Vector3d vxDim(arPtDiagonal[1] - arPtDiagonal[0]);
vxDim.normalize();
if( vxDim.dotProduct(-_XW+_YW) < 0 ){
// vxDim = -vxDim;
}
Vector3d vyDim = _ZW.crossProduct(vxDim);
double dOffset = U(0);
int bRecalcRequested = TRUE;
String sDimensionKey = "Diagonal-"+i;
if( _Map.hasEntity(sDimensionKey) ){
Entity ent = _Map.getEntity(sDimensionKey);
TslInst tsl = (TslInst)ent;
if( tsl.bIsValid() ){
Map mapTsl = tsl.map();
int nExecutionMode = mapTsl.getInt("ExecutionMode");
if( nExecutionMode != 2 ){//not equal to request recalc
bRecalcRequested = FALSE;
}
else{
ent.dbErase();
_Map.removeAt(sDimensionKey, TRUE);
}
}
else{
_Map.removeAt(sDimensionKey, TRUE);
}
}
if( bRecalcRequested ){
Line ln(arPtDiagonal[0], vxDim);
arPtDiagonal = ln.projectPoints(arPtDiagonal);
Point3d ptOrigin = arPtDiagonal[0] + vyDim * dOffset - vxDim * U(100);
Map mapDim;
mapDim.setInt("ExecutionMode", 0);
mapDim.setEntity("Parent", _ThisInst);
mapDim.setVector3d("vxDim", vxDim);
mapDim.setVector3d("vyDim", vyDim);
mapDim.setPoint3d("Pt0", ptOrigin, _kAbsolute);
mapDim.setVector3d("ReadDirection", vReadDirection);
lstPoints.setLength(0);
lstPoints.append(ptOrigin);
lstPoints.append(arPtDiagonal);
TslInst tsl;
tsl.dbCreate(strScriptName, vecUcsX,vecUcsY,lstBeams, lstElements, lstPoints, lstPropInt, lstPropDouble, lstPropString, _kModelSpace, mapDim ); // create new instance
int nValuesSet = tsl.setPropValuesFromCatalog(sCatalogKeyDialog);
tsl.setPropString(T("|Floorgroup|"), sNameFloorGroup);
tsl.setPropString(T("|Text at middle of dimension line|"), "DIAGONAL =<>");
tsl.setPropString(T("|Text at end of dimension line|"), "<>");
if( nValuesSet )tsl.transformBy(_XW*0);
grpFloor.addEntity(tsl, TRUE, 0, 'D');
_Map.setEntity(sDimensionKey, tsl);
}
}
//Dimension openings
for( int i=0;i<arOp.length();i++ ){
OpeningSF op = arOp[i];
//is it still valid?
if( !op.bIsValid() )continue;
Element el = op.element();
//Other openings in this element?
Body arBdOtherOpening[0];
for( int j=0;j<arOp.length();j++ ){
if( i==j )continue;
OpeningSF opOther = arOp[j];
Element elOther = opOther.element();
if( elOther.handle() == el.handle() ){
arBdOtherOpening.append(Body(opOther.plShape(), el.vecZ()));
arOp[j] = OpeningSF();
}
}
//Body opening
Body bdOp(op.plShape(), el.vecZ());
bdOp.vis(i);
Point3d ptOpCen = bdOp.ptCen();
//Point projected to SY level
Point3d ptOpSY = pnSY.closestPointTo(ptOpCen);
Line lnOpSY(ptOpSY, el.vecX());
//Possible T-Connections
Beam arBmPossibleT[0];
for( int j=0;j<arBmSY.length();j++ ){
Beam bmSY = arBmSY[j];
if( bmSY.vecX().isParallelTo(el.vecX()) )continue;
arBmPossibleT.append(bmSY);
}
//T-Connections
Beam arBmT[] = Beam().filterBeamsHalfLineIntersectSort(arBmPossibleT, ptOpSY, el.vecX());
if( arBmT.length() == 0 )continue;
Beam bmT = arBmT[0];
Vector3d vT = bmT.vecD(el.vecX());
//Reference point (outside first connecting wall)
Point3d ptReference = lnOpSY.intersect(Plane(bmT.ptCen(), vT), .5 * bmT.dD(vT));
ptReference.vis(i);
//Points to dimension
Point3d arPtOpeningDim[] = bdOp.extremeVertices(el.vecX());
for( int j=0;j<arBdOtherOpening.length();j++ ){
arPtOpeningDim.append(arBdOtherOpening[j].extremeVertices(el.vecX()));
}
arPtOpeningDim.append(ptReference);
//Offset
double dOffset = dOffsetOpening;
int bRecalcRequested = TRUE;
String sDimensionKey = "Opening-"+op.handle();
if( _Map.hasEntity(sDimensionKey) ){
Entity ent = _Map.getEntity(sDimensionKey);
TslInst tsl = (TslInst)ent;
if( tsl.bIsValid() ){
Map mapTsl = tsl.map();
int nExecutionMode = mapTsl.getInt("ExecutionMode");
if( nExecutionMode != 2 ){//not equal to request recalc
bRecalcRequested = FALSE;
}
else{
ent.dbErase();
_Map.removeAt(sDimensionKey, TRUE);
}
}
else{
_Map.removeAt(sDimensionKey, TRUE);
}
}
if( bRecalcRequested ){
Line ln(ptReference, el.vecX());
arPtOpeningDim = ln.projectPoints(arPtOpeningDim);
arPtOpeningDim = ln.orderPoints(arPtOpeningDim);
Vector3d vyDim = -el.vecZ();
if( vyDim.dotProduct(_YW - _XW) < 0 )
vyDim = el.vecZ();
Vector3d vxDim = vyDim.crossProduct(_ZW);
Point3d ptOrigin = arPtOpeningDim[0] + el.vecZ() * dOffset - el.vecX() * U(100);
Map mapDim;
mapDim.setInt("ExecutionMode", 0);
mapDim.setEntity("Parent", _ThisInst);
mapDim.setVector3d("vxDim", vxDim);
mapDim.setVector3d("vyDim", vyDim);
mapDim.setPoint3d("Pt0", ptOrigin, _kAbsolute);
lstPoints.setLength(0);
lstPoints.append(ptOrigin);
lstPoints.append(arPtOpeningDim);
TslInst tsl;
tsl.dbCreate(strScriptName, vecUcsX,vecUcsY,lstBeams, lstElements, lstPoints, lstPropInt, lstPropDouble, lstPropString, _kModelSpace, mapDim ); // create new instance
int nValuesSet = tsl.setPropValuesFromCatalog(sCatalogKeyOutside);
tsl.setPropString(T("|Floorgroup|"), sNameFloorGroup);
tsl.setPropString(T("|Text at middle of dimension line|"), "<>");
tsl.setPropString(T("|Text at end of dimension line|"), "<>");
if( nValuesSet )tsl.transformBy(_XW*0);
grpFloor.addEntity(tsl, TRUE, 0, 'D');
_Map.setEntity(sDimensionKey, tsl);
}
}
//Calculate the length of the SY beams in combination with the openings (added to the PlaneProfile)
PLine arPlSY[] = ppSY.allRings();
for( int i=0;i<arPlSY.length();i++ ){
PLine plSY = arPlSY[i];
//Extreme points of pline
Point3d arPtPl[] = plSY.vertexPoints(TRUE);
//Extreme points in X & Y direction
Point3d arPtPlX[] = lnX.orderPoints(arPtPl);
Point3d arPtPlY[] = lnY.orderPoints(arPtPl);
if( arPtPlX.length() < 2 || arPtPlY.length() < 2 ){
reportWarning(TN("|Not enough vertices found for calculation of extremes!|"));
return;
}
//Length in both directions
double dLengthX = vx.dotProduct(arPtPlX[arPtPlX.length() - 1] - arPtPlX[0]);
double dLengthY = vy.dotProduct(arPtPlY[arPtPlY.length() - 1] - arPtPlY[0]);
//Check direction and get length and direction
double dLengthSY;
Vector3d vxBm;
Point3d ptTxt;
if( dLengthX > dLengthY ){
//Horizontal beam
dLengthSY = dLengthX;
vxBm = vx;
ptTxt = arPtPlX[0];
}
else{
//Vertical beam
dLengthSY = dLengthY;
vxBm = vy;
ptTxt = arPtPlY[0];
}
//Vector pointing outside
Vector3d vOutside = vz.crossProduct(vxBm);
if( vOutside.dotProduct(ptTxt - _Pt0) < 0 ){
vOutside = -vOutside;
}
//Reposition ptTxt to outside of SY-beam
ptTxt = plSY.closestPointTo(ptTxt + vOutside * U(150));
if( ppHouse.pointInProfile(ptTxt) == _kPointInProfile ){
vOutside = -vOutside;
ptTxt = plSY.closestPointTo(ptTxt + vOutside * U(150));
}
ptTxt.vis();