Skip to content

Commit 9639f75

Browse files
committed
Connector.makeMoorPyConnector now makes fixed point when joined:
- Created Node.isJoined method to check if a node is joined to anything. - Changed Connector.makeMoorPyConnector to check if a node is joined, in which case the MP point will be fixed rather than free.
1 parent 9eee5b6 commit 9639f75

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

famodel/famodel_base.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,19 @@ def join(self, object):
188188
raise Exception("This would attach two higher-level nodes, which is not supported.")
189189

190190

191+
def isJoined(self):
192+
'''Check if this node is joined to anything else.'''
193+
194+
for att in self.attachments.values(): # Look through everything attached
195+
object = att['obj']
196+
if isinstance(object, Node): # Only another node could be joined
197+
if self.id in object.attachments:
198+
return True
199+
200+
# If we've gotten this far, it's not joined with anything
201+
return False
202+
203+
191204
def separate(self, object):
192205
'''Opposite of join'''
193206

famodel/mooring/connector.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,14 @@ def makeMoorPyConnector(self, ms):
5959
ms : class instance
6060
MoorPy system
6161
'''
62+
63+
if self.isJoined(): # if the connector is joined to something
64+
pointType = 1 # make it a fixed point
65+
else:
66+
pointType = 0 # otherwise a free point
67+
6268
# create connector as a point in MoorPy system
63-
ms.addPoint(0,self.r)
69+
ms.addPoint(pointType, self.r)
6470

6571
# assign this point as mpConn in the anchor class instance
6672
self.mpConn = ms.pointList[-1]

0 commit comments

Comments
 (0)