Results 1 to 8 of 8
  1. #1

    Problem in PyQt with blender

    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.
    Code:
    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:
    Ca.PNG

    My problem is in this function bpy.ops.transform.resize
    Can you help me please?
    Last edited by Py3D; 16-Mar-17 at 05:51.



  2. #2
    is there any reply....



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



  4. #4
    Member VincentG's Avatar
    Join Date
    Apr 2013
    Location
    Belgium, Brussels
    Posts
    598
    Originally Posted by Py3D View Post
    is there any reply....
    You can also read answers...
    https://blenderartists.org/forum/sho...t-into-Blender

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



  5. #5
    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_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'}



  6. #6
    Code:
    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.



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



  8. #8
    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)



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •