[Bf-extensions-cvs] [92301276] master: archipack: fix left select issue in draw window/door and allow selecting preset while drawing

Stephen Leger noreply at git.blender.org
Wed Aug 9 22:38:09 CEST 2017


Commit: 92301276de6919b27b79d548ea69cd0b07ec0549
Author: Stephen Leger
Date:   Thu Aug 3 15:59:40 2017 +0200
Branches: master
https://developer.blender.org/rBA92301276de6919b27b79d548ea69cd0b07ec0549

archipack: fix left select issue in draw window/door and allow selecting preset while drawing

===================================================================

M	archipack/archipack_door.py
M	archipack/archipack_snap.py
M	archipack/archipack_window.py

===================================================================

diff --git a/archipack/archipack_door.py b/archipack/archipack_door.py
index 642b7747..c50398c6 100644
--- a/archipack/archipack_door.py
+++ b/archipack/archipack_door.py
@@ -1598,7 +1598,7 @@ class ARCHIPACK_OT_door(ArchipackCreateTool, Operator):
 
     def unique(self, context):
         act = context.active_object
-        sel = [o for o in context.selected_objects]
+        sel = context.selected_objects[:]
         bpy.ops.object.select_all(action="DESELECT")
         for o in sel:
             if archipack_door.filter(o):
@@ -1650,6 +1650,7 @@ class ARCHIPACK_OT_door_draw(ArchpackDrawTool, Operator):
     filepath = StringProperty(default="")
     feedback = None
     stack = []
+    object_name = ""
 
     @classmethod
     def poll(cls, context):
@@ -1690,6 +1691,8 @@ class ARCHIPACK_OT_door_draw(ArchpackDrawTool, Operator):
             bpy.ops.archipack.door(auto_manipulate=False, filepath=self.filepath)
             o = context.active_object
 
+        self.object_name = o.name
+
         bpy.ops.archipack.generate_hole('INVOKE_DEFAULT')
         o.select = True
         context.scene.objects.active = o
@@ -1697,7 +1700,10 @@ class ARCHIPACK_OT_door_draw(ArchpackDrawTool, Operator):
     def modal(self, context, event):
 
         context.area.tag_redraw()
-        o = context.active_object
+        o = context.scene.objects.get(self.object_name)
+        if o is None:
+            return {'FINISHED'}
+
         d = archipack_door.datablock(o)
         hole = None
 
@@ -1721,6 +1727,16 @@ class ARCHIPACK_OT_door_draw(ArchpackDrawTool, Operator):
                 d.y = wall.data.archipack_wall2[0].width
 
         if event.value == 'PRESS':
+
+            if event.type in {'C'}:
+                bpy.ops.archipack.door(mode='DELETE')
+                self.feedback.disable()
+                bpy.types.SpaceView3D.draw_handler_remove(self._handle, 'WINDOW')
+                bpy.ops.archipack.door_preset_menu(
+                    'INVOKE_DEFAULT',
+                    preset_operator="archipack.door_draw")
+                return {'FINISHED'}
+
             if event.type in {'LEFTMOUSE', 'RET', 'NUMPAD_ENTER', 'SPACE'}:
                 if wall is not None:
                     context.scene.objects.active = wall
@@ -1781,6 +1797,7 @@ class ARCHIPACK_OT_door_draw(ArchpackDrawTool, Operator):
             self.feedback.instructions(context, "Draw a door", "Click & Drag over a wall", [
                 ('LEFTCLICK, RET, SPACE, ENTER', 'Create a door'),
                 ('BACKSPACE, CTRL+Z', 'undo last'),
+                ('C', 'Choose another door'),
                 ('SHIFT', 'Make independant copy'),
                 ('RIGHTCLICK or ESC', 'exit')
                 ])
diff --git a/archipack/archipack_snap.py b/archipack/archipack_snap.py
index eb3898d3..92e09595 100644
--- a/archipack/archipack_snap.py
+++ b/archipack/archipack_snap.py
@@ -142,10 +142,11 @@ def snap_point(takeloc=None,
     # for ArchipackSnapBase to be able to handle both modes
     # must implements corresponding helper create and delete actions
     SnapStore.mode = mode
-    res = bpy.ops.archipack.snap('INVOKE_DEFAULT')
+    bpy.ops.archipack.snap('INVOKE_DEFAULT')
     # return helper so we are able to move it "live"
     return SnapStore.helper
 
+
 class ArchipackSnapBase():
     """
         Helper class for snap Operators
@@ -273,7 +274,7 @@ class ARCHIPACK_OT_snap(ArchipackSnapBase, Operator):
         # NOTE: this part only run after transform LEFTMOUSE RELEASE
         # or with ESC and RIGHTMOUSE
         if event.type not in {'ESC', 'RIGHTMOUSE', 'LEFTMOUSE', 'MOUSEMOVE'}:
-            print("Snap.modal skip unknown event %s %s" % (event.type, event.value))
+            # print("Snap.modal skip unknown event %s %s" % (event.type, event.value))
             # self.report({'WARNING'}, "ARCHIPACK_OT_snap unknown event")
             return{'PASS_THROUGH'}
         if event.type in ('ESC', 'RIGHTMOUSE'):
diff --git a/archipack/archipack_window.py b/archipack/archipack_window.py
index 4b052643..3979b181 100644
--- a/archipack/archipack_window.py
+++ b/archipack/archipack_window.py
@@ -1841,6 +1841,7 @@ class ARCHIPACK_OT_window_draw(ArchpackDrawTool, Operator):
     filepath = StringProperty(default="")
     feedback = None
     stack = []
+    object_name = ""
 
     @classmethod
     def poll(cls, context):
@@ -1881,6 +1882,8 @@ class ARCHIPACK_OT_window_draw(ArchpackDrawTool, Operator):
             bpy.ops.archipack.window(auto_manipulate=False, filepath=self.filepath)
             o = context.active_object
 
+        self.object_name = o.name
+
         bpy.ops.archipack.generate_hole('INVOKE_DEFAULT')
         o.select = True
         context.scene.objects.active = o
@@ -1888,7 +1891,11 @@ class ARCHIPACK_OT_window_draw(ArchpackDrawTool, Operator):
     def modal(self, context, event):
 
         context.area.tag_redraw()
-        o = context.active_object
+        o = context.scene.objects.get(self.object_name)
+
+        if o is None:
+            return {'FINISHED'}
+
         d = archipack_window.datablock(o)
         hole = None
         if d is not None:
@@ -1911,6 +1918,14 @@ class ARCHIPACK_OT_window_draw(ArchpackDrawTool, Operator):
                 d.y = wall.data.archipack_wall2[0].width
 
         if event.value == 'PRESS':
+
+            if event.type in {'C'}:
+                bpy.ops.archipack.window(mode='DELETE')
+                self.feedback.disable()
+                bpy.types.SpaceView3D.draw_handler_remove(self._handle, 'WINDOW')
+                bpy.ops.archipack.window_preset_menu('INVOKE_DEFAULT', preset_operator="archipack.window_draw")
+                return {'FINISHED'}
+
             if event.type in {'LEFTMOUSE', 'RET', 'NUMPAD_ENTER', 'SPACE'}:
                 if wall is not None:
                     context.scene.objects.active = wall
@@ -1970,6 +1985,7 @@ class ARCHIPACK_OT_window_draw(ArchpackDrawTool, Operator):
             self.feedback.instructions(context, "Draw a window", "Click & Drag over a wall", [
                 ('LEFTCLICK, RET, SPACE, ENTER', 'Create a window'),
                 ('BACKSPACE, CTRL+Z', 'undo last'),
+                ('C', 'Choose another window'),
                 ('SHIFT', 'Make independant copy'),
                 ('RIGHTCLICK or ESC', 'exit')
                 ])



More information about the Bf-extensions-cvs mailing list