Problem in PyQt with blender


(Py3D) #1

Hello,
I create an interface with PyQt5 Inside Blender. i embed into this interface some buttons to run my script.
My project is import a file .stl with a button from my hard drive and it works well.

self.import_btn.clicked.connect(self.importCommand)
def importCommand(self, context): 
        qfd = QFileDialog()
        title = 'Open STL file'
        path = "C:/"
        f = QFileDialog.getOpenFileName(qfd, title, path, '*.stl')
        bpy.ops.import_mesh.stl(filepath=f[0])
        Remake()
def Remake(self,context):
    main = bpy.data.objects['Main']
    main.select=True
    bpy.context.scene.objects.active= main
    bpy.ops.transform.resize(value=(1+pourcentageaugmentation, 1+pourcentageaugmentation, 1+pourcentageaugmentation), constraint_axis=(False, False, False), constraint_orientation='GLOBAL', mirror=False, proportional='DISABLED', proportional_edit_falloff='SMOOTH', proportional_size=1)
    return {'FINISHED'}

But when i add a function to remake this stl file, The blender and my interface PyQt crashe:


My problem is in this function bpy.ops.transform.resize
Can you help me please?


(Py3D) #2

is there any reply…


(erdinc) #3

What is the console output? (If you start blender from a console, there might be some error messages after crashing.)


(VincentG) #4

You can also read answers…

Your Blender is probably not crashing but wait that the Qt window finish.


(Py3D) #5

I don’t found the solution yet. can you help me with a tutorial or an example please?


(Py3D) #6

In the console, i have this error:
AttributeError: ‘bool’ object has no attribute ‘scene’


(Py3D) #7

In the console, i have this error:
AttributeError: ‘bool’ object has no attribute ‘scene’
this is my function:
def mark1Command(self, context):
bpy.ops.object.empty_add(type=‘PLAIN_AXES’, radius=1, view_align=False, location=(context.scene.cursor_location.x,context.scene.cursor_location.y,context.scene.cursor_location.z), layers=(True, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False))
for obj in bpy.context.selected_objects:
obj.name = “Repere1”
return {‘FINISHED’}


(erdinc) #8
def mark1Command(self, context):

If the error is in this function, probably you are calling it with a wrong “context” argument. You are a sending a “bool”. But it needs to be a bpy.context object.


(Py3D) #9

quand je mis: def mark1Command(self, bpy.context):
ça me donne une erreur (invalid syntax)


(Py3D) #10

avant d’implémenter PyQt, j’ai utilisé GUI de Blender et ça marche bien.
Je veux maintenant le transformer en PyQt5. voila le code d’avant:
class Repere1(bpy.types.Operator):
bl_idname=“object.repere1”
bl_label = " Creation Repere 1 "
def execute(self,context):
bpy.ops.object.empty_add(type=‘PLAIN_AXES’, radius=1, view_align=False, location=(context.scene.cursor_location.x,context.scene.cursor_location.y,context.scene.cursor_location.z), layers=(True, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False))
for obj in bpy.context.selected_objects:
obj.name = “Repere1”
return {‘FINISHED’}
bpy.utils.register_class(Repere1)


(Py3D) #11

before i code with PyQt, i used GUI of Blender and it works very well.
I want to convert GUI blender to PyQt5. this is my code:
class Repere1(bpy.types.Operator):
bl_idname=“object.repere1”
bl_label = " Creation Repere 1 "
def execute(self,context):
bpy.ops.object.empty_add(type=‘PLAIN_AXES’, radius=1, view_align=False, location=(context.scene.cursor_location.x,context. scene.cursor_location.y,context.scene.cursor_locat ion.z), layers=(True, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False))
for obj in bpy.context.selected_objects:
obj.name = “Repere1”
return {‘FINISHED’}
bpy.utils.register_class(Repere1)