def newVHDAWindow(name, label, path, namespace_user=hou.userName(), namespace_type='dev'): defaults = [namespace_user, namespace_type, name, label, path] dialog = New_VHDA_Dialog(hou.ui.mainQtWindow(), defaults) dialog.exec_() button_idx = dialog.exitval values = dialog.parmvals return button_idx, values
def createNewVHDA(node): name = "default" label = "Default" namespace = hou.userName() if isSubnet(node): full_name = node.name() name = ''.join(i for i in full_name if not i.isdigit()) label = name.replace("_", " ") label = label.title() elif isHDA(node): # node.type().name() would return 'noise:2.0', however we only need 'noise', so get the name component instead name = node.type().nameComponents()[2] label = node.type().description() namespace = node.type().nameComponents()[1] if name != "default": button_idx, values = newVHDAWindow(name, label, getDefaultVHDAPath(), namespace_user=namespace) if button_idx == 1: namespace_user = values[0] namespace_type = values[1] name = values[2] label = values[3] location = values[4] major, minor = hasSpecificVHDA(node, namespace_user, namespace_type, name) major += 1 minor = 0 createVHDA(node, namespace_user, namespace_type, name, major, minor, label, location)
def main(): exitCode = 0 # _msg("0 " +str(sys.argv[0])) # _msg("1 " +str(sys.argv[1])) _msg("arg1: {}".format(sys.argv[2])) _msg("arg2: {}".format(sys.argv[3])) hipf = str(sys.argv[2]) hou.hipFile.load(hipf) # igy inditod a bulit, ez egy kontener for geocnt in hou.node("/obj/prop").children(): # iteration _msg("Points in {}".format(geocnt.path())) # string format for point in geocnt.displayNode().geometry().points(): # foreach point _msg("{}".format(point.position())) # print vector _msg(" ") psz = "{}/sweet".format(geocnt.path()) # path to image _msg(psz) # /obj/prop/geo1/sweet - path to parm _msg(geocnt.name()) # geo1 - nodename _msg(str(hou.parm(psz).eval())) # resolved path Q:/Work/../image.png _msg(" -- - ") _msg(str(geocnt.parm('szoveg').eval())) # string typed into the field # RAW string path $JOB/.../image.png _msg(str(geocnt.parm('sweet').rawValue())) # in the hip i attached an expression: 7.12 * ch("intgr") _msg(str(geocnt.parm('flott').expression())) # username spaced padded with _ _msg(hou.userName(alpha=True)) # current node - since nothing is selected we get / # after that every relative path works from pwd() _msg(str(hou.pwd())) # type of an object < class 'hou.Node' > print(type(hou.pwd())) for geocnt in hou.node("/obj/nagy").children(): _msg(" {}".format(geocnt.path())) # split into two string at once # the is MaxSplit. Default value is -1, which is "all occurrences" lhs, rhs = "sommas_bubuka".split("_", 1) # classic split example splz = "aaa bsbs kdkd sdfs".split(" ") _msg("type of the split array:") print(type(splz)) _msg("nof items in array:") print(len(splz)) # some regexp # regular expression "[a-m]+" means the lowercase letters a through m that occur one or more times are matched as a delimiter atext = 'zzzzzzabczzzzzzdefzzzzzzzzzghizzzzzzzzzzzz' alist = re.split("[a-m]+", atext) # this is how you print a list print(alist) # ['zzzzzz', 'zzzzzz', 'zzzzzzzzz', 'zzzzzzzzzzzz'] # chomp one at a time atext = "theres coffee in that nebula" mytuple = atext.partition(" ") print type(mytuple) # <type 'tuple' > print mytuple # ('theres', ' ', 'coffee in that nebula') print mytuple[0] # theres print mytuple[2] # coffee in that nebula readLineDemo() readLineDemoPro() _msg("exitcode:" + str(exitCode)) _msg("bye!") return exitCode
def build_ui(self): layout = QVBoxLayout() self.user_namespace_enable = QCheckBox() self.user_namespace_enable.clicked.connect(self.on_LineEditChange) self.user_namespace_enable.setChecked(self.defaults[0] != "") user_namespace_layout = QHBoxLayout() user_namespace = QLabel("Namespace") user_namespace.setFixedSize(100, 20) self.user_edit = QLineEdit( self.defaults[0] if self.defaults[0] != "" else hou.userName()) self.user_edit.textChanged.connect(self.on_LineEditChange) user_namespace_layout.addWidget(self.user_namespace_enable) user_namespace_layout.addWidget(user_namespace) user_namespace_layout.addWidget(self.user_edit) type_layout = QHBoxLayout() self.type_enable = QCheckBox() self.type_enable.clicked.connect(self.on_LineEditChange) self.type_enable.setChecked(self.defaults[1] != "") type_label = QLabel("Branch") type_label.setFixedSize(100, 20) self.type_edit = QLineEdit( self.defaults[1] if self.defaults[1] != "" else "dev") self.type_edit.textChanged.connect(self.on_LineEditChange) type_layout.addWidget(self.type_enable) type_layout.addWidget(type_label) type_layout.addWidget(self.type_edit) assettype_layout = QHBoxLayout() assettype_label = QLabel("Type and Version") assettype_label.setFixedSize(126, 20) self.assettype_edit = QLineEdit(self.defaults[2]) self.assettype_edit.textChanged.connect(self.on_LineEditChange) _major = self.defaults[5] if self.defaults[5] != None else 1 _minor = self.defaults[6] if self.defaults[6] != None else 0 versionstring = "{0}.{1}".format(_major, _minor) self.assetversion_edit = QLineEdit(versionstring) self.assetversion_edit.textChanged.connect(self.on_LineEditChange) self.assetversion_edit.setFixedWidth(30) assettype_layout.addWidget(assettype_label) assettype_layout.addWidget(self.assettype_edit) assettype_layout.addWidget(self.assetversion_edit) assetlabel_layout = QHBoxLayout() assetlabel_label = QLabel("Label") assetlabel_label.setFixedSize(126, 20) self.assetlabel_edit = QLineEdit(self.defaults[3]) assetlabel_layout.addWidget(assetlabel_label) assetlabel_layout.addWidget(self.assetlabel_edit) verticalSpacer = QSpacerItem(20, 20, QSizePolicy.Minimum, QSizePolicy.Expanding) self.namespace_preview = QLabel() self.on_LineEditChange() buttons_layout = QHBoxLayout() OK_btn = QPushButton("Continue") Cancel_btn = QPushButton("Cancel") OK_btn.clicked.connect(self.on_OK) Cancel_btn.clicked.connect(self.on_Cancel) buttons_layout.addWidget(OK_btn) buttons_layout.addWidget(Cancel_btn) layout.addLayout(user_namespace_layout) layout.addLayout(type_layout) layout.addLayout(assettype_layout) layout.addLayout(assetlabel_layout) layout.addWidget(self.namespace_preview) layout.addItem(verticalSpacer) layout.addLayout(buttons_layout) self.setLayout(layout) self.setFixedHeight(self.sizeHint().height())