2727using System . IO ;
2828using System . Collections . Generic ;
2929using System . Linq ;
30+ using BH . Engine . Base ;
3031
3132namespace BH . Adapter . MidasCivil
3233{
@@ -42,67 +43,68 @@ private bool CreateCollection(IEnumerable<BarVaryingDistributedLoad> barVaryingD
4243
4344 foreach ( BarVaryingDistributedLoad barVaryingDistributedLoad in barVaryingDistributedLoads )
4445 {
45- if ( ! barVaryingDistributedLoad . RelativePositions )
46+ BarVaryingDistributedLoad load = barVaryingDistributedLoad . ShallowClone ( ) ;
47+ if ( ! load . RelativePositions )
4648 {
4749 Engine . Base . Compute . RecordError ( "The midas adapter can only handle BarVaryingDistributedLoads with relative positions. Please update the loads to be set with this format." ) ;
4850 continue ;
4951 }
5052
51- if ( barVaryingDistributedLoad . StartPosition >= barVaryingDistributedLoad . EndPosition )
53+ if ( load . StartPosition >= load . EndPosition )
5254 {
5355 Engine . Base . Compute . RecordError ( "Midas civil only supports start positions less than end positions for BarVaryingDistributedLoads." ) ;
5456 continue ;
5557 }
5658
5759 List < string > midasBarLoads = new List < string > ( ) ;
58- string barLoadPath = CreateSectionFile ( barVaryingDistributedLoad . Loadcase . Name + "\\ BEAMLOAD" ) ;
59- string midasLoadGroup = Adapters . MidasCivil . Convert . FromLoadGroup ( barVaryingDistributedLoad ) ;
60+ string barLoadPath = CreateSectionFile ( load . Loadcase . Name + "\\ BEAMLOAD" ) ;
61+ string midasLoadGroup = Adapters . MidasCivil . Convert . FromLoadGroup ( load ) ;
6062
61- List < string > assignedBars = barVaryingDistributedLoad . Objects . Elements . Select ( x => x . AdapterId < string > ( typeof ( MidasCivilId ) ) ) . ToList ( ) ;
63+ List < string > assignedBars = load . Objects . Elements . Select ( x => x . AdapterId < string > ( typeof ( MidasCivilId ) ) ) . ToList ( ) ;
6264
63- List < double > startLoadVectors = new List < double > { barVaryingDistributedLoad . ForceAtStart . X ,
64- barVaryingDistributedLoad . ForceAtStart . Y ,
65- barVaryingDistributedLoad . ForceAtStart . Z ,
66- barVaryingDistributedLoad . MomentAtStart . X ,
67- barVaryingDistributedLoad . MomentAtStart . Y ,
68- barVaryingDistributedLoad . MomentAtStart . Z } ;
65+ List < double > startLoadVectors = new List < double > { load . ForceAtStart . X ,
66+ load . ForceAtStart . Y ,
67+ load . ForceAtStart . Z ,
68+ load . MomentAtStart . X ,
69+ load . MomentAtStart . Y ,
70+ load . MomentAtStart . Z } ;
6971
70- List < double > endLoadVectors = new List < double > { barVaryingDistributedLoad . ForceAtEnd . X ,
71- barVaryingDistributedLoad . ForceAtEnd . Y ,
72- barVaryingDistributedLoad . ForceAtEnd . Z ,
73- barVaryingDistributedLoad . MomentAtEnd . X ,
74- barVaryingDistributedLoad . MomentAtEnd . Y ,
75- barVaryingDistributedLoad . MomentAtEnd . Z } ;
72+ List < double > endLoadVectors = new List < double > { load . ForceAtEnd . X ,
73+ load . ForceAtEnd . Y ,
74+ load . ForceAtEnd . Z ,
75+ load . MomentAtEnd . X ,
76+ load . MomentAtEnd . Y ,
77+ load . MomentAtEnd . Z } ;
7678
7779 Vector zeroVector = new Vector { X = 0 , Y = 0 , Z = 0 } ;
7880
7981 for ( int i = 0 ; i < 6 ; i ++ )
8082 {
81- barVaryingDistributedLoad . ForceAtStart = zeroVector ;
82- barVaryingDistributedLoad . MomentAtStart = zeroVector ;
83- barVaryingDistributedLoad . ForceAtEnd = zeroVector ;
84- barVaryingDistributedLoad . MomentAtEnd = zeroVector ;
83+ load . ForceAtStart = zeroVector ;
84+ load . MomentAtStart = zeroVector ;
85+ load . ForceAtEnd = zeroVector ;
86+ load . MomentAtEnd = zeroVector ;
8587
8688 if ( ! ( startLoadVectors [ i ] == 0 && endLoadVectors [ i ] == 0 ) )
8789 {
8890 if ( i < 3 )
8991 {
90- barVaryingDistributedLoad . ForceAtStart = CreateSingleComponentVector ( i , startLoadVectors [ i ] ) ;
91- barVaryingDistributedLoad . ForceAtEnd = CreateSingleComponentVector ( i , endLoadVectors [ i ] ) ;
92+ load . ForceAtStart = CreateSingleComponentVector ( i , startLoadVectors [ i ] ) ;
93+ load . ForceAtEnd = CreateSingleComponentVector ( i , endLoadVectors [ i ] ) ;
9294
9395 foreach ( string assignedBar in assignedBars )
9496 {
95- midasBarLoads . Add ( Adapters . MidasCivil . Convert . FromBarVaryingDistributedLoad ( barVaryingDistributedLoad , assignedBar , "Force" , m_forceUnit , m_lengthUnit ) ) ;
97+ midasBarLoads . Add ( Adapters . MidasCivil . Convert . FromBarVaryingDistributedLoad ( load , assignedBar , "Force" , m_forceUnit , m_lengthUnit ) ) ;
9698 }
9799 }
98100 else
99101 {
100- barVaryingDistributedLoad . MomentAtStart = CreateSingleComponentVector ( i - 3 , startLoadVectors [ i ] ) ;
101- barVaryingDistributedLoad . MomentAtEnd = CreateSingleComponentVector ( i - 3 , endLoadVectors [ i ] ) ;
102+ load . MomentAtStart = CreateSingleComponentVector ( i - 3 , startLoadVectors [ i ] ) ;
103+ load . MomentAtEnd = CreateSingleComponentVector ( i - 3 , endLoadVectors [ i ] ) ;
102104
103105 foreach ( string assignedBar in assignedBars )
104106 {
105- midasBarLoads . Add ( Adapters . MidasCivil . Convert . FromBarVaryingDistributedLoad ( barVaryingDistributedLoad , assignedBar , "Moment" , m_forceUnit , m_lengthUnit ) ) ;
107+ midasBarLoads . Add ( Adapters . MidasCivil . Convert . FromBarVaryingDistributedLoad ( load , assignedBar , "Moment" , m_forceUnit , m_lengthUnit ) ) ;
106108 }
107109 }
108110
0 commit comments