@@ -1099,7 +1099,7 @@ def parseYAML(self, data):
10991099
11001100
11011101 def unload (self , fileName , MDversion = 2 , line_dL = 0 , rod_dL = 0 , flag = 'p' ,
1102- outputList = [], Lm = [0 ], T_half = 42 , phi = None , dynamicStiffness = False , MDoptionsDict = {}):
1102+ outputList = [], Lm = [0 ], T_half = 42 , phi = None , dynamicStiffness = False , cleanLineTypeName = False , MDoptionsDict = {}):
11031103 '''Unloads a MoorPy system into a MoorDyn-style input file
11041104
11051105 Parameters
@@ -1125,6 +1125,8 @@ def unload(self, fileName, MDversion=2, line_dL=0, rod_dL=0, flag='p',
11251125 if true, automatically activateDynamicStiffness to calculate dynamic EA
11261126 MDoptionsDict: dictionary, optional
11271127 MoorDyn Options. If not given, default options are considered.
1128+ cleanLineTypeName: bool, optional
1129+ If true, line type names will be renamed to "type_{counter}" to avoid long names that may cause issues in MoorDyn.
11281130 Returns
11291131 -------
11301132 None.
@@ -1380,24 +1382,25 @@ def unload(self, fileName, MDversion=2, line_dL=0, rod_dL=0, flag='p',
13801382 L .append ("TypeName Diam Mass/m EA BA/-zeta EI Cd Ca CdAx CaAx" )
13811383 L .append ("(name) (m) (kg/m) (N) (N-s/-) (N-m^2) (-) (-) (-) (-)" )
13821384
1383- # Create unique short keys for the line types
1384- # build mapping from old keys → new short keys
1385- key_map = {}
1386- for i , key in enumerate (self .lineTypes .keys ()):
1387- key_map [key ] = f"type_{ i + 1 } "
1388-
1389- # update all line.type['name'] values using the mapping
1390- for line in self .lineList :
1391- old_key = line .type ['name' ]
1392- if old_key in key_map :
1393- line .type ['name' ] = key_map [old_key ]
1394-
1395- # rebuild lineTypes with the new keys
1396- new_lineTypes = {}
1397- for old_key , item in self .lineTypes .items ():
1398- new_lineTypes [key_map [old_key ]] = item
1399-
1400- self .lineTypes = new_lineTypes
1385+ if cleanLineTypeName :
1386+ # Create unique short keys for the line types
1387+ # build mapping from old keys → new short keys
1388+ key_map = {}
1389+ for i , key in enumerate (self .lineTypes .keys ()):
1390+ key_map [key ] = f"type_{ i + 1 } "
1391+
1392+ # update all line.type['name'] values using the mapping
1393+ for line in self .lineList :
1394+ old_key = line .type ['name' ]
1395+ if old_key in key_map :
1396+ line .type ['name' ] = key_map [old_key ]
1397+
1398+ # rebuild lineTypes with the new keys
1399+ new_lineTypes = {}
1400+ for old_key , item in self .lineTypes .items ():
1401+ new_lineTypes [key_map [old_key ]] = item
1402+
1403+ self .lineTypes = new_lineTypes
14011404
14021405 j = 0 # count for list of Lms
14031406 for key , lineType in self .lineTypes .items ():
0 commit comments