Example #1
0
 def invoke(self, context, event):
     e = context.object
     locEnd = cursor_2d_to_location_3d(context, event)
     # try to get a wall instance assuming <e> is a corner EMPTY located at either free end of the wall
     wall = getWallFromEmpty(context, self, e, True)
     if wall:
         o = wall.extend(e, locEnd)
         bpy.ops.object.select_all(action="DESELECT")
         self.mover = AlongSegmentMover(wall, o)
         # set mode of operation
         self.attached = False
     else:
         # try to get a wall instance assuming <empty> is a segment EMPTY
         if e and "t" in e and e["t"] == "ws":
             wall = getWallFromEmpty(context, self, e, False)
             if wall:
                 # wall.startAttachedWall(empty, locEnd) returns segment EMPTY
                 o = wall.startAttachedWall(e, locEnd)
                 bpy.ops.object.select_all(action="DESELECT")
                 self.mover = SegmentMover(getWallFromEmpty(context, self, o), o)
                 # set mode of operation
                 self.attached = True
         if not wall:
             self.report({"ERROR"}, "To extend the wall, select an EMPTY object at either free end of the wall")
             return {"CANCELLED"}
     self.state = self.set_location
     self.lastOperator = getLastOperator(context)
     # The order how self.mover.start() and context.window_manager.modal_handler_add(self)
     # are called is important. If they are called in the reversed order, it won't be possible to
     # capture X, Y, Z keys
     self.mover.start()
     context.window_manager.modal_handler_add(self)
     return {"RUNNING_MODAL"}
Example #2
0
 def invoke(self, context, event):
     if not context.scene.prk.levels:
         self.report({"ERROR"}, "To create a wall add at least one level")
         return {"CANCELLED"}
     locEnd = cursor_2d_to_location_3d(context, event)
     wall = Wall(context, self)
     constraint_axis = wall.create(locEnd)
     bpy.ops.transform.translate("INVOKE_DEFAULT", constraint_axis=constraint_axis, constraint_orientation="LOCAL")
     return {"FINISHED"}
Example #3
0
 def invoke(self, context, event):
     if not context.scene.prk.levels:
         self.report({'ERROR'}, "To create a wall add at least one level")
         return {'CANCELLED'}
     locEnd = cursor_2d_to_location_3d(context, event)
     wall = Wall(context, self)
     constraint_axis = wall.create(locEnd)
     bpy.ops.transform.translate('INVOKE_DEFAULT',
                                 constraint_axis=constraint_axis,
                                 constraint_orientation='LOCAL')
     return {'FINISHED'}
Example #4
0
 def invoke(self, context, event):
     e = context.object
     locEnd = cursor_2d_to_location_3d(context, event)
     # try to get a wall instance assuming <e> is a corner EMPTY located at either free end of the wall
     wall = getWallFromEmpty(context, self, e, True)
     if wall:
         o = wall.extend(e, locEnd)
         bpy.ops.object.select_all(action="DESELECT")
         self.mover = AlongSegmentMover(wall, o)
         # set mode of operation
         self.attached = False
     else:
         # try to get a wall instance assuming <empty> is a segment EMPTY
         if e and "t" in e and e["t"] == "ws":
             wall = getWallFromEmpty(context, self, e, False)
             if wall:
                 # wall.startAttachedWall(empty, locEnd) returns segment EMPTY
                 o = wall.startAttachedWall(e, locEnd)
                 bpy.ops.object.select_all(action="DESELECT")
                 self.mover = SegmentMover(
                     getWallFromEmpty(context, self, o), o)
                 # set mode of operation
                 self.attached = True
         if not wall:
             self.report({
                 'ERROR'
             }, "To extend the wall, select an EMPTY object at either free end of the wall"
                         )
             return {'CANCELLED'}
     self.state = self.set_location
     self.lastOperator = getLastOperator(context)
     # The order how self.mover.start() and context.window_manager.modal_handler_add(self)
     # are called is important. If they are called in the reversed order, it won't be possible to
     # capture X, Y, Z keys
     self.mover.start()
     context.window_manager.modal_handler_add(self)
     return {'RUNNING_MODAL'}