Skip to content

Commit

Permalink
Merge pull request #27 from kartchnb/fix-for-sym-links
Browse files Browse the repository at this point in the history
Initial fix for issue #21
  • Loading branch information
kartchnb authored Nov 1, 2022
2 parents 24cf1c3 + 7e5c5c7 commit 2b29c25
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
26 changes: 25 additions & 1 deletion OpenScadJob.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
import os
import shutil
import tempfile

from UM.Job import Job

from . import OpenScadInterface
Expand All @@ -21,4 +25,24 @@ def __init__(self, openScadInterface, openScadFilePath, openScadParameters, stlF

def run(self) -> None:
'''Generate an STL from an OpenSCAD file'''
self._openScadInterface.GenerateStl(self._openScadFilePath, self._openScadParameters, self._stlFilePath)

# Check if the openscad file is in a symbolically-linked directory
# OpenScad apparently can't handle source files in symbolically-linked directories (at least on Windows)
openScadFileDir = os.path.dirname(self._openScadFilePath)
if os.path.islink(openScadFileDir):

# Copy the file to the system's temporary directory
openScadFileName = os.path.basename(self._openScadFilePath)
tempDir = tempfile.gettempdir()
tempOpenScadFilePath = os.path.join(tempDir, openScadFileName)
shutil.copy2(self._openScadFilePath, tempOpenScadFilePath)

# Run openscad with the temporary file
self._openScadInterface.GenerateStl(tempOpenScadFilePath, self._openScadParameters, self._stlFilePath)

# Delete the temporary file
os.remove(tempOpenScadFilePath)

# If this is just a normal, everyday file, run openscad normally
else:
self._openScadInterface.GenerateStl(self._openScadFilePath, self._openScadParameters, self._stlFilePath)
2 changes: 1 addition & 1 deletion plugin.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "Auto Towers Generator",
"author": "Brad Kartchner",
"version": "2.4.1",
"version": "2.4.2",
"api": 7,
"supported_sdk_versions": ["7.9.0", "8.0.0", "8.1.0", "8.2.0"],
"description": "Automates the generation of several parameterized calibration models.",
Expand Down

0 comments on commit 2b29c25

Please sign in to comment.