22
22
23
23
using BH . oM . Adapters . MidasCivil ;
24
24
using BH . Engine . Adapter ;
25
+ using BH . oM . Structure . Elements ;
25
26
using BH . oM . Structure . Loads ;
26
27
using BH . oM . Geometry ;
27
28
using System . IO ;
28
29
using System . Collections . Generic ;
29
30
using System . Linq ;
31
+ using BH . Engine . Base ;
32
+ using BH . Engine . Spatial ;
33
+ using BH . Engine . Geometry ;
34
+ using BH . Adapter . Adapters . MidasCivil ;
35
+ using System . Data ;
30
36
31
37
namespace BH . Adapter . MidasCivil
32
38
{
@@ -42,67 +48,90 @@ private bool CreateCollection(IEnumerable<BarVaryingDistributedLoad> barVaryingD
42
48
43
49
foreach ( BarVaryingDistributedLoad barVaryingDistributedLoad in barVaryingDistributedLoads )
44
50
{
45
- if ( ! barVaryingDistributedLoad . RelativePositions )
51
+ BarVaryingDistributedLoad load = barVaryingDistributedLoad . ShallowClone ( ) ;
52
+
53
+ if ( load . StartPosition >= load . EndPosition )
46
54
{
47
- Engine . Base . Compute . RecordError ( "The midas adapter can only handle BarVaryingDistributedLoads with relative positions. Please update the loads to be set with this format ." ) ;
55
+ Engine . Base . Compute . RecordError ( "MidasCivil only supports start positions less than end positions for BarVaryingDistributedLoads ." ) ;
48
56
continue ;
49
57
}
50
58
51
- if ( barVaryingDistributedLoad . StartPosition >= barVaryingDistributedLoad . EndPosition )
59
+ List < double > startPosition = new List < double > ( ) ;
60
+ List < double > endPosition = new List < double > ( ) ;
61
+
62
+
63
+ foreach ( Bar bar in load . Objects . Elements )
52
64
{
53
- Engine . Base . Compute . RecordError ( "Midas civil only supports start positions less than end positions for BarVaryingDistributedLoads." ) ;
54
- continue ;
65
+ if ( load . RelativePositions == false )
66
+ {
67
+ double length = bar . Length ( ) ;
68
+
69
+ startPosition . Add ( barVaryingDistributedLoad . StartPosition / length ) ;
70
+ endPosition . Add ( barVaryingDistributedLoad . EndPosition / length ) ;
71
+
72
+ if ( load . StartPosition / length > 1 || load . EndPosition / length > 1 )
73
+ Engine . Base . Compute . RecordError ( "The load start or end position is outside one or more bars" ) ;
74
+ }
75
+ else
76
+ {
77
+ startPosition . Add ( barVaryingDistributedLoad . StartPosition ) ;
78
+ endPosition . Add ( barVaryingDistributedLoad . EndPosition ) ;
79
+ }
55
80
}
56
81
82
+
57
83
List < string > midasBarLoads = new List < string > ( ) ;
58
- string barLoadPath = CreateSectionFile ( barVaryingDistributedLoad . Loadcase . Name + "\\ BEAMLOAD" ) ;
59
- string midasLoadGroup = Adapters . MidasCivil . Convert . FromLoadGroup ( barVaryingDistributedLoad ) ;
84
+ string barLoadPath = CreateSectionFile ( load . Loadcase . Name + "\\ BEAMLOAD" ) ;
85
+ string midasLoadGroup = Adapters . MidasCivil . Convert . FromLoadGroup ( load ) ;
86
+
87
+ List < string > assignedBars = load . Objects . Elements . Select ( x => x . AdapterId < string > ( typeof ( MidasCivilId ) ) ) . ToList ( ) ;
60
88
61
- List < string > assignedBars = barVaryingDistributedLoad . Objects . Elements . Select ( x => x . AdapterId < string > ( typeof ( MidasCivilId ) ) ) . ToList ( ) ;
62
89
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 } ;
90
+ List < double > startLoadVectors = new List < double > { load . ForceAtStart . X ,
91
+ load . ForceAtStart . Y ,
92
+ load . ForceAtStart . Z ,
93
+ load . MomentAtStart . X ,
94
+ load . MomentAtStart . Y ,
95
+ load . MomentAtStart . Z } ;
69
96
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 } ;
97
+ List < double > endLoadVectors = new List < double > { load . ForceAtEnd . X ,
98
+ load . ForceAtEnd . Y ,
99
+ load . ForceAtEnd . Z ,
100
+ load . MomentAtEnd . X ,
101
+ load . MomentAtEnd . Y ,
102
+ load . MomentAtEnd . Z } ;
76
103
77
104
Vector zeroVector = new Vector { X = 0 , Y = 0 , Z = 0 } ;
78
105
79
106
for ( int i = 0 ; i < 6 ; i ++ )
80
107
{
81
- barVaryingDistributedLoad . ForceAtStart = zeroVector ;
82
- barVaryingDistributedLoad . MomentAtStart = zeroVector ;
83
- barVaryingDistributedLoad . ForceAtEnd = zeroVector ;
84
- barVaryingDistributedLoad . MomentAtEnd = zeroVector ;
108
+ load . ForceAtStart = zeroVector ;
109
+ load . MomentAtStart = zeroVector ;
110
+ load . ForceAtEnd = zeroVector ;
111
+ load . MomentAtEnd = zeroVector ;
85
112
86
113
if ( ! ( startLoadVectors [ i ] == 0 && endLoadVectors [ i ] == 0 ) )
87
114
{
88
115
if ( i < 3 )
89
116
{
90
- barVaryingDistributedLoad . ForceAtStart = CreateSingleComponentVector ( i , startLoadVectors [ i ] ) ;
91
- barVaryingDistributedLoad . ForceAtEnd = CreateSingleComponentVector ( i , endLoadVectors [ i ] ) ;
117
+ load . ForceAtStart = CreateSingleComponentVector ( i , startLoadVectors [ i ] ) ;
118
+ load . ForceAtEnd = CreateSingleComponentVector ( i , endLoadVectors [ i ] ) ;
92
119
93
- foreach ( string assignedBar in assignedBars )
120
+ for ( int j = 0 ; j < assignedBars . Count ; j ++ )
94
121
{
95
- midasBarLoads . Add ( Adapters . MidasCivil . Convert . FromBarVaryingDistributedLoad ( barVaryingDistributedLoad , assignedBar , "Force" , m_forceUnit , m_lengthUnit ) ) ;
122
+ midasBarLoads . Add ( Adapters . MidasCivil . Convert . FromBarVaryingDistributedLoad ( load ,
123
+ assignedBars [ j ] , "Force" , m_forceUnit , m_lengthUnit , startPosition [ j ] , endPosition [ j ] ) ) ;
96
124
}
97
125
}
98
126
else
99
127
{
100
- barVaryingDistributedLoad . MomentAtStart = CreateSingleComponentVector ( i - 3 , startLoadVectors [ i ] ) ;
101
- barVaryingDistributedLoad . MomentAtEnd = CreateSingleComponentVector ( i - 3 , endLoadVectors [ i ] ) ;
128
+ load . MomentAtStart = CreateSingleComponentVector ( i - 3 , startLoadVectors [ i ] ) ;
129
+ load . MomentAtEnd = CreateSingleComponentVector ( i - 3 , endLoadVectors [ i ] ) ;
102
130
103
- foreach ( string assignedBar in assignedBars )
131
+ for ( int j = 0 ; j < assignedBars . Count ; j ++ )
104
132
{
105
- midasBarLoads . Add ( Adapters . MidasCivil . Convert . FromBarVaryingDistributedLoad ( barVaryingDistributedLoad , assignedBar , "Moment" , m_forceUnit , m_lengthUnit ) ) ;
133
+ midasBarLoads . Add ( Adapters . MidasCivil . Convert . FromBarVaryingDistributedLoad ( load ,
134
+ assignedBars [ j ] , "Moment" , m_forceUnit , m_lengthUnit , startPosition [ j ] , endPosition [ j ] ) ) ;
106
135
}
107
136
}
108
137
0 commit comments