Finding the number of elements in a path? #167
Answered
by
ornamentist
ornamentist
asked this question in
Q&A
|
Is there a way to find the number of path "elements" or "steps" in a given path object? I'd like to be able to keep or delete path objects based on how complex they are. |
Answered by
ornamentist
Dec 12, 2025
Replies: 1 comment 1 reply
|
Yes, but you'll have to drop down to the underlying Consider a path represented in SVG as for object in all_shapes():
if object.tag != "path":
continue
iobj = object.get_inkex_object()
p = iobj.get_path()
for i, seg in enumerate(p):
print('[%d] %s' % (i + 1, seg))⇓ This same path contains 13 control points: for object in all_shapes():
if object.tag != "path":
continue
iobj = object.get_inkex_object()
p = iobj.get_path()
for i, seg in enumerate(p.control_points):
print('[%d] %s' % (i + 1, seg))⇓ Thus, you can count path commands with |
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Very neat — thanks.