-
Notifications
You must be signed in to change notification settings - Fork 160
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
19 changed files
with
2,405 additions
and
0 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added
BIN
+6.25 MB
Snippet-0005 Visualizing GeoTIFF with HeightField/ETOPO1_Ice_g_geotiff_jp.tif
Binary file not shown.
Binary file added
BIN
+288 KB
Snippet-0005 Visualizing GeoTIFF with HeightField/Visualizing GeoTIFF with HeightField.hipnc
Binary file not shown.
Binary file added
BIN
+92.3 KB
Snippet-0006 Digital Asset Runtime Control on Unity Editor/RuntimeControlHoudiniEngine.hiplc
Binary file not shown.
Binary file added
BIN
+17.5 KB
Snippet-0006 Digital Asset Runtime Control on Unity Editor/sampleasset.hdalc
Binary file not shown.
Binary file added
BIN
+171 KB
Snippet-0007 Saving Node as Python Code/Save Node as Python Code.hipnc
Binary file not shown.
2,209 changes: 2,209 additions & 0 deletions
2,209
Snippet-0007 Saving Node as Python Code/node_reconstruction.py
Large diffs are not rendered by default.
Oops, something went wrong.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,196 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<shelfDocument> | ||
<!-- This file contains definitions of shelves, toolbars, and tools. | ||
It should not be hand-edited when it is being used by the application. | ||
Note, that two definitions of the same element are not allowed in | ||
a single file. --> | ||
|
||
<tool name="SaveStateToDB" label="Save State To DB" icon="PLASMA_App"> | ||
<script scriptType="python"><![CDATA[import sqlite3 # sqlite3ã¢ã¸ã¥ã¼ã«ã®ã¤ã³ãã¼ã | ||
import hou # Houdiniã®ã¢ã¸ã¥ã¼ã«ã®ã¤ã³ãã¼ã | ||
import datetime | ||
from PySide2 import QtCore | ||
from PySide2 import QtWidgets | ||
node = hou.node("/") | ||
# database.dbã¨ããååã®SQLiteã®ãã¼ã¿ãã¼ã¹ãã¡ã¤ã«ã | ||
# HIPãã¡ã¤ã«ã¨åãé層ã«æ¥ãããã«ãã¡ã¤ã«ãã¹ãä½ã | ||
dbname = hou.houdiniPath()[0] + "/database.db" | ||
### ãã¤ã¢ãã°ã®ã¯ã©ã¹ãä½ã | ||
class SaveState(QtWidgets.QWidget): | ||
def __init__(self, parent=None): | ||
QtWidgets.QWidget.__init__(self, parent) | ||
vbox = QtWidgets.QVBoxLayout() # 縦ã«ä¸¦ã¹ãã¬ã¤ã¢ã¦ãæ¹å¼ã使ã | ||
self.setGeometry(500, 300, 300, 100) # ã¦ã£ã³ãã¦ã®ãµã¤ãºã®æå® | ||
self.setWindowTitle('Save State') # ã¦ã£ã³ãã¦ã®ã¿ã¤ãã«ã®æå® | ||
self.label = QtWidgets.QLabel('Comment', self) | ||
vbox.addWidget(self.label, 1) | ||
textedit = QtWidgets.QTextEdit() # ããã¹ããã£ã¼ã«ããä½ã | ||
vbox.addWidget(textedit) # ã¬ã¤ã¢ã¦ãã«ããã¹ããã£ã¼ã«ãã追å ãã | ||
self.msgtextedit = textedit # ãã¤ã¢ãã°ã¯ã©ã¹ã®msgtexteditå¤æ°ã«ããã¹ããã£ã¼ã«ããæ ¼ç´ãã | ||
button = QtWidgets.QPushButton('Save State', self) # ä¿åãã¿ã³ãä½æãã | ||
button.setFocusPolicy(QtCore.Qt.NoFocus) | ||
vbox.addWidget(button) # ãã¿ã³ãã¬ã¤ã¢ã¦ãã«è¿½å ãã | ||
self.connect(button, QtCore.SIGNAL('clicked()'), self.save) # ãã¿ã³ã¯ãªãã¯æã®ã¤ãã³ãã®å¦çãæå®ãã | ||
self.setLayout(vbox) | ||
def save(self): | ||
# sqlite3ã使ã£ã¦ãã¼ã¿ãã¼ã¹ãä½ããhistoryã¨ãããã¼ãã«ã | ||
# ã¾ã ãã¼ã¿ãã¼ã¹ã«ãªãå ´åã«éãæ°è¦ã§ä½æãã | ||
conn = sqlite3.connect(dbname) | ||
c = conn.cursor() | ||
sql_create_table = ''' CREATE TABLE IF NOT EXISTS history ( | ||
id integer PRIMARY KEY, | ||
name text, | ||
state_data text, | ||
created text | ||
); ''' | ||
c.execute(sql_create_table) | ||
### ååãä½ã | ||
name = self.msgtextedit.toPlainText() | ||
### ãã¼ããããã¯ã¼ã¯åæ§æç¨ã®Pythonã³ã¼ããåå¾ãã | ||
node = hou.node("/") # ä¸çªä¸ã®é層ã®ãã¼ããããã¯ã¼ã¯ã®ãã¹ | ||
code = node.asCode(False, True, False, True, True, True) # ãã¼ããããã¯ã¼ã¯ãåæ§æããããã®Pythonã³ã¼ããåå¾ãã | ||
### ç¾å¨ã®æ¥æãåå¾ãã | ||
created = datetime.datetime.now().strftime("%Y/%m/%d %H:%M:%S") | ||
sql_insert = ''' INSERT INTO history (name, state_data, created) | ||
VALUES ( | ||
?, | ||
?, | ||
? | ||
); ''' #ãã¼ã¿æ¿å ¥ã®ã¯ã¨ãªæãä½ã | ||
c.execute(sql_insert, [name, code, created]) # ãã¼ã¿ãã¼ã¹ã«ã¯ã¨ãªãéã | ||
conn.commit() # ãã¼ã¿ãã¼ã¹ã®å¤æ´åãä¿åãã | ||
conn.close() # ãã¼ã¿ãã¼ã¹ã®æ¥ç¶ãåã | ||
self.close() | ||
dialog = SaveState() | ||
dialog.show()]]></script> | ||
</tool> | ||
|
||
<tool name="LoadSaveState" label="Load Save State" icon="PLASMA_App"> | ||
<script scriptType="python"><![CDATA[import sqlite3 | ||
import hou | ||
from PySide2 import QtCore | ||
from PySide2 import QtWidgets | ||
from functools import partial | ||
node = hou.node("/") | ||
dbname = hou.houdiniPath()[0] + "/database.db" | ||
conn = sqlite3.connect(dbname) | ||
c = conn.cursor() | ||
sql_create_table = ''' CREATE TABLE IF NOT EXISTS history ( | ||
id integer PRIMARY KEY, | ||
name text, | ||
state_data text, | ||
created text | ||
); ''' | ||
c.execute(sql_create_table) | ||
conn.commit() | ||
sql_get_rows = ''' SELECT id, name, state_data, created FROM history ORDER BY created ''' | ||
c.execute(sql_get_rows) | ||
rows = c.fetchall() | ||
conn.close() | ||
# èªã¿åãã®ãã¤ã¢ãã°ã®ã¯ã©ã¹ | ||
class LoadState(QtWidgets.QWidget): | ||
def __init__(self, datas, parent=None): | ||
QtWidgets.QWidget.__init__(self, parent) | ||
vbox = QtWidgets.QVBoxLayout() | ||
self.setGeometry(500, 300, 600, 300) | ||
self.setWindowTitle('Load State') | ||
tableWidget = QtWidgets.QTableWidget() | ||
tableWidget.setRowCount(len(datas)) # ãã¼ã¿ãã¼ã¹ã«ãããã¼ã¿ã®æ°ã ãè¡ãä½ã | ||
tableWidget.setColumnCount(5) # åãäºã¤ä½ã | ||
tableWidget.setHorizontalHeaderLabels(["id", "commnet", "created", "", ""]) | ||
for i in range(len(datas)): | ||
### ãã¼ã¿ãã¼ã¹ã®æ ¼ç´ãããPythonã³ã¼ã以å¤ããã¼ãã«ã®ã»ã«ã«æ¿å ¥ãã | ||
tableWidget.setItem(i, 0, QtWidgets.QTableWidgetItem(str(datas[i][0]))) | ||
tableWidget.setItem(i, 1, QtWidgets.QTableWidgetItem(str(datas[i][1]))) | ||
tableWidget.setItem(i, 2, QtWidgets.QTableWidgetItem(str(datas[i][3]))) | ||
buttonLoad = QtWidgets.QPushButton("Load State") # èªã¿åãç¨ã®ãã¿ã³ãä½ã | ||
buttonLoad.setFocusPolicy(QtCore.Qt.NoFocus) | ||
buttonLoad.clicked.connect(partial(self.loadData, datas[i][2])) # ãã¿ã³ã¯ãªãã¯æã®é¢æ°ã«ãã¼ã¿ãã¼ã¹ã«æ ¼ç´ãããPythonã®ã³ã¼ãããã¹ãã | ||
tableWidget.setCellWidget(i, 3, buttonLoad) # èªã¿åãç¨ã®ãã¿ã³ãï¼ã¤ãã®åã«æ¿å ¥ãã | ||
buttonDelete = QtWidgets.QPushButton("Delete"); # ãã¼ã¿åé¤ç¨ã®ãã¿ã³ãä½ã | ||
buttonDelete.setFocusPolicy(QtCore.Qt.NoFocus) | ||
buttonDelete.clicked.connect(partial(self.deleteData, datas[i][0])) # åé¤ãã¿ã³ã¯ãªãã¯æã®é¢æ°ã«ãã¼ã¿ã®idããã¹ãã | ||
tableWidget.setCellWidget(i, 4, buttonDelete) # äºã¤ãã®åã«åé¤ãã¿ã³ãæ¿å ¥ãã | ||
self.table = tableWidget # ãã¤ã¢ãã°ã®ã¯ã©ã¹ã®å¤æ°tableã«ãã¼ãã«ã®ã¦ã£ã¸ã§ãããæ ¼ç´ãã | ||
### ãã¼ãã«ã®ãããã¼ã®ãµã¤ãºãèªå調æ´ãã | ||
header = tableWidget.horizontalHeader() | ||
header.setSectionResizeMode(1, QtWidgets.QHeaderView.Stretch) | ||
header.setSectionResizeMode(0, QtWidgets.QHeaderView.ResizeToContents) | ||
header.setSectionResizeMode(2, QtWidgets.QHeaderView.ResizeToContents) | ||
header.setSectionResizeMode(3, QtWidgets.QHeaderView.ResizeToContents) | ||
header.setSectionResizeMode(4, QtWidgets.QHeaderView.ResizeToContents) | ||
vbox.addWidget(tableWidget) # ãã¼ãã«ã®ã¦ã£ã¸ã§ãããã¬ã¤ã¢ã¦ãã«è¿½å ãã | ||
self.setLayout(vbox) | ||
### ãã¼ã¿èªã¿åãã®ãã¿ã³ãæ¼ããéã«å¼ã°ããé¢æ° | ||
def loadData(self, data): | ||
exec(data) # ãã¼ã¿ãã¼ã¹ã«æ ¼ç´ããã¦ããPythonã³ã¼ããå®è¡ãã¦ããã¼ããããã¯ã¼ã¯ãåæ§æãã | ||
self.close() | ||
### ãã¼ã¿åé¤ãã¿ã³ãæ¼ããéã«å¼ã°ããé¢æ° | ||
def deleteData(self, id): | ||
### idã«ããããããã¼ã¿ãæ¢ã | ||
results = self.table.model().match( | ||
self.table.model().index(0, 0), | ||
QtCore.Qt.DisplayRole, | ||
id, | ||
-1, | ||
QtCore.Qt.MatchContains | ||
) | ||
### foundRowã«åé¤ãã対象ã®è¡çªå·ãæ ¼ç´ãã | ||
foundRow = -1 | ||
for result in results: | ||
foundRow = result.row() | ||
self.table.removeRow(foundRow) # æå®ã®è¡çªå·ã®ãã¼ãã«ã®è¡ãåé¤ãã | ||
conn = sqlite3.connect(dbname) | ||
c = conn.cursor() | ||
sql_remove_item = ''' DELETE FROM history WHERE id = ?; ''' # æå®ã®idã®ãã¼ã¿ããã¼ã¿ãã¼ã¹ããåé¤ããã¯ã¨ãªãä½ã | ||
c.execute(sql_remove_item, [id]) # ãã¼ã¿ãã¼ã¹ãããã¼ã¿ãåé¤ãã | ||
conn.commit() # ãã¼ã¿ãã¼ã¹ãæ´æ°ãã | ||
conn.close() | ||
dialog = LoadState(rows) | ||
dialog.show()]]></script> | ||
</tool> | ||
</shelfDocument> |
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.