Removed the assumption that every script would have an accompanying 3D view.
This commit is contained in:
parent
3d3f640dae
commit
93e6c95de6
|
@ -120,25 +120,25 @@ class CadQueryExecuteScript:
|
|||
cqCodePane = Shared.getActiveCodePane()
|
||||
|
||||
# Clear the old render before re-rendering
|
||||
Shared.clearActiveDocument()
|
||||
# Shared.clearActiveDocument()
|
||||
|
||||
# Save our code to a tempfile and render it
|
||||
tempFile = tempfile.NamedTemporaryFile(delete=False)
|
||||
tempFile.write(cqCodePane.toPlainText().encode('utf-8'))
|
||||
tempFile.close()
|
||||
|
||||
docname = os.path.splitext(os.path.basename(cqCodePane.file.path))[0]
|
||||
|
||||
# Make sure we replace any troublesome characters
|
||||
for ch in ['&', '#', '.', '-', '$', '%', ',', ' ']:
|
||||
if ch in docname:
|
||||
docname = docname.replace(ch, "")
|
||||
|
||||
# If the matching 3D view has been closed, we need to open a new one
|
||||
try:
|
||||
FreeCAD.getDocument(docname)
|
||||
except:
|
||||
FreeCAD.newDocument(docname)
|
||||
# docname = os.path.splitext(os.path.basename(cqCodePane.file.path))[0]
|
||||
#
|
||||
# # Make sure we replace any troublesome characters
|
||||
# for ch in ['&', '#', '.', '-', '$', '%', ',', ' ']:
|
||||
# if ch in docname:
|
||||
# docname = docname.replace(ch, "")
|
||||
#
|
||||
# # If the matching 3D view has been closed, we need to open a new one
|
||||
# try:
|
||||
# FreeCAD.getDocument(docname)
|
||||
# except:
|
||||
# FreeCAD.newDocument(docname)
|
||||
|
||||
# We import this way because using execfile() causes non-standard script execution in some situations
|
||||
imp.load_source('temp_module', tempFile.name)
|
||||
|
@ -163,9 +163,6 @@ class CadQueryNewScript:
|
|||
return True
|
||||
|
||||
def Activated(self):
|
||||
# We need to close any file that's already open in the editor window
|
||||
CadQueryCloseScript().Activated()
|
||||
|
||||
module_base_path = module_locator.module_path()
|
||||
templ_dir_path = os.path.join(module_base_path, 'Templates')
|
||||
|
||||
|
|
|
@ -3,6 +3,8 @@
|
|||
def show(cqObject, rgba=(204, 204, 204, 0.0)):
|
||||
import FreeCAD
|
||||
from random import random
|
||||
import os, tempfile
|
||||
import Shared
|
||||
|
||||
#Convert our rgba values
|
||||
r = rgba[0] / 255.0
|
||||
|
@ -10,6 +12,30 @@ def show(cqObject, rgba=(204, 204, 204, 0.0)):
|
|||
b = rgba[2] / 255.0
|
||||
a = int(rgba[3] * 100.0)
|
||||
|
||||
# Grab our code editor so we can interact with it
|
||||
cqCodePane = Shared.getActiveCodePane()
|
||||
|
||||
# Clear the old render before re-rendering
|
||||
Shared.clearActiveDocument()
|
||||
|
||||
# Save our code to a tempfile and render it
|
||||
tempFile = tempfile.NamedTemporaryFile(delete=False)
|
||||
tempFile.write(cqCodePane.toPlainText().encode('utf-8'))
|
||||
tempFile.close()
|
||||
|
||||
docname = os.path.splitext(os.path.basename(cqCodePane.file.path))[0]
|
||||
|
||||
# Make sure we replace any troublesome characters
|
||||
for ch in ['&', '#', '.', '-', '$', '%', ',', ' ']:
|
||||
if ch in docname:
|
||||
docname = docname.replace(ch, "")
|
||||
|
||||
# If the matching 3D view has been closed, we need to open a new one
|
||||
try:
|
||||
FreeCAD.getDocument(docname)
|
||||
except:
|
||||
FreeCAD.newDocument(docname)
|
||||
|
||||
ad = FreeCAD.activeDocument()
|
||||
|
||||
# If we've got a blank shape name, we have to create a random ID
|
||||
|
|
Loading…
Reference in New Issue
Block a user