Got the parameters editor working so that it can modify the model, but it still needs a lot of clean-up.
This commit is contained in:
parent
84c0a9b249
commit
68907ba9d7
|
@ -138,8 +138,34 @@ class CadQueryExecuteScript:
|
|||
|
||||
# Allows us to present parameters to users later that they can alter
|
||||
parameters = cqModel.metadata.parameters
|
||||
build_parameters = {}
|
||||
|
||||
build_result = cqModel.build()
|
||||
# Collect the build parameters from the Parameters Editor view, if they exist
|
||||
mw = FreeCADGui.getMainWindow()
|
||||
|
||||
# Tracks whether or not we have already added the variables editor
|
||||
isPresent = False
|
||||
|
||||
# If the widget is open, we need to close it
|
||||
dockWidgets = mw.findChildren(QtGui.QDockWidget)
|
||||
for widget in dockWidgets:
|
||||
if widget.objectName() == "cqVarsEditor":
|
||||
# Toggle the visibility of the widget
|
||||
if not widget.visibleRegion().isEmpty():
|
||||
# build_parameters = {'param': 2}
|
||||
|
||||
# Find all of the controls that will have parameter values in them
|
||||
valueControls = mw.findChildren(QtGui.QLineEdit)
|
||||
for valueControl in valueControls:
|
||||
objectName = valueControl.objectName()
|
||||
FreeCAD.Console.PrintMessage(objectName + "\r\n")
|
||||
if objectName != None and objectName != '' and objectName[0] == 'p':
|
||||
FreeCAD.Console.PrintMessage(objectName.split('_')[1] + "\r\n")
|
||||
build_parameters[objectName.split('_')[1]] = valueControl.text()
|
||||
|
||||
FreeCAD.Console.PrintMessage(build_parameters[objectName.split('_')[1]] + "\r\n")
|
||||
|
||||
build_result = cqModel.build(build_parameters=build_parameters)
|
||||
|
||||
# Make sure that the build was successful
|
||||
if build_result.success:
|
||||
|
@ -346,12 +372,12 @@ class ToggleParametersEditor:
|
|||
if not isPresent:
|
||||
cqVariablesEditor = QtGui.QDockWidget("CadQuery Variables Editor")
|
||||
cqVariablesEditor.setObjectName("cqVarsEditor")
|
||||
# cqVariablesEditor.setAutoFillBackground(True)
|
||||
# p = cqVariablesEditor.palette()
|
||||
# p.setColor(cqVariablesEditor.backgroundRole(), '#FF0000')
|
||||
# cqVariablesEditor.setPalette(p)
|
||||
|
||||
mw.addDockWidget(QtCore.Qt.LeftDockWidgetArea, cqVariablesEditor)
|
||||
|
||||
# Go ahead and populate the view if there are variables in the script
|
||||
CadQueryValidateScript().Activated()
|
||||
|
||||
|
||||
class CadQueryValidateScript:
|
||||
"""Checks the script for the user without executing it and populates the variable editor, if needed"""
|
||||
|
|
|
@ -112,10 +112,11 @@ def populateParameterEditor(parameters):
|
|||
label = QtGui.QLabel(pKey)
|
||||
value = QtGui.QLineEdit()
|
||||
value.setText(str(pVal.default_value))
|
||||
btn = QtGui.QPushButton("OK")
|
||||
value.setObjectName("p_" + pKey)
|
||||
# btn = QtGui.QPushButton("OK")
|
||||
gridLayout.addWidget(label, line, 0)
|
||||
gridLayout.addWidget(value, line, 1)
|
||||
gridLayout.addWidget(btn, line, 2)
|
||||
# gridLayout.addWidget(btn, line, 2)
|
||||
|
||||
line += 1
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user