Using connectAllOpenPaths()

Hi, I’m trying to use the layer.connectAllOpenPaths() and nothing is actually happening, nor is there an error message in the Macro Panel.
Selecting by hand my paths and right clicking Close Open Paths in the context menu does work.

What am I missing?

code snippet: (just last line doesn’t do anything)

addToLayer = NSMutableArray.array()

for path in thisLayer.paths:
	newPath = GSPath()
	newPath = path.copy()
	for node in newPath.nodes:
		node.x += shiftX
		node.y += shiftY

for path in addToLayer:

for path in thisLayer.paths:
	path.selected = True


Maybe you could use this:

for path in thisLayer.paths:

But for me connectAllOpenPaths is also not doing anything.

That function is for connecting open path ends that are already on top of each other, like in this case:



Are both functions the same? -
Close Open Paths and layer.connectAllOpenPaths()?

No. One closes open paths, the other reconnects open path ends with identical coordinates.

Oh, in that case I have 2 questions:

  1. Is there a way to access via script the ‘Close Open Paths’?
  2. thisLayer.connectAllOpenPaths() still does nothing in my code, for instance on these nodes:
    Is there another import I should include or am I calling it wrong?

The open pieces seem to be double and overlap the normal outline. Can you double click next the the curve and Cmd+Arrow right move the selection? I suspect that it is a full outline and some unneeded pieces will be left.

Sadly- none found :frowning:
Also- is seems to work as one unit, shifting all together nicely.
just not actually closing. (nor is thisLayer.correctPathDirection() doing anything- thought that might help…)

Is there somewhere (couldn’t find) I can see how it’s done in OffsetCurve filter? Although the filter itself doesn’t answer what I need exactly, maybe it’s close?

I think this might be due to adding a path manually and maybe doing it wrong?

connectingPaths = NSMutableArray.array()

for path in thisLayer.paths:

	# create a two-point path with the first nodes:
	connectingPath1 = GSPath()
	n1 = newPath.nodes[0]
	n2 = path.nodes[0]
	# add the path to the layer

	for path in connectingPaths:

Why are you doing this? Who does the path look before you do this?

The main objective is to create a version of BoradNibber for Hebrew glyphs.
In Hebrew the contrast is in an opposite direction to the one found in Latin glyphs, and BroadNibber can’t seem to handle that (tried originally to tweak the open code for that).
After some rounds of coding, I decided to try and code it myself (mainly- not using the OffsetCurve Filter, which seems to be the main problem for the flipped contrast).

Attached are two screenshots:

  1. prior to creating the path, connecting the first and last nodes (just duplicated and shifted the original)
  2. after creating the path from the 2 nodes, prior to trying to draw the path (as in the snippet above). This has an effect on the lower nodes some how, they look a bit off.

It seems that the copying or the reversing of the paths was not done correctly. You see the strange direction of the end node indicators (the blue line and the arrow)?

Can you show the full code? Do you have it on GitHub already?

You can change the angle in Broadnibber.

Yes, tried that as a starting point, and it still didn’t work properly- the output looked off in a Hebrew context.
Also tried to change the rotation matrix (worked better, not enough though)

Not on git yet, but I can DM it to you shortly.


Can you post a screenshot of the layer before you run the script?

This is the original path:

This is the outcome of running the script of copying the path, without creating the connecting paths the first and last nodes (just duplicated and shifted the original)

The funny arrows you noted only appear after creating the connecting paths (even without adding them to the layer paths yet, just declaring and initializing them)


I send you a “fixed” version of your script via DM. It is much simpler then you think :wink:

Oh my… that was simple…

I’m pasting here two notes that I think were helpful, for future searches on how to add nodes to a path

so instead of :
connectingPath1.addNode(n2) and then connectingPaths.append(connectingPath1)

here the solution Georg suggested was using python’s list.extened() :

also - if a path is copied and you with to connect it to the original - it should be reversed - newPath.reverse()

Thank you so so much.