Reza
April 17, 2024, 7:56am
1
Hi All
Can anybody help me
MacroTab.title = "Point Counter"
font = Glyphs.font
# Get selected glyph
for layer in font.selectedLayers:
glyph = layer.parent
print("---------- %s ----------" % glyph.name)
# count handles, nodes and paths
for layer in glyph.layers:
countPaths = 0
countOffcurves = 0
countCurves = 0
countLines = 0
for i, path in enumerate(layer.paths):
countPaths += 1
for node in path.nodes:
if node.type == "offcurve":
countOffcurves += 1
if node.type == "curve":
countCurves += 1
if node.type == "line":
countLines += 1
countPoints = countCurves + countOffcurves + countLines
countNode = countPoints - countOffcurves
print("%s All - %s handles, %s Node, %s paths - %s" % (countPoints, countOffcurves, countNode, countPaths, layer.name) )
print("")
I want add Glyphs.clearLog()
but when I add everything clear and show nothing
and this code show node for all layer. I want just master layer
Thanks
The clearLog() is broken up. 3.3. I fixed it already and will update soon.
Reza
April 17, 2024, 8:14am
3
Thanks @GeorgSeifert
Do you have any suggestion for second part (Just master layer)
mekkablue
(Rainer Erich Scheichelbauer)
April 17, 2024, 8:25am
4
if layer.isMasterLayer:
…
Reza
April 18, 2024, 11:12am
6
after update to 3301 clear log work but this script didnot work. what happend?
macro panel: File “”, line 5
NameError: name ‘glyph’ is not defined. Did you mean: ‘Glyphs’?
Reza
April 18, 2024, 12:04pm
7
MacroTab.title = "Point Counter"
Glyphs.clearLog()
font = Glyphs.font
for layer in font.selectedLayers:
print("---------- %s ----------" % glyph.name)
for layer in glyph.layers:
if layer.isMasterLayer:
countPaths = 0
countOffcurves = 0
countCurves = 0
countLines = 0
for i, path in enumerate(layer.paths):
countPaths += 1
for node in path.nodes:
if node.type == "offcurve":
countOffcurves += 1
if node.type == "curve":
countCurves += 1
if node.type == "line":
countLines += 1
countPoints = countCurves + countOffcurves + countLines
countNode = countPoints - countOffcurves
print("%s All - %s handles, %s Node, %s paths - %s" % (countPoints, countOffcurves, countNode, countPaths, layer.name) )
print("")
Reza
April 18, 2024, 12:05pm
8
Traceback (most recent call last):
File "<macro panel>", line 5
NameError: name 'glyph' is not defined. Did you mean: 'Glyphs'?
Reza
April 18, 2024, 12:06pm
9
It works before
works on 3300
SCarewe
(Sebastian Carewe)
April 18, 2024, 12:53pm
10
Your script doesn’t define the variable glyph
.
You are declaring the variable layer
twice: once as an iteration in Font.selectedLayers
and once as an iteration in glyph.layers
.
I would write:
for selection in Font.selectedLayers:
...
for layer in selection.parent.layers:
...