Skip to content

Commit

Permalink
Merge pull request #32 from pedohorse/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
pedohorse authored Aug 4, 2021
2 parents 967a7fb + 7957537 commit 1d883dd
Show file tree
Hide file tree
Showing 5 changed files with 108 additions and 77 deletions.
19 changes: 15 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,22 @@ You can read a bit more about it in here:
this plugin is built to only use standard system modules and standard houdini modules.

**HOWEVER** in some cases (like houdini 17.5 on linux) you might run into **SSL error** due to certificated being out of date. In this case you **should** install certifi module to still properly secure your connection. This can be done as simple as **pip install certifi** on linux, windows or mac (details at: https://pypi.org/project/certifi/)
### Super short and simple variant ###
### Super short and simple package variant (use it with houdini >17.0) ###
1. Download the contents of this repository as ZIP
2. Unzip the contents of the folder **hpaste-master** it into your Houdini user folder, something like C:\Users\\<**USER>**\Documents\houdini16.5\
(you actually don't need to copy the example folder from there)
3. Enjoy!
2. Unzip the contents of the archive (which is automatically created by github folder `hpaste-master`)
into your user folder (for ex `C:\Users\<USER>\Documents\houdini18.5\`)
so as a result you will have `C:\Users\<USER>\Documents\houdini18.5\hpaste-master`
3. Pick one file `hpaste.json` from there and move it into `packages` folder of your houdini user directory (create it if it does not exist)
for ex. the full path will look like `C:\Users\<USER>\Documents\houdini18.5\packages\hpaste.json`
4. Enjoy!

#### legacy variant
1. Download the contents of this repository as ZIP
2. Open the downloaded zip - you will see one folder **hpaste-master** inside it - this folder was created automatically by github
3. Copy the **contents** of the folder **hpaste-master** it into your Houdini user folder, something like `C:\Users\<USER>\Documents\houdini16.5\`
(just to be clear, you **DON'T** copy the folder **hpaste-master** itself, you copy it's **contents**)
(also you actually don't need to copy the example folder from there)
4. Enjoy!

### a bit longer variant ###
1. copy **hpaste** folder from python2.7libs to your local script folder
Expand Down
4 changes: 4 additions & 0 deletions hpaste.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"load_package_once": true,
"path": "$HOUDINI_PACKAGE_PATH/../hpaste-master"
}
60 changes: 32 additions & 28 deletions python2.7libs/hpaste/hpasteshelffunctions.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,36 +92,40 @@ def hpasteweb(pane=None):
if isinstance(qapp, QApplication):
qapp.restoreOverrideCursor()

try:
stringToNodes(s, ne=pane, key=key)
except InvalidContextError as e:
nec, snc = e.contexts()
if snc == 'Sop' and nec == 'Object':
if hou.ui.displayMessage("Error: %s" % str(e.message), severity=hou.severityType.Warning, buttons=('Create geo node', 'Cancel'), default_choice=0, close_choice=1) == 0:
geonode = e.node().createNode('geo')
if pane is not None:
geonode.setPosition(pane.cursorPosition())
stringToNodes(s, hou_parent=geonode, key=key)
else:
geonode = None
for _ in range(2):
try:
stringToNodes(s, ne=pane, key=key, hou_parent=geonode)
except InvalidContextError as e:
nec, snc = e.contexts()
if snc == 'Sop' and nec == 'Object':
if hou.ui.displayMessage("Error: %s" % str(e.message), severity=hou.severityType.Warning, buttons=('Create geo node', 'Cancel'), default_choice=0, close_choice=1) == 0:
if geonode is not None:
raise RuntimeError('are we in an infinite loop?')
geonode = e.node().createNode('geo')
if pane is not None:
geonode.setPosition(pane.cursorPosition())
pane = None
continue
else:
hou.ui.displayMessage("Error: %s" % str(e.message), severity=hou.severityType.Error)
return
except WrongKeyLengthError as e:
hou.ui.displayMessage("Bad key length: %s. Check if you copied hpaste link correctly" % str(e.message), severity=hou.severityType.Error)
return
except NoKeyError as e:
hou.ui.displayMessage("This snippet is encrypted and requires a key: %s. Check if you copied hpaste link correctly. key in the link usually goes in front of the snippet, separated by '!'" % str(e.message), severity=hou.severityType.Error)
return
except WrongKeyError as e:
hou.ui.displayMessage("Wrong key: %s. Check if you copied hpaste link correctly" % str(e.message), severity=hou.severityType.Error)
return
except RuntimeError as e:
hou.ui.displayMessage("Error: %s" % str(e.message), severity=hou.severityType.Error)
return
except WrongKeyLengthError as e:
hou.ui.displayMessage("Bad key length: %s. Check if you copied hpaste link correctly" % str(e.message), severity=hou.severityType.Error)
return
except NoKeyError as e:
hou.ui.displayMessage("This snippet is encrypted and requires a key: %s. Check if you copied hpaste link correctly. key in the link usually goes in front of the snippet, separated by '!'" % str(e.message), severity=hou.severityType.Error)
return
except WrongKeyError as e:
hou.ui.displayMessage("Wrong key: %s. Check if you copied hpaste link correctly" % str(e.message), severity=hou.severityType.Error)
return
except RuntimeError as e:
hou.ui.displayMessage("Error: %s" % str(e.message), severity=hou.severityType.Error)
return
except RuntimeWarning as e:
hou.ui.displayMessage("Warning: %s" % str(e.message), severity=hou.severityType.Warning)
#except Exception as e:
# hou.ui.displayMessage("Internal Error: %s" % str(e.message), severity=hou.severityType.Error)
# return
except RuntimeWarning as e:
hou.ui.displayMessage("Warning: %s" % str(e.message), severity=hou.severityType.Warning)
break

hou.ui.setStatusMessage("Success: Nodes pasted!")


Expand Down
56 changes: 31 additions & 25 deletions python3.7libs/hpaste/hpasteshelffunctions.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,32 +83,38 @@ def hpasteweb(pane=None):
if isinstance(qapp, QApplication):
qapp.restoreOverrideCursor()

try:
stringToNodes(s, ne=pane, key=key)
except InvalidContextError as e:
nec, snc = e.contexts()
if snc == 'Sop' and nec == 'Object':
if hou.ui.displayMessage("Error: %s" % str(e), severity=hou.severityType.Warning, buttons=('Create geo node', 'Cancel'), default_choice=0, close_choice=1) == 0:
geonode = e.node().createNode('geo')
if pane is not None:
geonode.setPosition(pane.cursorPosition())
stringToNodes(s, hou_parent=geonode, key=key)
else:
geonode = None
for _ in range(2):
try:
stringToNodes(s, ne=pane, key=key, hou_parent=geonode)
except InvalidContextError as e:
nec, snc = e.contexts()
if snc == 'Sop' and nec == 'Object':
if hou.ui.displayMessage("Error: %s" % str(e), severity=hou.severityType.Warning, buttons=('Create geo node', 'Cancel'), default_choice=0, close_choice=1) == 0:
if geonode is not None:
raise RuntimeError('are we in an infinite loop?')
geonode = e.node().createNode('geo')
if pane is not None:
geonode.setPosition(pane.cursorPosition())
pane = None
continue
else:
hou.ui.displayMessage("Error: %s" % str(e), severity=hou.severityType.Error)
return
except WrongKeyLengthError as e:
hou.ui.displayMessage("Bad key length: %s. Check if you copied hpaste link correctly" % str(e), severity=hou.severityType.Error)
return
except NoKeyError as e:
hou.ui.displayMessage("This snippet is encrypted and requires a key: %s. Check if you copied hpaste link correctly. key in the link usually goes in front of the snippet, separated by '!'" % str(e), severity=hou.severityType.Error)
return
except WrongKeyError as e:
hou.ui.displayMessage("Wrong key: %s. Check if you copied hpaste link correctly" % str(e), severity=hou.severityType.Error)
return
except RuntimeError as e:
hou.ui.displayMessage("Error: %s" % str(e), severity=hou.severityType.Error)
return
except WrongKeyLengthError as e:
hou.ui.displayMessage("Bad key length: %s. Check if you copied hpaste link correctly" % str(e), severity=hou.severityType.Error)
return
except NoKeyError as e:
hou.ui.displayMessage("This snippet is encrypted and requires a key: %s. Check if you copied hpaste link correctly. key in the link usually goes in front of the snippet, separated by '!'" % str(e), severity=hou.severityType.Error)
return
except WrongKeyError as e:
hou.ui.displayMessage("Wrong key: %s. Check if you copied hpaste link correctly" % str(e), severity=hou.severityType.Error)
return
except RuntimeError as e:
hou.ui.displayMessage("Error: %s" % str(e), severity=hou.severityType.Error)
return
except RuntimeWarning as e:
hou.ui.displayMessage("Warning: %s" % str(e), severity=hou.severityType.Warning)
except RuntimeWarning as e:
hou.ui.displayMessage("Warning: %s" % str(e), severity=hou.severityType.Warning)
break

hou.ui.setStatusMessage("Success: Nodes pasted!")
46 changes: 26 additions & 20 deletions toolbar/hpaste.shelf
Original file line number Diff line number Diff line change
Expand Up @@ -63,28 +63,34 @@ def do(pane):
else:
qapp = QApplication.instance()
s = qapp.clipboard().text()
try:
hpaste.stringToNodes(s, ne=pane)
except hpaste.InvalidContextError as e:
nec, snc = e.contexts()
if snc == 'Sop' and nec == 'Object':
if hou.ui.displayMessage("Error: %s" % str(e), severity=hou.severityType.Warning, buttons=('Create geo node', 'Cancel'), default_choice=0, close_choice=1) == 0:
geonode = e.node().createNode('geo')
if pane is not None:
geonode.setPosition(pane.cursorPosition())
hpaste.stringToNodes(s, hou_parent=geonode)
else:
geonode = None
for _ in range(2):
try:
hpaste.stringToNodes(s, ne=pane, hou_parent=geonode)
except hpaste.InvalidContextError as e:
nec, snc = e.contexts()
if snc == 'Sop' and nec == 'Object':
if hou.ui.displayMessage("Error: %s" % str(e), severity=hou.severityType.Warning, buttons=('Create geo node', 'Cancel'), default_choice=0, close_choice=1) == 0:
if geonode is not None:
raise RuntimeError('are we in an infinite loop?')
geonode = e.node().createNode('geo')
if pane is not None:
geonode.setPosition(pane.cursorPosition())
pane = None
continue
else:
hou.ui.displayMessage("Error: %s"%str(e),severity=hou.severityType.Error)
return
except RuntimeError as e:
hou.ui.displayMessage("Error: %s"%str(e),severity=hou.severityType.Error)
return
except RuntimeError as e:
hou.ui.displayMessage("Error: %s"%str(e),severity=hou.severityType.Error)
return
except RuntimeWarning as e:
hou.ui.displayMessage("Warning: %s"%str(e),severity=hou.severityType.Warning)
except Exception as e:
hou.ui.displayMessage("Internal Error: %s"%str(e),severity=hou.severityType.Error)
return
except RuntimeWarning as e:
hou.ui.displayMessage("Warning: %s"%str(e),severity=hou.severityType.Warning)
except Exception as e:
hou.ui.displayMessage("Internal Error: %s"%str(e),severity=hou.severityType.Error)
return
break
do(kwargs['pane'])
]]></script>
Expand Down

0 comments on commit 1d883dd

Please sign in to comment.