Merge pull request #4906 from Russ4262/fix/toolbit_missing_readme_doc
[Path] Fix relative shape files for toolbits
This commit is contained in:
@@ -164,6 +164,10 @@ SET(PathScripts_post_SRCS
|
||||
PathScripts/post/uccnc_post.py
|
||||
)
|
||||
|
||||
SET(Tools_SRCS
|
||||
Tools/README.md
|
||||
)
|
||||
|
||||
SET(Tools_Bit_SRCS
|
||||
Tools/Bit/45degree_chamfer.fctb
|
||||
Tools/Bit/5mm-thread-cutter.fctb
|
||||
@@ -256,6 +260,7 @@ SET(Path_Data
|
||||
SET(all_files
|
||||
${PathScripts_SRCS}
|
||||
${PathScripts_post_SRCS}
|
||||
${Tools_SRCS}
|
||||
${Tools_Bit_SRCS}
|
||||
${Tools_Library_SRCS}
|
||||
${Tools_Shape_SRCS}
|
||||
@@ -308,6 +313,13 @@ INSTALL(
|
||||
Mod/Path/PathScripts/post
|
||||
)
|
||||
|
||||
INSTALL(
|
||||
FILES
|
||||
${Tools_SRCS}
|
||||
DESTINATION
|
||||
Mod/Path/Tools
|
||||
)
|
||||
|
||||
INSTALL(
|
||||
FILES
|
||||
${Tools_Bit_SRCS}
|
||||
|
||||
@@ -96,6 +96,7 @@ def findToolBit(name, path=None):
|
||||
return _findToolFile("{}.fctb".format(name), path, 'Bit')
|
||||
|
||||
|
||||
# Only used in ToolBit unit test module: TestPathToolBit.py
|
||||
def findToolLibrary(name, path=None):
|
||||
'''findToolLibrary(name, path) ... search for name, if relative path look in path'''
|
||||
PathLog.track(name, path)
|
||||
@@ -117,12 +118,15 @@ def _findRelativePath(path, typ):
|
||||
return relative
|
||||
|
||||
|
||||
# Unused due to bug fix related to relative paths
|
||||
"""
|
||||
def findRelativePathShape(path):
|
||||
return _findRelativePath(path, 'Shape')
|
||||
|
||||
|
||||
def findRelativePathTool(path):
|
||||
return _findRelativePath(path, 'Bit')
|
||||
"""
|
||||
|
||||
|
||||
def findRelativePathLibrary(path):
|
||||
@@ -380,7 +384,10 @@ class ToolBit(object):
|
||||
if PathPreferences.toolsStoreAbsolutePaths():
|
||||
attrs['shape'] = obj.BitShape
|
||||
else:
|
||||
attrs['shape'] = findRelativePathShape(obj.BitShape)
|
||||
# attrs['shape'] = findRelativePathShape(obj.BitShape)
|
||||
# Extract the name of the shape file
|
||||
__, filShp = os.path.split(obj.BitShape) # __ is an ignored placeholder acknowledged by LGTM
|
||||
attrs['shape'] = str(filShp)
|
||||
params = {}
|
||||
for name in obj.BitPropertyNames:
|
||||
params[name] = PathUtil.getPropertyValueString(obj, name)
|
||||
|
||||
@@ -85,6 +85,15 @@ def checkWorkingDir():
|
||||
PathPreferences.setLastPathToolBit("{}{}Bit".format(workingdir, os.path.sep))
|
||||
PathLog.debug('setting workingdir to: {}'.format(workingdir))
|
||||
|
||||
# Copy only files of default Path\Tools folder to working directory (targeting the README.md help file)
|
||||
src_toolfiles = os.listdir(defaultdir)
|
||||
for file_name in src_toolfiles:
|
||||
if file_name in ["README.md"]:
|
||||
full_file_name = os.path.join(defaultdir, file_name)
|
||||
if os.path.isfile(full_file_name):
|
||||
shutil.copy(full_file_name, workingdir)
|
||||
|
||||
# Determine which subdirectories are missing
|
||||
subdirlist = ['Bit', 'Library', 'Shape']
|
||||
mode = 0o777
|
||||
for dir in subdirlist.copy():
|
||||
@@ -92,6 +101,7 @@ def checkWorkingDir():
|
||||
if os.path.exists(subdir):
|
||||
subdirlist.remove(dir)
|
||||
|
||||
# Query user for creation permission of any missing subdirectories
|
||||
if len(subdirlist) >= 1:
|
||||
needed = ', '.join([str(d) for d in subdirlist])
|
||||
qm = PySide.QtGui.QMessageBox
|
||||
@@ -100,9 +110,11 @@ def checkWorkingDir():
|
||||
if ret == qm.No:
|
||||
return False
|
||||
else:
|
||||
# Create missing subdirectories if user agrees to creation
|
||||
for dir in subdirlist:
|
||||
subdir = "{}{}{}".format(workingdir, os.path.sep, dir)
|
||||
os.mkdir(subdir, mode)
|
||||
# Query user to copy example files into subdirectories created
|
||||
if dir != 'Shape':
|
||||
qm = PySide.QtGui.QMessageBox
|
||||
ret = qm.question(None,'', "Copy example files to new {} directory?".format(dir), qm.Yes | qm.No)
|
||||
@@ -452,6 +464,7 @@ class ToolBitLibrary(object):
|
||||
if shapefile is None: # user canceled
|
||||
return
|
||||
|
||||
# select the bit file location and filename
|
||||
filename = PathToolBitGui.GetNewToolFile()
|
||||
if filename is None:
|
||||
return
|
||||
@@ -460,7 +473,7 @@ class ToolBitLibrary(object):
|
||||
loc, fil = os.path.split(filename)
|
||||
fname = os.path.splitext(fil)[0]
|
||||
fullpath = "{}{}{}.fctb".format(loc, os.path.sep, fname)
|
||||
PathLog.debug(fullpath)
|
||||
PathLog.debug("fullpath: {}".format(fullpath))
|
||||
|
||||
self.temptool = PathToolBit.ToolBitFactory().Create(name=fname)
|
||||
self.temptool.BitShape = shapefile
|
||||
@@ -565,6 +578,7 @@ class ToolBitLibrary(object):
|
||||
self.form.librarySave.setEnabled(True)
|
||||
|
||||
def toolEdit(self, selected):
|
||||
PathLog.track()
|
||||
item = self.toolModel.item(selected.row(), 0)
|
||||
|
||||
if self.temptool is not None:
|
||||
@@ -620,9 +634,13 @@ class ToolBitLibrary(object):
|
||||
toolNr = self.toolModel.data(self.toolModel.index(row, 0), PySide.QtCore.Qt.EditRole)
|
||||
toolPath = self.toolModel.data(self.toolModel.index(row, 0), _PathRole)
|
||||
if PathPreferences.toolsStoreAbsolutePaths():
|
||||
tools.append({'nr': toolNr, 'path': toolPath})
|
||||
bitPath = toolPath
|
||||
else:
|
||||
tools.append({'nr': toolNr, 'path': PathToolBit.findRelativePathTool(toolPath)})
|
||||
# bitPath = PathToolBit.findRelativePathTool(toolPath)
|
||||
# Extract the name of the shape file
|
||||
__, filShp = os.path.split(toolPath) # __ is an ignored placeholder acknowledged by LGTM
|
||||
bitPath = str(filShp)
|
||||
tools.append({'nr': toolNr, 'path': bitPath})
|
||||
|
||||
if self.path is not None:
|
||||
with open(self.path, 'w') as fp:
|
||||
|
||||
Reference in New Issue
Block a user