Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Running script produce an error #128

Open
Almaghasilah opened this issue Jul 1, 2022 · 2 comments
Open

Running script produce an error #128

Almaghasilah opened this issue Jul 1, 2022 · 2 comments
Labels
help wanted Extra attention is needed question Further information is requested

Comments

@Almaghasilah
Copy link

Almaghasilah commented Jul 1, 2022

Hello,

I am trying to run a function from a library called Goo (https://github.com/smegason/Goo) in a Python script. Here is my code:

import bpy
from goo import goo 
from importlib import reload
reload(goo)
 
for collection in bpy.data.collections:  # loop through the existing collection
      for objs in collection.objects:
            bpy.data.objects.remove(objs)
      bpy.data.collections.remove(collection)

cA_collection = bpy.data.collections.new("A_Cells")
bpy.context.scene.collection.children.link(cA_collection)
cA1 = goo.Cell("cell_A1", loc=(2, 2, 0), flavor="ico_sphere")
goo.make_cell(cA1)
obj = bpy.context.active_object
bpy.ops.collection.objects_remove_all()
bpy.data.collections['A_Cells'].objects.link(obj)

Every time I run it, it would produce this following error

Traceback (most recent call last):
  File "/Users/ahmedalmaghasilah/.vscode/extensions/jacqueslucke.blender-development-0.0.17/pythonFiles/include/blender_vscode/utils.py", line 22, in always
    try: func()
  File "/Users/ahmedalmaghasilah/.vscode/extensions/jacqueslucke.blender-development-0.0.17/pythonFiles/include/blender_vscode/operators/script_runner.py", line 24, in run_script_action
    bpy.ops.dev.run_script(context, filepath=path)
  File "/Applications/Blender.app/Contents/Resources/3.2/scripts/modules/bpy/ops.py", line 113, in __call__
    ret = _op_call(self.idname_py(), C_dict, kw, C_exec, C_undo)
RuntimeError: Error: Python: Traceback (most recent call last):
  File "/Users/ahmedalmaghasilah/.vscode/extensions/jacqueslucke.blender-development-0.0.17/pythonFiles/include/blender_vscode/operators/script_runner.py", line 16, in execute
    runpy.run_path(self.filepath, init_globals={"CTX" : ctx})
  File "/Applications/Blender.app/Contents/Resources/3.2/python/lib/python3.10/runpy.py", line 269, in run_path
    return _run_module_code(code, init_globals, run_name,
  File "/Applications/Blender.app/Contents/Resources/3.2/python/lib/python3.10/runpy.py", line 96, in _run_module_code
    _run_code(code, mod_globals, init_globals,
  File "/Applications/Blender.app/Contents/Resources/3.2/python/lib/python3.10/runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "/Users/ahmedalmaghasilah/Desktop/Blender/Goo/scripts/modules/goo/sample_codes.py", line 30, in <module>
    goo.make_cell(cA1)
  File "/Users/ahmedalmaghasilah/Desktop/Blender/Goo/scripts/modules/goo/goo.py", line 568, in make_cell
    bpy.context.object.name = cell.data['name']
AttributeError: 'NoneType' object has no attribute 'name'
Location: /Applications/Blender.app/Contents/Resources/3.2/scripts/modules/bpy/ops.py:113`

However, when I run it on Blender's Scripting tab, it runs fine and never produce the error above.

I am wondering if anyone has the same issue before.

@Almaghasilah Almaghasilah changed the title Error with running script Running script produce an error Jul 1, 2022
@Griperis
Copy link
Collaborator

Hi @Almaghasilah,
this seems like issue of the goo library. You can see that in the output the function make_cell expected some cell.data to exist, but it is None.

  File "/Users/ahmedalmaghasilah/Desktop/Blender/Goo/scripts/modules/goo/goo.py", line 568, in make_cell
    bpy.context.object.name = cell.data['name']
AttributeError: 'NoneType' object has no attribute 'name'

@Mateusz-Grzelinski Mateusz-Grzelinski added help wanted Extra attention is needed invalid This doesn't seem right question Further information is requested labels Aug 11, 2024
@Mateusz-Grzelinski
Copy link
Collaborator

it might be the limitation of current running script implementation. But I do not have time to investigate it.

class RunScriptOperator(bpy.types.Operator):
    def execute(self, context):
        ctx = prepare_script_context(self.filepath)
        runpy.run_path(self.filepath, init_globals={"CTX": ctx})
        redraw_all()
        return {"FINISHED"}

@Mateusz-Grzelinski Mateusz-Grzelinski removed the invalid This doesn't seem right label Aug 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants