godot-python icon indicating copy to clipboard operation
godot-python copied to clipboard

Unable to pack a scene if it has Python scripts

Open dranorter opened this issue 3 years ago • 1 comments

I have a simple project with a CSGMesh and a few other nodes. The CSGMesh has a Python script, which generates a small ArrayMesh. I wanted to try exporting the scene as a packed scene once the mesh was present. However, I find that calling packed_scene.pack(get_tree().get_current_scene()) fails with the error:

Pythonscript 0.50.0 (CPython 3.8.5.final.0)
Traceback (most recent call last):
  File "build\windows-64\pythonscript\_godot_instance.pxi", line 67, in _godot.pythonscript_instance_get_prop
  File "build\windows-64\pythonscript\godot\bindings.pyx", line 244, in godot.bindings.Object.__getattr__
AttributeError: `CSGMesh` object has no attribute `_import_path`
Traceback (most recent call last):
  File "build\windows-64\pythonscript\_godot_instance.pxi", line 67, in _godot.pythonscript_instance_get_prop
  File "build\windows-64\pythonscript\godot\bindings.pyx", line 244, in godot.bindings.Object.__getattr__
AttributeError: `CSGMesh` object has no attribute `script`

This happens the same way whether I make the call within a Python script, or a GDNative script.

When inspecting the node in the Inspector, of course, it does have the property "script", whose value corresponds to a python script.

Seems somewhat related to #267.

dranorter avatar Mar 15 '21 07:03 dranorter

Hi @dranorter

I think I found the issue: Node._import_path is a property, but it getter/setter are not defined in Godot's api.json version used to build version 0.50.0 of Godot Python (I guess it was this one https://github.com/godotengine/godot-headers/blob/f2122198d51f230d903f9585527248f6cf411494/api.json)

The good news is newer version of api.json seems to have fixed this \o/ (see https://github.com/godotengine/godot-headers/blob/godot-3.2.3-stable/api.json)

touilleMan avatar Mar 27 '21 08:03 touilleMan