# The signal for the slider
self.ui.planeSizeHorizontalSlider.valueChanged.connect(self.plane_size_slider)
def plane_size_slider(self, value): img_plane_node = self.get_current_img_plane() value /= 10.00 self.ui.planeSizeLineEdit.setText(str(value)) self.set_plane_size(img_plane_node, value)
def set_plane_size(self, node, value): width = cmds.getAttr("{0}.width".format(node)) height = cmds.getAttr("{0}.height".format(node)) ratio = height / width
with UndoManager(): # UndoManager is a contextmanager cmds.setAttr("{0}.maintainRatio".format(node), 0) cmds.setAttr("{0}.width".format(node), value) cmds.setAttr("{0}.height".format(node), value * ratio) cmds.setAttr("{0}.maintainRatio".format(node), 1)# The signal for the slider
self.ui.planeSizeHorizontalSlider.valueChanged.connect(self.plane_size_slider)self.ui.planeSizeHorizontalSlider.sliderReleased.connect(self.plane_size_slider)
def plane_size_slider(self, value): img_plane_node = self.get_current_img_plane() value /= 10.00 self.ui.planeSizeLineEdit.setText(str(value))
def plane_size_slider_release(self): img_plane_node = self.get_current_img_plane() value = float(self.ui.planeSizeLineEdit.text()) self.set_plane_size(img_plane_node, value)
def set_plane_size(self, node, value): width = cmds.getAttr("{0}.width".format(node)) height = cmds.getAttr("{0}.height".format(node)) ratio = height / width
with UndoManager(): # UndoManager is a contextmanager cmds.setAttr("{0}.maintainRatio".format(node), 0) cmds.setAttr("{0}.width".format(node), value) cmds.setAttr("{0}.height".format(node), value * ratio) cmds.setAttr("{0}.maintainRatio".format(node), 1)# Connections that I have set for my slider
self.ui.planeSizeHorizontalSlider.sliderPressed.connect(self.slider_pressed)
self.ui.planeSizeHorizontalSlider.sliderReleased.connect(self.slider_released)
self.ui.planeSizeHorizontalSlider.valueChanged.connect(self.plane_size_slider)
def slider_pressed(self):
cmds.undoInfo(openChunk=True, chunkName='SlideTest')
def slider_released(self):
cmds.undoInfo(closeChunk=True, chunkName='SlideTest')
def plane_size_slider(self, value):
img_plane_node = self.get_current_img_plane()
value /= 10.00
self.ui.planeSizeLineEdit.setText(str(value))
self.set_plane_size(img_plane_node, value)
def set_plane_size(self, node, value):
width = cmds.getAttr("{0}.width".format(node))
height = cmds.getAttr("{0}.height".format(node))
ratio = height / width
# This got regiters as additional actions...
cmds.setAttr("{0}.maintainRatio".format(node), 0)
cmds.setAttr("{0}.width".format(node), value)
cmds.setAttr("{0}.height".format(node), value * ratio)
cmds.setAttr("{0}.maintainRatio".format(node), 1)
# 1: #
# 2: #
# 3: #
# 4: #
# 5: SlideTest #
# 6: #
# 7: #
# 8: #
# 9: #
# 10: SlideTest #
# 1: SlideTest #
# 2: SlideTest #