How can I check what the type of layer.shapes?


How can I get the shape type value between GSPath and GSComponent??

layer = f.selectedLayers[0]
for item in layer.shapes:

it shows between these two types.
<objective-c class GSComponent at ~>
<objective-c class GSPath at ~>

I want to know how to get the shape type like ‘GSShapeTypeComponent’, ‘GSPath’ to check whether the shape is a path or a component.


Check the shapeType, it is either GSShapeTypePath or GSShapeTypeComponent.

How can I check it with script?
Is it possible like below code?

print(layer.shapes[0].shapeType == GSShapeTypeComponent)

You must call shapeType, like so:

Ah, the document wrote ‘shapeType’ is in ‘properties’. In your reply, it is a method(function).

Thanks a lot!

I think the Python wrapper is missing some parts here. For example, position on GSShape is wrapped for GSPath but not for GSComponent.

/cc @GeorgSeifert

That is strange. For some properties it is enough to define them on the superclass (GSShape). E.g. .locked is set for GSShape and GSComponent but works for GSPath, too. I’ll fix it.

But with position, it is the other way around. And position doesn’t make much sense for paths.

in 3.0.3(3073),
‘shapeType’ has changed to ‘bool’ type. Is it right?
Instead of ‘shapeType’, it can be checked with ‘type()’ function like below.

for shape in layer.shapes:
    print(type(shape) == GSComponent)
  	print(type(shape) == GSPath)

will it be fixed with ‘type()’ or returned to ‘shapeType’?
Or should I use layer.components and layer.paths?

Please let me know the best solution for this.
It is important for me, as I develop plugins for Hangul compositions.

Thanks in advance,