def Activated(self): if not lithophane_utils.checkOpenscadInstalled(): return mesh, label = lithophane_utils.findSelectedBooleanMesh() if mesh is None: qtutils.showInfo( "No Lithophane Mesh selected", "Select one Lithophane mesh, and either a FreeCAD Mesh or an object with a Shape" ) return base = lithophane_utils.findSelectedBaseFeature() if base is None: qtutils.showInfo( "No Base Feature selected", "Select one Lithophane mesh, and either a FreeCAD Mesh or an object with a Shape" ) return mesh.addAdditiveFeature(base) FreeCAD.ActiveDocument.recompute()
def checkBaseMeshExecution(self): if self.Object.LithophaneImage is None: qtutils.showInfo('No LithophaneImage linked', 'Please link a lithophane Image to the mesh to caculate the geometry') return None return self.Object.LithophaneImage.Proxy
def checkExecution(self): mesh, meshLabel = lithophane_utils.findSelectedMesh() if mesh is None: qtutils.showInfo("No mesh selected", "Select exactly one mesh to continue") return None return (mesh, meshLabel)
def Activated(self): lithophaneImage, imageLabel = lithophane_utils.findSelectedImage() if lithophaneImage is None: qtutils.showInfo("No LithophaneImage selected", "Select exactly one LithophaneImage to continue") return showPointCloud(lithophaneImage.lines, imageLabel + '_PointCloud') lithophane_utils.recomputeView()
def Activated(self): (image, label, freeCadObject) = lithophane_utils.findSelectedImage( includeObject=True) if image is None: qtutils.showInfo("No LithophaneImage selected", "Select exactly one LithophaneImage to continue") return panel = ScalePanel(image, freeCadObject) FreeCADGui.Control.showDialog(panel)
def Activated(self): lithophaneImage, imageLabel, documentObject = lithophane_utils.findSelectedImage( True) if lithophaneImage is None: qtutils.showInfo("No LithophaneImage selected", "Select exactly one LithophaneImage to continue") return self.createGeometryInstance(documentObject, imageLabel) lithophane_utils.recomputeView()
def checkOpenscadInstalled(): found = True try: import OpenSCADUtils found = OpenSCADUtils.getopenscadversion() is not None except: found = False if not found: qtutils.showInfo('OpenSCAD import failed', 'The import of OpenSCADUtils failed. Make sure you have OpenSCAD installed and configured in the preferences.') return found
def Activated(self): mesh, label = lithophane_utils.findSelectedMesh() if mesh is None: qtutils.showInfo("No Mesh selected", "Select exactly one Mesh to continue") return boundBox = mesh.BoundBox length = formatLength(boundBox.XMax - boundBox.XMin) width = formatLength(boundBox.YMax - boundBox.YMin) height = formatLength(boundBox.ZMax - boundBox.ZMin) message = "Length (X): %s\n\nWidth (Y): %s\n\nHeight (Z): %s" %(length, width, height) qtutils.showInfo("Bounding Information", message)
def Activated(self): lithophaneImage, imageLabel = lithophane_utils.findSelectedImage() if lithophaneImage is None: qtutils.showInfo("No LithophaneImage selected", "Select exactly one LithophaneImage to continue") return timers = [] timers.append(Timer('Creating ImagePlane (1/7)')) imagePlane = makeImagePlane(lithophaneImage.lines) timers[-1].stop() timers.append(Timer('Creating ImageBase (2/7)')) block = makeBlockBase(lithophaneImage.lines) timers[-1].stop() timers.append(Timer('Create Bottom Plane (3/7)')) bottomPlane = createBottomRectangle(lithophaneImage.lines) timers[-1].stop() timers.append(Timer('Merge Meshes (4/7)')) imageMesh = Mesh.Mesh() imageMesh.addMesh(imagePlane) imageMesh.addMesh(block) imageMesh.addMesh(bottomPlane) timers[-1].stop() timers.append(Timer('Removing Duplicate Points (5/7)')) imageMesh.removeDuplicatedPoints() lithophane_utils.recomputeView() timers[-1].stop() timers.append(Timer('Recalculating Normals (6/7)')) imageMesh.harmonizeNormals() timers[-1].stop() timers.append(Timer('Recomputing View (7/7)')) Mesh.show(imageMesh, imageLabel + '_Box') lithophane_utils.recomputeView() timers[-1].stop() FreeCAD.Console.PrintMessage('Creating Boxy image took %.3f s' % (computeOverallTime(timers)))
def applyBooleanOperations(base, operations): ''' base the base mesh operations [(mesh, mode, name)]''' blenderExecutable = preferences.getBlenderExecutable() if blenderExecutable is None or blenderExecutable.strip() == '': from utils import qtutils qtutils.showInfo( 'Blender Executable not set', 'Go to "Tools > Edit Parameters" and set "Plugins > Furti > Lithophane > BlenderExecutable" to the blender executable path' ) return with tempfile.TemporaryDirectory() as tmpdirname: config = BooleanConfig() firstOperation = operations[0] baseFile = writeMesh(base, tmpdirname, 'base') featureFile = writeMesh(firstOperation[0], tmpdirname, firstOperation[2]) config.addFiles(baseFile, featureFile, firstOperation[1]) if len(operations) > 1: for mesh, mode, name in operations[1:]: featureFile = writeMesh(mesh, tmpdirname, name) config.addOutcome(featureFile, mode) configPath = config.write(tmpdirname) resultPath = os.path.join(tmpdirname, 'boolean_result.stl') executeBlender(blenderExecutable, configPath, resultPath) resultMesh = Mesh.Mesh() resultMesh.read(Filename=resultPath) return resultMesh
mesh, label = lithophane_utils.findSelectedMesh() if mesh is None: qtutils.showInfo("No Mesh selected", "Select exactly one Mesh to continue") return boundBox = mesh.BoundBox length = formatLength(boundBox.XMax - boundBox.XMin) width = formatLength(boundBox.YMax - boundBox.YMin) height = formatLength(boundBox.ZMax - boundBox.ZMin) message = "Length (X): %s\n\nWidth (Y): %s\n\nHeight (Z): %s" %(length, width, height) qtutils.showInfo("Bounding Information", message) def IsActive(self): """There should be at least an active document.""" return not FreeCAD.ActiveDocument is None if __name__ == "__main__": command = MeasureCommand(); if command.IsActive(): command.Activated() else: qtutils.showInfo("No open Document", "There is no open document") else: import toolbars toolbars.toolbarManager.registerCommand(MeasureCommand())