コード例 #1
0
ファイル: ops.py プロジェクト: vvoovv/prokitektura-studio
    def connectSegments(self, context, wall1, wall2, o1, o2):
        o = wall1.connect(wall2, o1, o2)

        bpy.ops.object.select_all(action="DESELECT")

        self.lastOperator = getLastOperator(context)
        mover = SegmentMover(getWallFromEmpty(context, self, o), o)
        self.mover = mover
        self.finished = False
        # 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
        mover.start()
        context.window_manager.modal_handler_add(self)
        return {'RUNNING_MODAL'}
コード例 #2
0
ファイル: ops.py プロジェクト: vvoovv/prokitektura-studio
 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'}