Skip to content

Commit

Permalink
fix path on Linux
Browse files Browse the repository at this point in the history
  • Loading branch information
LewisOrton committed May 15, 2020
1 parent 3403e94 commit 5da448b
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions scripts/externaldragdrop.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@
# by Lewis Orton
# https://vimeo.com/lewisorton

import hou, re, os, sys
import hou, re, os, sys, platform

from urllib import unquote
#decode urlpath on windows

def dropAccept(files):

pane = hou.ui.paneTabUnderCursor()
Expand All @@ -13,11 +15,11 @@ def dropAccept(files):

for file in files:

#windows file path contains special prefix which needs to be removed
if file[0:8] == "file:///":
if platform.system() == "Windows":
file_path = file[8:]
else:
file_path = file
elif platform.system() == "Linux":
file_path = file[7:]

file_path = unquote(file_path) #decode urlpath
file_basename = os.path.splitext(os.path.basename(file_path))
file_ext = file_basename[1].lower()
Expand Down Expand Up @@ -49,6 +51,7 @@ def rel_path(fullpath):
def import_file(network_node, file_path, file_basename, cursor_position):
#validate node name
file_name = re.sub(r"[^0-9a-zA-Z\.]+", "_", file_basename[0])

file_ext = file_basename[1].lower()

#create new geo node in obj network if none exists
Expand Down

0 comments on commit 5da448b

Please sign in to comment.