From 8f469bfd03e240302ae4f7ac35b88a9040a3029a Mon Sep 17 00:00:00 2001 From: Yorik van Havre Date: Sat, 26 Apr 2014 13:09:43 -0300 Subject: [PATCH] Arch: made importWebGL easier to use in python scripts --- src/Mod/Arch/importWebGL.py | 146 ++++++++++++++++++------------------ 1 file changed, 71 insertions(+), 75 deletions(-) diff --git a/src/Mod/Arch/importWebGL.py b/src/Mod/Arch/importWebGL.py index c59a6fb44..1079360d5 100644 --- a/src/Mod/Arch/importWebGL.py +++ b/src/Mod/Arch/importWebGL.py @@ -32,7 +32,73 @@ else: FreeCADGui = None tab = " " -addWireframe = False +wireframeStyle = "faceloop" # this can be "faceloop", "multimaterial" or None + + +template = """ + + + FreeCAD model + + + + + + """ + if open.__module__ == '__builtin__': pythonopen = open @@ -53,10 +119,9 @@ def getHTML(objectsList): objectsData = '' for obj in objectsList: objectsData += getObjectData(obj) - template = getTemplate() - template = template.replace("$CameraData",getCameraData()) - template = template.replace("$ObjectsData",objectsData) - return template + t = template.replace("$CameraData",getCameraData()) + t = t.replace("$ObjectsData",objectsData) + return t def getCameraData(): "returns the position and direction of the camera as three.js snippet" @@ -75,7 +140,7 @@ def getCameraData(): # print result return result -def getObjectData(obj,wireframeMode="faceloop"): +def getObjectData(obj,wireframeMode=wireframeStyle): """returns the geometry data of an object as three.js snippet. wireframeMode can be multimaterial, faceloop or None""" @@ -156,73 +221,4 @@ def getObjectData(obj,wireframeMode="faceloop"): result += tab+"scene.add( mesh );\n"+tab return result - -def getTemplate(): - "returns a html template" - - result = """ - - - FreeCAD model - - - - - - """ - - return result