Interactive scripting pane added to pyQt viewer geom.app

This commit is contained in:
jakob-beetz
2016-11-24 13:57:42 +01:00
committed by Thomas Krijnen
parent 3ba2f781d8
commit 90e4f21f29
4 changed files with 239 additions and 1 deletions
@@ -0,0 +1,25 @@
quickload_model = "D:\Project1.ifc"
["snippets"]
'print all wall ids' = """# a simple script that iterates over all walls in the current
# model and prints their Globally unique IDs (GUIDS) to the console
# window
for wall in model.by_type("IfcWall"):
print ("wall with global id: "+str(wall.GlobalId))
"""
'print all properties of current selection' = """# a simple script that iterates over all IfcPropertySets of the currently
# selected object and prints them to the console
#####################################################################
# check if something is selected
if selection:
#get the IfcProduct that is stored in the global variable 'selection'
obj = selection
for relDefinesByProperties in obj.IsDefinedBy:
print("[{0}]".format(relDefinesByProperties.RelatingPropertyDefinition.Name))
for prop in relDefinesByProperties.RelatingPropertyDefinition.HasProperties:
print ("{:<20} :{}".format(prop.Name,prop.NominalValue.wrappedValue))
print ("\n")
"""
@@ -0,0 +1,51 @@
from pyqode.qt import QtCore, QtGui, QtWidgets
from configobj import ConfigObj
from ..geom.app import application
try:
from ..geom.code_editor_pane import code_edit
except ImportError:
print ("code editor or one of its dependencies (pyQode) could not be found. Please make sure to install pyQode")
class my_app(application):
class toolbar(QtGui.QToolBar):
def __init__(self):
QtGui.QToolBar.__init__(self)
self.widget.append()
def __init__(self):
application.__init__(self)
# self.window = my_app.window()
self.window.setWindowTitle("Interactive IfcOpenShell Viewer with REPL-like funcionality")
tb = self.window.addToolBar("File")
self.window.resize(1024,720)
# loadButton = QtGui.QAction(QtGui.QIcon("new.bmp"),"new",self)
loadButton = QtGui.QAction("Quickload",self)
loadButton.triggered.connect(self.loadExampleFile)
loadButton.setShortcut(QtGui.QKeySequence("CTRL+L"))
tb.addAction(loadButton)
# zoomAllButton = QtGui.QAction(QtGui.QIcon("new.bmp"),"new",self)
zoomAllButton = QtGui.QAction("zoom All",self)
zoomAllButton.triggered.connect(self.zoomAll)
tb.addAction(zoomAllButton)
self.config = ConfigObj("snippets.config")
print (self.config["snippets"])
snippets = self.config["snippets"]
self.codeedit= code_edit(self.canvas, snippets )
self.components.append(self.codeedit)
self.window.centralWidget().addWidget(self.codeedit)
self.runButton = QtGui.QAction("execute code (Strg+P)",self)
self.runButton.setShortcut(QtGui.QKeySequence("CTRL+P"))
self.runButton.triggered.connect(self.codeedit.runCode)
tb.addAction(self.runButton)
def loadExampleFile(self):
self.load(self.config["quickload_model"])
def zoomAll(self):
self.canvas._display.FitAll()
my_app().start()