midas-civil 0.1.5__py3-none-any.whl → 0.1.7__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of midas-civil might be problematic. Click here for more details.

midas_civil/__init__.py CHANGED
@@ -23,6 +23,8 @@ from ._view import *
23
23
  from ._movingload import*
24
24
  from ._settlement import*
25
25
 
26
+
27
+
26
28
  print('')
27
29
  print('*'*20,' MIDAS CIVIL-NX PYTHON LIBRARY 🐍 ','*'*20)
28
30
  print('')
midas_civil/_boundary.py CHANGED
@@ -10,6 +10,16 @@ def convList(item):
10
10
  return item
11
11
 
12
12
 
13
+ # ----- Extend for list of nodes/elems -----
14
+
15
+ def _ADD_Support(self):
16
+ if isinstance(self.NODE,int):
17
+ Boundary.Support.sups.append(self)
18
+ elif isinstance(self.NODE,list):
19
+ for nID in self.NODE:
20
+ Boundary.Support(nID,self.CONST,self.GROUP)
21
+
22
+
13
23
  class Boundary:
14
24
 
15
25
  @classmethod
@@ -67,7 +77,7 @@ class Boundary:
67
77
  self.CONST = string
68
78
  self.GROUP = group
69
79
  self.ID = len(Boundary.Support.sups) + 1
70
- Boundary.Support.sups.append(self)
80
+ _ADD_Support(self)
71
81
 
72
82
  @classmethod
73
83
  def json(cls):
@@ -416,4 +416,568 @@ class CS:
416
416
  def delete(cls):
417
417
  """Deletes all construction stages from the database and resets the class"""
418
418
  cls.stages = []
419
- return MidasAPI("DELETE", "/db/stag")
419
+ return MidasAPI("DELETE", "/db/stag")
420
+
421
+ #-----------------------------------------------------------Comp Section for CS--------------------------------------------------------------
422
+
423
+ class CompSec:
424
+ compsecs = []
425
+
426
+ def __init__(self,
427
+ activation_stage: str,
428
+ section_id: int,
429
+ comp_type: str = "GENERAL",
430
+ tapered_type: bool = False,
431
+ partinfo: list = None,
432
+ id: int = None):
433
+ """
434
+ Parameters:
435
+ activation_stage: Active Stage name (required)
436
+ section_id: Section ID (required)
437
+ comp_type: Composite Type - "GENERAL" or "USER" (default "GENERAL")
438
+ tapered_type: Tapered Type - True or False (default False)
439
+ partinfo: List of part information lists (required)
440
+ id: The composite section ID (optional)
441
+
442
+ Part Info Format:
443
+ Each part should be a list with elements in order:
444
+ [part_number, material_type, material_id, composite_stage, age,
445
+ height, volume_surface_ratio, module_exposed_surface, area,
446
+ asy, asz, ixx, iyy, izz, warea, iw]
447
+
448
+ - part_number: Integer (required)
449
+ - material_type: "ELEM" or "MATL" (required)
450
+ - material_id: String (optional, blank for ELEM)
451
+ - composite_stage: String (optional, blank for active stage)
452
+ - age: Number (default 0)
453
+ - height: Number (default AUTO)
454
+ - volume_surface_ratio: Number (default 0)
455
+ - module_exposed_surface: Number (default 0)
456
+ - area: Number (default 1)
457
+ - asy: Number (default 1)
458
+ - asz: Number (default 1)
459
+ - ixx: Number (default 1)
460
+ - iyy: Number (default 1)
461
+ - izz: Number (default 1)
462
+ - warea: Number (default 1)
463
+ - iw: Number (default 1)
464
+
465
+ Examples:
466
+ ```python
467
+ # Basic composite section
468
+ CompSec("CS1", 1, "GENERAL", False, [
469
+ [1, "ELEM", "", "", 2, 1.5, 1.5, 1, 1, 1, 1, 1, 1, 1, 1, 1],
470
+ [2, "MATL", "3", "CS2", 5, 0.245, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1]
471
+ ])
472
+
473
+ # With minimal part info (using defaults)
474
+ CompSec("CS1", 2, "GENERAL", False, [
475
+ [1, "ELEM"],
476
+ [2, "MATL", "2","CS2"]
477
+ ])
478
+ ```
479
+ """
480
+
481
+ self.ASTAGE = activation_stage
482
+ self.SEC = section_id
483
+ self.TYPE = comp_type
484
+ self.bTAP = tapered_type
485
+
486
+ # Set ID
487
+ if id is None:
488
+ self.ID = len(CS.CompSec.compsecs) + 1
489
+ else:
490
+ self.ID = id
491
+
492
+ # Process part information
493
+ self.vPARTINFO = []
494
+
495
+ if partinfo is None:
496
+ raise ValueError("Part information is required")
497
+
498
+ if not isinstance(partinfo, list):
499
+ raise ValueError("Part information must be a list of lists")
500
+
501
+ for part_data in partinfo:
502
+ if not isinstance(part_data, list) or len(part_data) < 2:
503
+ raise ValueError("Each part must be a list with at least part number and material type")
504
+
505
+ # Default values for part info
506
+ defaults = [
507
+ None, # PART (required)
508
+ None, # MTYPE (required)
509
+ "", # MAT
510
+ "", # CSTAGE
511
+ 0, # AGE
512
+ "AUTO", # PARTINFO_H
513
+ 0, # PARTINFO_VS
514
+ 0, # PARTINFO_M
515
+ 1, # AREA
516
+ 1, # ASY
517
+ 1, # ASZ
518
+ 1, # IXX
519
+ 1, # IYY
520
+ 1, # IZZ
521
+ 1, # WAREA
522
+ 1 # IW
523
+ ]
524
+
525
+ # Fill in provided values
526
+ for i, value in enumerate(part_data):
527
+ if i < len(defaults):
528
+ defaults[i] = value
529
+
530
+ # Validate required fields
531
+ if defaults[0] is None:
532
+ raise ValueError("Part number is required")
533
+ if defaults[1] is None:
534
+ raise ValueError("Material type is required")
535
+ if defaults[1] not in ["ELEM", "MATL"]:
536
+ raise ValueError("Material type must be 'ELEM' or 'MATL'")
537
+
538
+ # Create part info dictionary
539
+ part_info = {
540
+ "PART": defaults[0],
541
+ "MTYPE": defaults[1],
542
+ "MAT": defaults[2],
543
+ "CSTAGE": defaults[3],
544
+ "AGE": defaults[4],
545
+ "PARTINFO_H": defaults[5],
546
+ "PARTINFO_VS": defaults[6],
547
+ "PARTINFO_M": defaults[7],
548
+ "AREA": defaults[8],
549
+ "ASY": defaults[9],
550
+ "ASZ": defaults[10],
551
+ "IXX": defaults[11],
552
+ "IYY": defaults[12],
553
+ "IZZ": defaults[13],
554
+ "WAREA": defaults[14],
555
+ "IW": defaults[15]
556
+ }
557
+
558
+ self.vPARTINFO.append(part_info)
559
+
560
+ CS.CompSec.compsecs.append(self)
561
+
562
+ @classmethod
563
+ def json(cls):
564
+ """
565
+ Converts Composite Section data to JSON format
566
+ Example:
567
+ # Get the JSON data for all composite sections
568
+ json_data = CS.CompSec.json()
569
+ print(json_data)
570
+ """
571
+ json_data = {"Assign": {}}
572
+
573
+ for compsec in cls.compsecs:
574
+ section_data = {
575
+ "SEC": compsec.SEC,
576
+ "ASTAGE": compsec.ASTAGE,
577
+ "TYPE": compsec.TYPE,
578
+ "bTAP": compsec.bTAP,
579
+ "vPARTINFO": compsec.vPARTINFO
580
+ }
581
+
582
+ json_data["Assign"][str(compsec.ID)] = section_data
583
+
584
+ return json_data
585
+
586
+ @classmethod
587
+ def create(cls):
588
+ """Creates composite sections in the database"""
589
+ return MidasAPI("PUT", "/db/cscs", cls.json())
590
+
591
+ @classmethod
592
+ def get(cls):
593
+ """Gets composite section data from the database"""
594
+ return MidasAPI("GET", "/db/cscs")
595
+
596
+ @classmethod
597
+ def sync(cls):
598
+ """Updates the CompSec class with data from the database"""
599
+ cls.compsecs = []
600
+ response = cls.get()
601
+
602
+ if response != {'message': ''}:
603
+ if "CSCS" in response:
604
+ cscs_data_dict = response["CSCS"]
605
+ else:
606
+ return
607
+
608
+ for cscs_id, cscs_data in cscs_data_dict.items():
609
+ # Basic section data
610
+ astage = cscs_data.get("ASTAGE")
611
+ sec = cscs_data.get("SEC")
612
+ comp_type = cscs_data.get("TYPE", "GENERAL")
613
+ tapered_type = cscs_data.get("bTAP", False)
614
+ partinfo_data = cscs_data.get("vPARTINFO", [])
615
+
616
+ # Convert partinfo from dict format to list format
617
+ partinfo = []
618
+ for part in partinfo_data:
619
+ part_list = [
620
+ part.get("PART"),
621
+ part.get("MTYPE"),
622
+ part.get("MAT", ""),
623
+ part.get("CSTAGE", ""),
624
+ part.get("AGE", 0),
625
+ part.get("PARTINFO_H", "AUTO"),
626
+ part.get("PARTINFO_VS", 0),
627
+ part.get("PARTINFO_M", 0),
628
+ part.get("AREA", 1),
629
+ part.get("ASY", 1),
630
+ part.get("ASZ", 1),
631
+ part.get("IXX", 1),
632
+ part.get("IYY", 1),
633
+ part.get("IZZ", 1),
634
+ part.get("WAREA", 1),
635
+ part.get("IW", 1)
636
+ ]
637
+ partinfo.append(part_list)
638
+
639
+ # Create a new CompSec object
640
+ new_compsec = CS.CompSec(
641
+ activation_stage=astage,
642
+ section_id=sec,
643
+ comp_type=comp_type,
644
+ tapered_type=tapered_type,
645
+ partinfo=partinfo,
646
+ id=int(cscs_id)
647
+ )
648
+
649
+ # Remove the automatically added instance and replace with synced data
650
+ CS.CompSec.compsecs.pop()
651
+ CS.CompSec.compsecs.append(new_compsec)
652
+
653
+ @classmethod
654
+ def delete(cls):
655
+ """Deletes all composite sections from the database and resets the class"""
656
+ cls.compsecs = []
657
+ return MidasAPI("DELETE", "/db/cscs")
658
+
659
+
660
+ #-----------------------------------------------------------------------------------------------------------------------------------
661
+
662
+ class TimeLoads:
663
+ timeloads = []
664
+
665
+ def __init__(self,
666
+ element_id: int,
667
+ day: int,
668
+ group: str = "",
669
+ id: int = None):
670
+ """
671
+ Time Loads for Construction Stage define.
672
+
673
+ Parameters:
674
+ element_id: Element ID (required)
675
+ day: Time Loads in days (required)
676
+ group: Load Group Name (optional, default blank)
677
+ id: The time loads ID (optional)
678
+
679
+ Examples:
680
+ ```python
681
+ CS.TimeLoads(10, 35, "DL")
682
+ ```
683
+ """
684
+
685
+ self.ELEMENT_ID = element_id
686
+ self.DAY = day
687
+ self.GROUP_NAME = group
688
+
689
+ # Set ID
690
+ if id is None:
691
+ self.ID = len(CS.TimeLoads.timeloads) + 1
692
+ else:
693
+ self.ID = id
694
+
695
+ CS.TimeLoads.timeloads.append(self)
696
+
697
+ @classmethod
698
+ def json(cls):
699
+ """
700
+ Converts Time Loads data to JSON format
701
+ Example:
702
+ # Get the JSON data for all time loads
703
+ json_data = CS.TimeLoads.json()
704
+ print(json_data)
705
+ """
706
+ json_data = {"Assign": {}}
707
+
708
+ for timeload in cls.timeloads:
709
+ items_data = {
710
+ "ITEMS": [
711
+ {
712
+ "ID": 1,
713
+ "GROUP_NAME": timeload.GROUP_NAME,
714
+ "DAY": timeload.DAY
715
+ }
716
+ ]
717
+ }
718
+
719
+ json_data["Assign"][str(timeload.ELEMENT_ID)] = items_data
720
+
721
+ return json_data
722
+
723
+ @classmethod
724
+ def create(cls):
725
+ """Creates time loads in the database"""
726
+ return MidasAPI("PUT", "/db/tmld", cls.json())
727
+
728
+ @classmethod
729
+ def get(cls):
730
+ """Gets time loads data from the database"""
731
+ return MidasAPI("GET", "/db/tmld")
732
+
733
+ @classmethod
734
+ def sync(cls):
735
+ """Updates the TimeLoads class with data from the database"""
736
+ cls.timeloads = []
737
+ response = cls.get()
738
+
739
+ if response != {'message': ''}:
740
+ if "TMLD" in response:
741
+ stbk_data_dict = response["TMLD"]
742
+ else:
743
+ return
744
+
745
+ for element_id, stbk_data in stbk_data_dict.items():
746
+ items = stbk_data.get("ITEMS", [])
747
+
748
+ for item in items:
749
+ group_name = item.get("GROUP_NAME", "")
750
+ day = item.get("DAY", 0)
751
+ item_id = item.get("ID", 1)
752
+
753
+ # Create a new TimeLoads object
754
+ new_timeload = CS.TimeLoads(
755
+ element_id=int(element_id),
756
+ day=day,
757
+ group=group_name,
758
+ id=item_id
759
+ )
760
+
761
+ # Remove the automatically added instance and replace with synced data
762
+ CS.TimeLoads.timeloads.pop()
763
+ CS.TimeLoads.timeloads.append(new_timeload)
764
+
765
+ @classmethod
766
+ def delete(cls):
767
+ """Deletes all time loads from the database and resets the class"""
768
+ cls.timeloads = []
769
+ return MidasAPI("DELETE", "/db/tmld")
770
+
771
+ class CreepCoeff:
772
+ creepcoeffs = []
773
+
774
+ def __init__(self,
775
+ element_id: int,
776
+ creep: float,
777
+ group: str = "",
778
+ id: int = None):
779
+ """
780
+ Creep Coefficient for Construction Stage define.
781
+
782
+ Parameters:
783
+ element_id: Element ID (required)
784
+ creep: Creep Coefficient value (required)
785
+ group: Load Group Name (optional, default blank)
786
+ id: The creep coefficient ID (optional)
787
+
788
+ Examples:
789
+ ```python
790
+ # Basic creep coefficient
791
+ CS.CreepCoeff(25, 1.2)
792
+
793
+ # With specific ID & Group
794
+ CS.CreepCoeff(26, 1.5, "GR", id=2)
795
+ ```
796
+ """
797
+
798
+ self.ELEMENT_ID = element_id
799
+ self.CREEP = creep
800
+ self.GROUP_NAME = group
801
+
802
+ # Set ID
803
+ if id is None:
804
+ self.ID = len(CS.CreepCoeff.creepcoeffs) + 1
805
+ else:
806
+ self.ID = id
807
+
808
+ CS.CreepCoeff.creepcoeffs.append(self)
809
+
810
+ @classmethod
811
+ def json(cls):
812
+ """
813
+ Converts Creep Coefficient data to JSON format
814
+ Example:
815
+ # Get the JSON data for all creep coefficients
816
+ json_data = CS.CreepCoeff.json()
817
+ print(json_data)
818
+ """
819
+ json_data = {"Assign": {}}
820
+
821
+ for creepcoeff in cls.creepcoeffs:
822
+ items_data = {
823
+ "ITEMS": [
824
+ {
825
+ "ID": 1,
826
+ "GROUP_NAME": creepcoeff.GROUP_NAME,
827
+ "CREEP": creepcoeff.CREEP
828
+ }
829
+ ]
830
+ }
831
+
832
+ json_data["Assign"][str(creepcoeff.ELEMENT_ID)] = items_data
833
+
834
+ return json_data
835
+
836
+ @classmethod
837
+ def create(cls):
838
+ """Creates creep coefficients in the database"""
839
+ return MidasAPI("PUT", "/db/crpc", cls.json())
840
+
841
+ @classmethod
842
+ def get(cls):
843
+ """Gets creep coefficient data from the database"""
844
+ return MidasAPI("GET", "/db/crpc")
845
+
846
+ @classmethod
847
+ def sync(cls):
848
+ """Updates the CreepCoeff class with data from the database"""
849
+ cls.creepcoeffs = []
850
+ response = cls.get()
851
+
852
+ if response != {'message': ''}:
853
+ if "CRPC" in response:
854
+ crpc_data_dict = response["CRPC"]
855
+ else:
856
+ return
857
+
858
+ for element_id, crpc_data in crpc_data_dict.items():
859
+ items = crpc_data.get("ITEMS", [])
860
+
861
+ for item in items:
862
+ group_name = item.get("GROUP_NAME", "")
863
+ creep = item.get("CREEP", 0.0)
864
+ item_id = item.get("ID", 1)
865
+
866
+ # Create a new CreepCoeff object
867
+ new_creepcoeff = CS.CreepCoeff(
868
+ element_id=int(element_id),
869
+ creep=creep,
870
+ group=group_name,
871
+ id=item_id
872
+ )
873
+
874
+ # Remove the automatically added instance and replace with synced data
875
+ CS.CreepCoeff.creepcoeffs.pop()
876
+ CS.CreepCoeff.creepcoeffs.append(new_creepcoeff)
877
+
878
+ @classmethod
879
+ def delete(cls):
880
+ """Deletes all creep coefficients from the database and resets the class"""
881
+ cls.creepcoeffs = []
882
+ return MidasAPI("DELETE", "/db/crpc")
883
+
884
+ class Camber:
885
+ cambers = []
886
+
887
+ def __init__(self,
888
+ node_id: int,
889
+ camber: float,
890
+ deform: float,
891
+ id: int = None):
892
+ """
893
+ Camber for Construction Stage define.
894
+
895
+ Parameters:
896
+ node_id: Node ID (required)
897
+ camber: User camber value (required)
898
+ deform: Deformation value (required)
899
+ id: The camber ID (optional)
900
+
901
+ Examples:
902
+ ```python
903
+
904
+ CS.Camber(25, 0.17, 0.1)
905
+ ```
906
+ """
907
+
908
+ self.NODE_ID = node_id
909
+ self.USER = camber
910
+ self.DEFORM = deform
911
+
912
+ # Set ID
913
+ if id is None:
914
+ self.ID = len(CS.Camber.cambers) + 1
915
+ else:
916
+ self.ID = id
917
+
918
+ CS.Camber.cambers.append(self)
919
+
920
+ @classmethod
921
+ def json(cls):
922
+ """
923
+ Converts Camber data to JSON format
924
+ Example:
925
+ # Get the JSON data for all cambers
926
+ json_data = CS.Camber.json()
927
+ print(json_data)
928
+ """
929
+ json_data = {"Assign": {}}
930
+
931
+ for camber in cls.cambers:
932
+ camber_data = {
933
+ "DEFORM": camber.DEFORM,
934
+ "USER": camber.USER
935
+ }
936
+
937
+ json_data["Assign"][str(camber.NODE_ID)] = camber_data
938
+
939
+ return json_data
940
+
941
+ @classmethod
942
+ def create(cls):
943
+ """Creates cambers in the database"""
944
+ return MidasAPI("PUT", "/db/cmcs", cls.json())
945
+
946
+ @classmethod
947
+ def get(cls):
948
+ """Gets camber data from the database"""
949
+ return MidasAPI("GET", "/db/cmcs")
950
+
951
+ @classmethod
952
+ def sync(cls):
953
+ """Updates the Camber class with data from the database"""
954
+ cls.cambers = []
955
+ response = cls.get()
956
+
957
+ if response != {'message': ''}:
958
+ if "CMCS" in response:
959
+ cmcs_data_dict = response["CMCS"]
960
+ else:
961
+ return
962
+
963
+ for node_id, cmcs_data in cmcs_data_dict.items():
964
+ deform = cmcs_data.get("DEFORM", 0.0)
965
+ user = cmcs_data.get("USER", 0.0)
966
+
967
+ # Create a new Camber object
968
+ new_camber = CS.Camber(
969
+ node_id=int(node_id),
970
+ camber=user,
971
+ deform=deform,
972
+ id=len(cls.cambers) + 1
973
+ )
974
+
975
+ # Remove the automatically added instance and replace with synced data
976
+ CS.Camber.cambers.pop()
977
+ CS.Camber.cambers.append(new_camber)
978
+
979
+ @classmethod
980
+ def delete(cls):
981
+ """Deletes all cambers from the database and resets the class"""
982
+ cls.cambers = []
983
+ return MidasAPI("DELETE", "/db/cmcs")