Hello. I am (simply said) trying the following:
I have a square (so four straight line segments). For each straight line segment, I want to open the corners of this segment and then close them again. This order is important (not open a corner, then close it, then go to the next one – both corners need to be open at the same time and then closed afterwards).
My approach is the following: for every node of the segment, open the current node and the next node, then close them both again. I am sadly failing at the last node of the path. Here is my code:
select_tool = NSClassFromString("GSToolSelect").alloc().init()
def convert_node_index(nodes, index):
new_index = index % len(nodes)
return nodes[new_index]
for path in Layer.paths:
nodecount = len(path.nodes)
index = 0
while index < nodecount: # make sure only the original number of nodes is used
# open the current node
Layer.openCornerAtNode_offset_(convert_node_index(path.nodes, index), 10)
# open the next node (whose index is one higher now)
Layer.openCornerAtNode_offset_(convert_node_index(path.nodes, index + 2), 10)
# close the first corner
select_tool._makeCorner_firstNodeIndex_endNodeIndex_(path, convert_node_index(path.nodes, index).index, convert_node_index(path.nodes, index + 1).index)
# close the second corner
select_tool._makeCorner_firstNodeIndex_endNodeIndex_(path, convert_node_index(path.nodes, index + 1).index, convert_node_index(path.nodes, index + 2).index)
# finally, increase the index by one to go to the next node
index += 1
But, for reasons incomprehensible to me, the following happens:
… when what should actually happen is that the path looks exactly the same as before.
There is something very basic wrong in my logic. I have spent far too many hours trying to debug this. Please put me out of my misery.