Skip to content

Import Spatial and MeshInstance #191

Closed

Description

@filantus

Hi! Thank you for so precious project!

Can you please help with problem which i have?

I am have trying use python script with Spatial node, but got error:

from godot import exposed, export
from godot import *


@exposed
class Scene3D(Spatial):
    def _ready(self):
        pass
Pythonscript 0.30.0 (CPython 3.7.1.final.0)
Got exception loading res://Scene3D.py (Scene3D): Traceback (most recent call last):
  File "build\windows-64\pythonscript\_godot_script.pxi", line 170, in _godot.pythonscript_script_init
  File "d:/Data/Dev/Godot/Python-test\Scene3D.py", line 6, in <module>
    class Scene3D(Spatial):
NameError: name 'Spatial' is not defined
from godot import exposed, export, Spatial


@exposed
class Scene3D(Spatial):
    def _ready(self):
        pass
Pythonscript 0.30.0 (CPython 3.7.1.final.0)
Got exception loading res://Scene3D.py (Scene3D): Traceback (most recent call last):
  File "build\windows-64\pythonscript\_godot_script.pxi", line 170, in _godot.pythonscript_script_init
  File "d:/Data/Dev/Godot/Python-test\Scene3D.py", line 1, in <module>
    from godot import exposed, export, Spatial
ImportError: cannot import name 'Spatial' from 'godot' (d:\Data\Dev\Godot\Python-test\addons\pythonscript\windows-64\lib\site-packages\godot\__init__.py)

With MeshInstance node i got same:

from godot import exposed, export
from godot import *


@exposed
class Cube(MeshInstance):
    def _ready(self):
        pass
Got exception loading res://Cube.py (Cube): Traceback (most recent call last):
  File "build\windows-64\pythonscript\_godot_script.pxi", line 170, in _godot.pythonscript_script_init
  File "d:/Data/Dev/Godot/Python-test\Cube.py", line 6, in <module>
    class Cube(MeshInstance):
NameError: name 'MeshInstance' is not defined

Although in Pong example all works fine. Node2D - works.

If i change root node type from Spatial to Node, and tring get MeshInstance node with help self.get_child(0) then i get:

from godot import exposed, export
from godot import *


@exposed
class Scene3D(Node):
    def _ready(self):
        print(self.get_child(0))
Pythonscript 0.30.0 (CPython 3.7.1.final.0)
Traceback (most recent call last):
  File "build\windows-64\pythonscript\_godot_instance.pxi", line 98, in _godot.pythonscript_instance_call_method
  File "d:/Data/Dev/Godot/Python-test\Scene3D.py", line 19, in _ready
    print(self.get_child(0))
  File "build\windows-64\pythonscript\godot\bindings.pyx", line 2427, in godot.bindings.Node.get_child
  File "build\windows-64\pythonscript\godot\bindings.pyx", line 94, in godot.bindings.Object.cast_from_ptr
KeyError: 'MeshInstance'

Software versions that i'm using:
OS: Win10x64
Godot: v3.2-stable_win64
Godot-python: 0.30.0-windows-64

Activity

  1. touilleMan commented on Jun 1, 2020

    @touilleMan
    Owner

    Thanks for pointing this out ;-)

    It seems v0.30.0 has been released with bindings_generate_sample=True (so with only a subset of the entire GDnative API)... with the pythonscript.gdnlib having broken path, this release was a really bad one ! 😄

    I'm going to release a new version today to fix this ;-)

  2. filantus commented on Jun 1, 2020

    @filantus
    Author

    Thank you for answer!

    Well, then i'll be waiting for the next release. 😃

    Thank you for great work!

  3. touilleMan commented on Jun 1, 2020

    @touilleMan
    Owner

    version 0.40.0 has been released (might take some time until it is validated to come on the asset store, in the meantime there is the releases page)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions