/
reinf_concr_column.py
1831 lines (1485 loc) · 83.6 KB
/
reinf_concr_column.py
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
# -*- coding: utf8 -*-
"""Reinforced Concrete Column script using standard pythonpart
Author:
Christophe MAIGNAN @ API2GETHER - 2024
"""
from typing import List
import math
import csv
import NemAll_Python_BaseElements as BaseElements
import NemAll_Python_BasisElements as BasisElements
import NemAll_Python_Geometry as Geometry
import NemAll_Python_AllplanSettings as Settings
import NemAll_Python_IFW_ElementAdapter as ElementAdapter
import NemAll_Python_IFW_Input as IFWInput
import NemAll_Python_ArchElements as ArchElements
import NemAll_Python_Reinforcement as Reinforcement
from BuildingElement import BuildingElement
from BuildingElementAttributeList import BuildingElementAttributeList
from CreateElementResult import CreateElementResult
from PythonPartUtil import PythonPartUtil
from ControlPropertiesUtil import ControlPropertiesUtil
from HandlePropertiesService import HandlePropertiesService
from HandleDirection import HandleDirection
from HandleParameterData import HandleParameterData
from HandleParameterType import HandleParameterType
from HandleProperties import HandleProperties
from Utils.RotationUtil import RotationUtil
import StdReinfShapeBuilder.GeneralReinfShapeBuilder as GeneralShapeBuilder
import StdReinfShapeBuilder.LinearBarPlacementBuilder as LinearBarBuilder
from StdReinfShapeBuilder.ConcreteCoverProperties import ConcreteCoverProperties
from StdReinfShapeBuilder.ReinforcementShapeProperties import ReinforcementShapeProperties
from StdReinfShapeBuilder.RotationAngles import RotationAngles
from StdReinfShapeBuilder.BarShapePlacementUtil import BarShapePlacementUtil
print('Load Reinforced Concrete Column')
def check_allplan_version(build_ele : BuildingElement,
version : float) -> bool:
"""Check the current Allplan version
Args:
build_ele : the building element
version : the current Allplan version
Returns:
True/False if version is supported by this script
"""
# Support versions >= 2024
version = Settings.AllplanVersion.MainReleaseName()
if float(version) >= 2024:
return True
else:
return False
def move_handle(build_ele : BuildingElement,
handle_prop : HandleProperties,
input_pnt : Geometry.Point3D,
doc : ElementAdapter.DocumentAdapter) -> CreateElementResult:
"""Called after modification of the element geometry using handles
Args:
build_ele : building element with the parameter properties
handle_prop : handle properties
input_pnt : input point
doc : input document
Returns:
Object with the result data of the element creation
"""
HandlePropertiesService.update_property_value(build_ele, handle_prop, input_pnt)
return create_element(build_ele, doc)
def initialize_control_properties(build_ele : BuildingElement,
ctrl_prop_util : ControlPropertiesUtil,
doc : ElementAdapter.DocumentAdapter) -> None:
"""Called after the properties and their values are read, but before
the property palette is displayed.
Args:
build_ele : building element
ctrl_prop_util : control properties utility
doc : document
"""
if build_ele.CSVFilePath.value:
ctrl_prop_util.set_enable_condition("ImportDataButton", "True")
set_constructive_dispositions(build_ele, ctrl_prop_util)
calcul_as_real(build_ele)
def modify_control_properties(build_ele : BuildingElement,
ctrl_prop_util : ControlPropertiesUtil,
value_name : str,
event_id : int,
doc : ElementAdapter.DocumentAdapter) -> bool:
"""Called after each change within the property palette
Args:
build_ele : building element
ctrl_prop_util : control properties utility
value_name : name(s) of the modified value (multiple names are separated by ,)
event_id : event ID
doc : document
Returns:
True if an update of the property palette is necessary, False otherwise
"""
if value_name == "ChoiceRadioGroup":
if build_ele.ChoiceRadioGroup.value == "circle":
build_ele.ColumnRotAngleZ.value = 0
build_ele.TextRotAngle.value = 0
return True
if event_id == build_ele.IMPORT_REINF_DATA_FROM_CSV:
# Path of CSV file
csv_file_path = build_ele.CSVFilePath.value
# Opening and reading the CSV file
with open(csv_file_path, mode='r', encoding='utf-8') as file:
csv_reader = csv.DictReader(file)
# Iterating over each row in the CSV file
for row in csv_reader:
# Search column name
if row['Repère'] == build_ele.ColumnId.value:
# Extracting the required data
long_rebars_diameter = row.get('Diamètre Armatures Longitudinales', '').strip()
long_rebars_quantity = row.get('Quantité Armatures Longitudinales', '').strip()
stir_rebars_diameter = row.get('Diamètre Armatures Transversales', '').strip()
A_stirrup_spacing = row.get('Espacement A Armatures Transversales', '').strip()
B_stirrup_spacing = row.get('Espacement B Armatures Transversales', '').strip()
C_stirrup_spacing = row.get('Espacement C Armatures Transversales', '').strip()
# Change value if not empty
if all([long_rebars_diameter, long_rebars_quantity, stir_rebars_diameter, A_stirrup_spacing, B_stirrup_spacing, C_stirrup_spacing]):
long_rebars_diameter = int(long_rebars_diameter)
valid_diameters = [8, 10, 12, 14, 16, 20]
if long_rebars_diameter in valid_diameters:
build_ele.FirstBarDiameter.value = long_rebars_diameter
build_ele.SecondBarDiameter.value = long_rebars_diameter
esp_min = 100
esp_max = 400
concr_cover = build_ele.ReinfConcreteCover.value
if build_ele.ChoiceRadioGroup.value == "rectangle":
length = max(build_ele.ColumnLength.value, build_ele.ColumnThick.value) - 2 * concr_cover
thickness = min(build_ele.ColumnLength.value, build_ele.ColumnThick.value) - 2 * concr_cover
nbr_rebars = int(long_rebars_quantity) - 4 # 4 => one main longitudinal rebar for each corner
min_value_in_length = max(0, math.ceil(length / esp_max) - 1)
max_value_in_length = max(min_value_in_length, math.floor(length / esp_min) - 1)
min_value_in_thick = max(0, math.ceil(thickness / esp_max) - 1)
max_value_in_thick = max(min_value_in_thick, math.floor(thickness / esp_min) - 1)
init_qtt_in_length = max(min_value_in_length, math.ceil((nbr_rebars - 2 * min_value_in_thick) / 2))
init_qtt_in_thick = min_value_in_thick
if init_qtt_in_length > max_value_in_length:
build_ele.ScndBarRectQttInLength.value = max_value_in_length
init_qtt_in_thick = nbr_rebars - 2 * max_value_in_length
else:
build_ele.ScndBarRectQttInLength.value = init_qtt_in_length
if init_qtt_in_thick > max_value_in_thick:
build_ele.ScndBarRectQttInThick.value = max_value_in_thick
else:
build_ele.ScndBarRectQttInThick.value = init_qtt_in_thick
main_stirrup_max_spac = min(20 * build_ele.FirstBarDiameter.value, 400, min(build_ele.ColumnLength.value, build_ele.ColumnThick.value))
else:
nbr_rebars = int(long_rebars_quantity)
diameter = 2 * math.pi * (build_ele.ColumnRadius.value - concr_cover)
min_value_circ = max(4, math.ceil(diameter / esp_max))
max_value_circ = max(min_value_circ, math.floor(diameter / esp_min))
nbr_rebars = max(min_value_circ, min(nbr_rebars, max_value_circ))
build_ele.RebarCircQtt.value = nbr_rebars
main_stirrup_max_spac = min(20 * build_ele.FirstBarDiameter.value, 400, 2 * build_ele.ColumnRadius.value)
# Stirrup diameter and spacing
scnd_stirrup_max_spac = 0.6 * main_stirrup_max_spac
ctrl_prop_util.set_max_value("MainStirrup", f",10,{main_stirrup_max_spac}")
ctrl_prop_util.set_max_value("StirrupList", f",{scnd_stirrup_max_spac},,")
A_stirrup_spacing = min(main_stirrup_max_spac, float(A_stirrup_spacing))
B_stirrup_spacing = min(scnd_stirrup_max_spac, float(B_stirrup_spacing))
C_stirrup_spacing = min(scnd_stirrup_max_spac, float(C_stirrup_spacing))
main_stirrup = build_ele.MainStirrup.value
main_stirrup = main_stirrup._replace(Spacing = A_stirrup_spacing)
valid_diameters = [6, 8, 10]
stir_rebars_diameter = int(stir_rebars_diameter)
if stir_rebars_diameter in valid_diameters:
main_stirrup = main_stirrup._replace(Diameter = stir_rebars_diameter)
build_ele.MainStirrup.value = main_stirrup
stirrup_list = build_ele.StirrupList.value
stirrup_list[0] = stirrup_list[0]._replace(Spacing = B_stirrup_spacing)
stirrup_list[1] = stirrup_list[1]._replace(Spacing = C_stirrup_spacing)
break
calcul_as_real(build_ele)
return True
if event_id == build_ele.CALC_LONG_REBAR_DIAM:
as_min = build_ele.AsMinDouble.value
list_diam_mm = [8, 10, 12, 14, 16, 20]
dict_section_cm2 = {diam: math.pi * (diam * 0.1 / 2) ** 2 for diam in list_diam_mm}
if build_ele.ChoiceRadioGroup.value == "rectangle":
nbr_rebars = 4 + 2 * (build_ele.ScndBarRectQttInLength.value + build_ele.ScndBarRectQttInThick.value)
else:
nbr_rebars = build_ele.RebarCircQtt.value
for diametre, section in dict_section_cm2.items():
if section * nbr_rebars >= as_min:
build_ele.FirstBarDiameter.value = build_ele.SecondBarDiameter.value = diametre
break
calcul_as_real(build_ele)
return True
if value_name in ('ShowReinfCheckBox',
'ChoiceRadioGroup',
'ColumnLength',
'ColumnThick',
'ColumnRadius',
'TakeColumnDim',
'FirstBarDiameter',
'SecondBarDiameter',
'ScndBarAsFirstBar',
'ScndBarRectQttInLength',
'ScndBarRectQttInThick',
'RebarCircQtt',
'MainStirrup',
'StirrupList'):
if build_ele.TakeColumnDim.value:
build_ele.NextColumnLength.value = build_ele.ColumnLength.value
build_ele.NextColumnThick.value = build_ele.ColumnThick.value
build_ele.NextColumnRadius.value = build_ele.ColumnRadius.value
if build_ele.ScndBarAsFirstBar.value:
build_ele.SecondBarDiameter.value = build_ele.FirstBarDiameter.value
set_constructive_dispositions(build_ele, ctrl_prop_util)
calcul_as_real(build_ele)
return True
if value_name == "ColumnRotAngleZ":
build_ele.TextRotAngle.value = -build_ele.ColumnRotAngleZ.value
return True
if value_name == "CSVFilePath":
if build_ele.CSVFilePath.value:
ctrl_prop_util.set_enable_condition("ImportDataButton", "True")
return True
return False
def on_control_event(build_ele : BuildingElement,
event_id : int,
doc : ElementAdapter.DocumentAdapter) -> None:
""" Called, when an event is triggered with a control (e.g. a button) in a property palette
Args:
build_ele : building element with the parameter properties
event_id : event id of the triggered control
doc : document of the Allplan drawing files
"""
def create_preview(build_ele : BuildingElement,
doc : ElementAdapter.DocumentAdapter) -> CreateElementResult:
"""Function for the creation of the library preview elements.
Args:
build_ele : the building element
doc : input document
Returns:
Preview elements. Only elements included in the property "elements" will be shown in the library preview
"""
com_prop = Settings.AllplanGlobalSettings.GetCurrentCommonProperties()
com_prop.GetGlobalProperties()
axis = Geometry.AxisPlacement3D(Geometry.Point3D())
geo = Geometry.BRep3D.CreateCuboid(axis, 300, 300, 5000)
model_ele_list = [BasisElements.ModelElement3D(com_prop, geo)]
return CreateElementResult(elements = model_ele_list)
def create_element(build_ele : BuildingElement,
doc : ElementAdapter.DocumentAdapter) -> CreateElementResult:
"""Creation of element
Args:
build_ele : the building element
doc : input document
Returns:
result of the created element
"""
model_ele_list = []
handle_list = []
attr_list = BuildingElementAttributeList()
pyp_util = PythonPartUtil()
# Extract parameters values from palette
column_id = build_ele.ColumnId.value
column_concrete_gr_value = build_ele.ConcreteGrade.value
concrete_grade_dict = {1: 'C12/15',
2: 'C16/20',
3: 'C20/25',
4: 'C25/30',
5: 'C30/37',
6: 'C35/45',
7: 'C40/50',
8: 'C45/55',
9: 'C50/60',
10: 'C55/67',
11: 'C60/75',
12: 'C70/85',
13: 'C80/95',
14: 'C90/105',
15: 'C100/115',
}
column_concrete_gr = concrete_grade_dict[column_concrete_gr_value]
choice = build_ele.ChoiceRadioGroup.value
column_length = build_ele.ColumnLength.value
column_thickness = build_ele.ColumnThick.value
column_radius = build_ele.ColumnRadius.value
column_height = build_ele.ColumnHeight.value
col_z_rotation = build_ele.ColumnRotAngleZ.value
has_next_col = build_ele.NextColumnCheckBox.value
next_col_length = build_ele.NextColumnLength.value
next_col_thick = build_ele.NextColumnThick.value
next_col_radius = build_ele.NextColumnRadius.value
attach_point = build_ele.AttachmentPoint.value
plane_ref: ArchElements.PlaneReferences = build_ele.PlaneReferences.value
column_bottom = plane_ref.GetAbsBottomElevation()
slab_height = build_ele.SlabHeight.value
texture = BasisElements.TextureDefinition(build_ele.MaterialButton.value)
# Define common properties
com_prop = build_ele.CommonProperties.value
# Define help properties
help_prop = BaseElements.CommonProperties()
help_prop.GetGlobalProperties()
help_prop.HelpConstruction = True
# Define reinforcement properties
is_showing_reinf = build_ele.ShowReinfCheckBox.value
reinf_prop = BaseElements.CommonProperties()
reinf_prop.Layer = build_ele.ReinfLayerProperties.value
# Define hatch properties
has_hatch = build_ele.HatchCheckBox.value
hatch_prop = BasisElements.HatchingProperties()
hatch_prop.HatchID = build_ele.HatchStyle.value
# Define fill properties
has_fill = build_ele.FillCheckBox.value
fill_prop = BasisElements.FillingProperties()
fill_prop.FirstColor = BaseElements.GetColorById(build_ele.FillColor.value)
# Define text properties
is_showing_annotation = build_ele.ShowTextCheckBox.value
text_com_prop = BaseElements.CommonProperties()
text_com_prop = build_ele.TextCommonProperties.value
text_dict = {"Aligner à Gauche" : BasisElements.TextAlignment.eLeftMiddle,
"Centrer" : BasisElements.TextAlignment.eMiddleMiddle,
"Aligner à Droite" : BasisElements.TextAlignment.eRightMiddle
}
text_prop = BasisElements.TextProperties()
text_prop.Height = text_prop.Width = build_ele.TextHeight.value
text_prop.Alignment = text_dict[build_ele.TextAlignment.value]
angle = Geometry.Angle()
angle.Deg = build_ele.TextRotAngle.value
text_prop.TextAngle = angle
text_origin = build_ele.TextOrigin.value
# Define handle properties
is_showing_handles = build_ele.ShowHandlesCheckBox.value
# Create 3D object
if choice == "rectangle":
main_column = Cuboid(build_ele, True, com_prop, attach_point, column_bottom, texture, column_length, column_thickness, column_height, col_z_rotation, slab_height)
next_column = Cuboid(build_ele, False, help_prop, attach_point, column_height, texture, next_col_length, next_col_thick, 1000, col_z_rotation, slab_height)
# Constructions line to align center point
frst_line = Geometry.Line3D(0, 0, 0, column_length, column_thickness, 0)
scnd_line = Geometry.Line3D(0, 0, 0, next_col_length, next_col_thick, 0)
from_point = scnd_line.GetCenterPoint()
to_point = frst_line.GetCenterPoint()
else:
main_column = Cylinder(build_ele, True, com_prop, attach_point, column_bottom, texture, column_radius, column_height, slab_height)
next_column = Cylinder(build_ele, False, help_prop, attach_point, column_height, texture, next_col_radius, 1000, slab_height)
from_point = to_point = Geometry.Point3D()
main_column.create_geo()
# Get intersection volume between main and next column
base_column = Geometry.Move(main_column.create_geo(), Geometry.Vector3D(0, 0, column_height))
next_column = Geometry.Move(next_column.create_geo(), Geometry.Vector3D(from_point, to_point))
err, intersect_column = Geometry.Intersect(base_column, next_column)
# Add object to view
pyp_util.add_pythonpart_view_2d3d(main_column.add_view())
if has_next_col:
pyp_util.add_pythonpart_view_2d(BasisElements.ModelElement3D(help_prop, texture, intersect_column))
# Create the handles
if is_showing_handles:
# Z rotation
if choice == "rectangle":
handle = HandleProperties(handle_id = "ColumnRotationHandle",
handle_point = main_column.points_list[10],
ref_point = main_column.points_list[0],
handle_param_data = [HandleParameterData("ColumnRotAngleZ", HandleParameterType.ANGLE)],
handle_move_dir = HandleDirection.ANGLE,
info_text = "Rotation suivant Z")
handle_list.append(handle)
for item in main_column.handles_prop:
handle = HandleProperties(handle_id = item.handle_id,
handle_point = item.handle_point,
ref_point = item.ref_point,
handle_param_data = [HandleParameterData(item.handle_param_data, HandleParameterType.POINT_DISTANCE)],
handle_move_dir = item.handle_move_dir,
distance_factor = item.distance_factor,
info_text = item.handle_info_text
)
handle_list.append(handle)
# Create the annotation
if is_showing_annotation:
# Set text value
text = f"{column_id} {main_column.name_dim}"
if column_concrete_gr_value > 4:
text += f"\n{column_concrete_gr}"
# Set origin of text
origin = text_origin - main_column.points_list[0]
# Text remains horizontal
placement_mat = Geometry.Matrix3D()
if choice == "rectangle":
rotation_axis = Geometry.Line3D(Geometry.Point3D(), Geometry.Point3D(0, 0, 1))
rotation_angle = Geometry.Angle.FromDeg(-col_z_rotation)
placement_mat.SetRotation(rotation_axis,rotation_angle)
origin = Geometry.Transform(origin, placement_mat)
# Transform Point3D to Point2D
origin = Geometry.Point2D(origin)
# Add text to view
pyp_util.add_pythonpart_view_2d(BasisElements.TextElement(text_com_prop, text_prop, text, origin))
text_handle = HandleProperties(handle_id = "Text",
handle_point = text_origin,
ref_point = main_column.points_list[0],
handle_param_data = [HandleParameterData("TextOrigin", HandleParameterType.POINT, False)],
handle_move_dir = HandleDirection.XYZ_DIR,
info_text = "Origine du texte"
)
text_handle.handle_type = IFWInput.ElementHandleType.HANDLE_SQUARE_RED
handle_list.append(text_handle)
# Create hatch
if has_hatch:
pyp_util.add_pythonpart_view_2d(BasisElements.HatchingElement(com_prop, hatch_prop, main_column.create_hatch_geo()))
# Create fill
if has_fill:
pyp_util.add_pythonpart_view_2d(BasisElements.FillingElement(com_prop, fill_prop, main_column.create_hatch_geo()))
# Create reinforcement
if is_showing_reinf:
reinf_ele_list = main_column.create_reinforcement()
# Apply reinforcement properties
for rebar in reinf_ele_list:
rebar.SetCommonProperties(reinf_prop)
pyp_util.add_reinforcement_elements(reinf_ele_list)
#
# Attributes
#
# Attribute set object @18358@
attr_list.add_attribute(18358, "Column")
# Code @18199@
attr_list.add_attribute(18199, "ReinforcedConcreteColumn")
# Trade @209@
attr_list.add_attribute(209, 13)
# Status @49@
attr_list.add_attribute(49, 0)
# Load bearing @573@
attr_list.add_attribute(573, 1)
# Concrete grade @1905@
attr_list.add_attribute(1905, column_concrete_gr)
# Geometry
length, thickness, radius, height, surface, volume = main_column.calcul_dimensions()
attr_list.add_attribute(220, length)
attr_list.add_attribute(221, thickness)
attr_list.add_attribute(107, radius)
attr_list.add_attribute(222, height)
attr_list.add_attribute(293, surface)
attr_list.add_attribute(226, volume)
#
# Reinforcement attributes
#
if is_showing_reinf:
weight, quantity, col_concr_cover, height, height_under_beam, \
frst_long_rebars, scnd_long_rebars, length_long_rebars, \
stirrup_A_placement, stirrup_B_placement, stirrup_C_placement, stirrup_sum_qtt_diam, stirrup_sum_dim, \
crosstie_along_length, crosstie_along_thick, \
next_col_dim, start_rebars_qtt, start_rebars_mid_length = main_column.create_reinf_attributes()
# Weight of bar
attr_list.add_attribute(756, weight)
# Quantity
attr_list.add_attribute(201, quantity)
# Concrete cover => ALLFA_value_03
attr_list.add_attribute(845, col_concr_cover)
# Column dimensions => ALLFA_value_06
attr_list.add_attribute(848, main_column.name_dim)
# Height => ALLFA_value_07
attr_list.add_attribute(849, height)
# Height under beam => ALLFA_value_08
attr_list.add_attribute(850, height_under_beam)
# First longitudinal rebars => ALLFA_value_09
attr_list.add_attribute(851, frst_long_rebars)
# Second longitudinal rebars => ALLFA_value_10
attr_list.add_attribute(852, scnd_long_rebars)
# Length of longitudinal rebars => ALLFA_value_11
attr_list.add_attribute(853, length_long_rebars)
# Stirrup placement [A] => ALLFA_value_12
attr_list.add_attribute(854, stirrup_A_placement)
# Stirrup placement [B] => ALLFA_value_13
attr_list.add_attribute(855, stirrup_B_placement)
# Stirrup placement [C] => ALLFA_value_14
attr_list.add_attribute(856, stirrup_C_placement)
# Stirrup summary for quantity / diameter => ALLFA_value_15
attr_list.add_attribute(857, stirrup_sum_qtt_diam)
# Stirrup summary for dimensions => ALLFA_value_16
attr_list.add_attribute(858, stirrup_sum_dim)
# Crosstie along length => ALLFA_value_17
attr_list.add_attribute(859, crosstie_along_length)
# Crosstie along thickness => ALLFA_value_18
attr_list.add_attribute(860, crosstie_along_thick)
# Next column dimensions => ALLFA_value_19
attr_list.add_attribute(861, next_col_dim)
# Starter rebars quantity => ALLFA_value_20
attr_list.add_attribute(862, start_rebars_qtt)
# Starter rebars mid length => ALLFA_value_01
attr_list.add_attribute(843, start_rebars_mid_length)
attr_list.add_attributes_from_parameters(build_ele)
pyp_util.add_attribute_list(attr_list)
# Reference point
placement_mat = Geometry.Matrix3D()
if choice == "rectangle":
rotation_axis = Geometry.Line3D(Geometry.Point3D(), Geometry.Point3D(0, 0, 1))
rotation_angle = Geometry.Angle.FromDeg(col_z_rotation)
placement_mat.SetRotation(rotation_axis,rotation_angle)
placement_mat.SetTranslation(Geometry.Vector3D(main_column.placement_pt))
# Create the PythonPart
model_ele_list = pyp_util.create_pythonpart(build_ele, placement_mat)
return CreateElementResult(model_ele_list, handle_list)
def set_constructive_dispositions(build_ele : BuildingElement,
ctrl_prop_util : ControlPropertiesUtil) -> None:
"""Calcul of constructive dispositions
Args:
build_ele : the building element
ctrl_prop_util : control properties utility
"""
# Set distance between rebars
esp_min = 100
esp_max = 400
if build_ele.ChoiceRadioGroup.value == "rectangle":
# Concrete section in cm²
Ac = (build_ele.ColumnLength.value * build_ele.ColumnThick.value) * 1e-2
# Rebars quantity
length = build_ele.ColumnLength.value - 2 * build_ele.ReinfConcreteCover.value
thickness = build_ele.ColumnThick.value - 2 * build_ele.ReinfConcreteCover.value
min_value_in_length = max(0, math.ceil(length / esp_max) - 1)
max_value_in_length = max(min_value_in_length, math.floor(length / esp_min) - 1)
min_value_in_thick = max(0, math.ceil(thickness / esp_max) - 1)
max_value_in_thick = max(min_value_in_thick, math.floor(thickness / esp_min) - 1)
if build_ele.ScndBarRectQttInLength.value > 0 or build_ele.ScndBarRectQttInThick.value > 0:
main_stirrup_max_dist = min(20 * min(build_ele.FirstBarDiameter.value, build_ele.SecondBarDiameter.value), 400, min(build_ele.ColumnLength.value, build_ele.ColumnThick.value))
else:
main_stirrup_max_dist = min(20 * build_ele.FirstBarDiameter.value, 400, min(build_ele.ColumnLength.value, build_ele.ColumnThick.value))
top_stirrup_length = max(build_ele.ColumnLength.value, build_ele.ColumnThick.value)
build_ele.ScndBarRectQttInLength.value = min_value_in_length if build_ele.ScndBarRectQttInLength.value < min_value_in_length else (max_value_in_length if build_ele.ScndBarRectQttInLength.value > max_value_in_length else build_ele.ScndBarRectQttInLength.value)
build_ele.ScndBarRectQttInThick.value = min_value_in_thick if build_ele.ScndBarRectQttInThick.value < min_value_in_thick else (max_value_in_thick if build_ele.ScndBarRectQttInThick.value > max_value_in_thick else build_ele.ScndBarRectQttInThick.value)
# Change the min and max values if they are different, otherwise reset and lock the value
if min_value_in_length != max_value_in_length:
ctrl_prop_util.set_min_value("ScndBarRectQttInLength", str(min_value_in_length))
ctrl_prop_util.set_max_value("ScndBarRectQttInLength", str(max_value_in_length))
ctrl_prop_util.set_enable_condition("ScndBarRectQttInLength", "True")
else:
ctrl_prop_util.set_min_value("ScndBarRectQttInLength", "0")
ctrl_prop_util.set_max_value("ScndBarRectQttInLength", "10")
ctrl_prop_util.set_enable_condition("ScndBarRectQttInLength", "False")
# Change the min and max values if they are different, otherwise reset and lock the value
if min_value_in_thick != max_value_in_thick:
ctrl_prop_util.set_min_value("ScndBarRectQttInThick", str(min_value_in_thick))
ctrl_prop_util.set_max_value("ScndBarRectQttInThick", str(max_value_in_thick))
ctrl_prop_util.set_enable_condition("ScndBarRectQttInThick", "True")
else:
ctrl_prop_util.set_min_value("ScndBarRectQttInThick", "0")
ctrl_prop_util.set_max_value("ScndBarRectQttInThick", "10")
ctrl_prop_util.set_enable_condition("ScndBarRectQttInThick", "False")
else:
# Concrete section in cm²
Ac = (math.pi * build_ele.ColumnRadius.value ** 2) * 1e-2
# Rebars quantity
diameter = 2 * math.pi * (build_ele.ColumnRadius.value - build_ele.ReinfConcreteCover.value)
min_value = max(4, math.ceil(diameter / esp_max))
max_value = max(min_value, math.floor(diameter / esp_min))
main_stirrup_max_dist = min(20 * build_ele.FirstBarDiameter.value, 400, 2 * build_ele.ColumnRadius.value)
top_stirrup_length = 2 * build_ele.ColumnRadius.value
build_ele.RebarCircQtt.value = min_value if build_ele.RebarCircQtt.value < min_value else (max_value if build_ele.RebarCircQtt.value > max_value else build_ele.RebarCircQtt.value)
# Change the min and max values if they are different, otherwise reset and lock the value
if min_value != max_value:
ctrl_prop_util.set_min_value("RebarCircQtt", str(min_value))
ctrl_prop_util.set_max_value("RebarCircQtt", str(max_value))
ctrl_prop_util.set_enable_condition("RebarCircQtt", "True")
else:
ctrl_prop_util.set_min_value("RebarCircQtt", "0")
ctrl_prop_util.set_max_value("RebarCircQtt", "10")
ctrl_prop_util.set_enable_condition("RebarCircQtt", "False")
# As min and As max in cm²
build_ele.AsMinDouble.value = 0.002 * Ac
build_ele.AsMaxDouble.value = 0.04 * Ac
# Set distance between stirrups
stirrup_list = build_ele.StirrupList.value
end_stirrup_max_dist = 0.6 * main_stirrup_max_dist
bottom_stirrup_length = 2 * stirrup_list[0][1]
ctrl_prop_util.set_max_value("MainStirrup", f",10,{main_stirrup_max_dist}")
ctrl_prop_util.set_max_value("StirrupList", f",{end_stirrup_max_dist},,")
stirrup_list[0] = stirrup_list[0]._replace(Length = float(bottom_stirrup_length))
stirrup_list[1] = stirrup_list[1]._replace(Length = float(top_stirrup_length))
def calcul_as_real(build_ele : BuildingElement) -> None:
"""Calcul of As real
Args:
build_ele : the building element
"""
if build_ele.ChoiceRadioGroup.value == "rectangle":
as_frst_rebar = 4 * math.pi * (build_ele.FirstBarDiameter.value / 10) ** 2 / 4
as_scnd_rebar = 2 * (build_ele.ScndBarRectQttInLength.value + build_ele.ScndBarRectQttInThick.value) * math.pi * (build_ele.SecondBarDiameter.value / 10) ** 2 / 4
build_ele.AsRealDouble.value = as_frst_rebar + as_scnd_rebar
else:
build_ele.AsRealDouble.value = build_ele.RebarCircQtt.value * math.pi * (build_ele.FirstBarDiameter.value / 10) ** 2 / 4
class Objects3D:
"""Definition of class Objects3D
"""
def __init__(self,
build_ele : BuildingElement,
is_main_col : bool,
object_prop : BaseElements.CommonProperties,
attach_point : int,
column_bottom : float,
texture : BasisElements.TextureDefinition):
self.build_ele = build_ele
self.is_main_col = is_main_col
self.object_prop = object_prop
self.geo = None
self.attach_point = attach_point
self.texture = texture
self.x_offset = 0
self.y_offset = 0
self.z_offset = column_bottom
self.points_list = []
self.reinf_ele_list = []
def calcul_dimensions(self) -> tuple:
pass
def create_geo(self) -> Geometry.BRep3D:
pass
def create_hatch_geo(self) -> Geometry.Polygon2D:
pass
def add_view(self) -> BasisElements.ModelElement3D:
object_3d = BasisElements.ModelElement3D(self.object_prop, self.texture, self.geo)
return object_3d
def attachment_point(self) -> Geometry.Point3D:
pass
def apply_transfo_matrix_to_handles(self) -> None:
placement_mat = Geometry.Matrix3D()
if self.__class__.__name__ == "Cuboid":
rotation_axis = Geometry.Line3D(Geometry.Point3D(), Geometry.Point3D(0, 0, 1))
rotation_angle = Geometry.Angle.FromDeg(self.col_z_rotation)
placement_mat.SetRotation(rotation_axis,rotation_angle)
placement_mat.SetTranslation(Geometry.Vector3D(self.placement_pt))
self.points_list = [Geometry.Transform(point, placement_mat) for point in self.points_list]
def create_reinforcement(self) -> List[Reinforcement.BarPlacement]:
self.reinf_ele = Reinforcement3D(self.build_ele)
reinf_ele_list = self.reinf_ele.create_rebars()
return reinf_ele_list
def create_reinf_attributes(self) -> tuple:
pass
class Handle:
"""Definition of class Handle
"""
def __init__(self,
handle_id : str,
handle_point : Geometry.Point3D,
ref_point : Geometry.Point3D,
handle_param_data : str,
handle_move_dir : HandleDirection,
handle_info_text : str,
distance_factor : float):
self.handle_id = handle_id
self.handle_point = handle_point
self.ref_point = ref_point
self.handle_param_data = handle_param_data
self.handle_move_dir = handle_move_dir
self.handle_info_text = handle_info_text
self.distance_factor = distance_factor
class Cuboid(Objects3D):
"""Definition of class Cuboid
"""
def __init__(self,
build_ele : BuildingElement,
is_main_col : bool,
object_prop : BaseElements.CommonProperties,
attach_point : int,
column_bottom : float,
texture : BasisElements.TextureDefinition,
column_length : float,
column_thick : float,
column_height : float,
col_z_rotation : float,
slab_height : float):
Objects3D.__init__(self, build_ele, is_main_col, object_prop, attach_point, column_bottom, texture)
self.column_length = column_length
self.column_thick = column_thick
self.column_height = column_height
self.col_z_rotation = col_z_rotation
self.slab_height = slab_height
self.name_dim = f"{round(column_thick / 10)}x{round(column_length / 10)}"
self.placement_pt = self.attachment_point()
# Set points list
"""
Points List :
5 6 7
---------------
| |
3 | 8 | 4
| |
---------------
0 10 1 2
"""
self.points_list = [Geometry.Point3D(), # 0
Geometry.Point3D(self.column_length / 2, 0, 0), # 1
Geometry.Point3D(self.column_length, 0, 0), # 2
Geometry.Point3D(0, self.column_thick / 2, 0), # 3
Geometry.Point3D(self.column_length, self.column_thick / 2, 0), # 4
Geometry.Point3D(0, self.column_thick, 0), # 5
Geometry.Point3D(self.column_length / 2, self.column_thick, 0), # 6
Geometry.Point3D(self.column_length, self.column_thick, 0), # 7
Geometry.Point3D(self.column_length / 2, self.column_thick / 2, 0), # 8
Geometry.Point3D(0, 0, self.column_height), # 9
Geometry.Point3D(self.column_length / 4, 0, 0), # 10
Geometry.Point3D(0, 0, self.column_height - self.slab_height) # 11
]
self.apply_transfo_matrix_to_handles()
# Set handles
self.handles_prop = [Handle("ColumnHeightHandle",
self.points_list[9],
self.points_list[0],
"ColumnHeight",
HandleDirection.Z_DIR,
"Hauteur",
1
),
Handle("SlabHeightHandle",
self.points_list[11],
self.points_list[9],
"SlabHeight",
HandleDirection.Z_DIR,
"Hauteur Poutre / Dalle",
1
)
]
# Handle dictionary : [handle point, base point, factor] with 2 handles if in middle
handle_length_dict = {1 : [self.points_list[7], self.points_list[5], 1],
2 : [[self.points_list[7], self.points_list[6], 2],
[self.points_list[5], self.points_list[6], 2]],
3 : [self.points_list[5], self.points_list[7], 1],
4 : [self.points_list[4], self.points_list[3], 1],
5 : [[self.points_list[4], self.points_list[8], 2],
[self.points_list[3], self.points_list[8], 2]],
6 : [self.points_list[3], self.points_list[4], 1],
7 : [self.points_list[2], self.points_list[0], 1],
8 : [[self.points_list[2], self.points_list[1], 2],
[self.points_list[0], self.points_list[1], 2]],
9 : [self.points_list[0], self.points_list[2], 1]
}
handle_thick_dict = {1 : [self.points_list[2], self.points_list[7], 1],
2 : [self.points_list[1], self.points_list[6], 1],
3 : [self.points_list[0], self.points_list[5], 1],
4 : [[self.points_list[7], self.points_list[4], 2],
[self.points_list[2], self.points_list[4], 2]],
5 : [[self.points_list[6], self.points_list[8], 2],
[self.points_list[1], self.points_list[8], 2]],
6 : [[self.points_list[5], self.points_list[3], 2],
[self.points_list[0], self.points_list[3], 2]],
7 : [self.points_list[7], self.points_list[2], 1],
8 : [self.points_list[6], self.points_list[1], 1],
9 : [self.points_list[5], self.points_list[0], 1]
}
# Length handle
if self.attach_point in [2, 5, 8]:
handles_param = handle_length_dict[self.attach_point]
for ensemble in handles_param:
handle_pnt, base_pnt, factor = ensemble
self.handles_prop.append(Handle("ColumnLengthHandle",
handle_pnt,
base_pnt,
"ColumnLength",
HandleDirection.X_DIR,
"Longueur",
factor
)
)
else:
handle_pnt, base_pnt, factor = handle_length_dict[self.attach_point]
self.handles_prop.append(Handle("ColumnLengthHandle",
handle_pnt,
base_pnt,
"ColumnLength",
HandleDirection.X_DIR,
"Longueur",
factor
)
)
# Thickness handle
if self.attach_point in [4, 5, 6]:
handles_param = handle_thick_dict[self.attach_point]
for ensemble in handles_param:
handle_pnt, base_pnt, factor = ensemble
self.handles_prop.append(Handle("ColumnThickHandle",
handle_pnt,
base_pnt,
"ColumnThick",
HandleDirection.Y_DIR,
"Largeur",
factor
)
)
else:
handle_pnt, base_pnt, factor = handle_thick_dict[self.attach_point]
self.handles_prop.append(Handle("ColumnThickHandle",
handle_pnt,
base_pnt,
"ColumnThick",
HandleDirection.Y_DIR,
"Largeur",
factor
)
)
def calcul_dimensions(self) -> tuple:
err, volume, surface, center_of_gravity = Geometry.CalcMass(self.geo)
volume = volume * 1e-9
length = self.column_length * 1e-3
thickness = self.column_thick * 1e-3
radius = 0
height = self.column_height * 1e-3
surface = length * thickness
return (length, thickness, radius, height, surface, volume)
def create_geo(self) -> Geometry.BRep3D: