/** * Copyright (c) 2011-2018 by Andrew Mustun. All rights reserved. * * This file is part of the QCAD project. * * QCAD is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * QCAD is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with QCAD. */ include("../MiscBlock.js"); include("scripts/File/File.js"); /** * \class BlockRefExport * \brief This action exports block references and positions as CSV file. * \ingroup ecma_misc_block */ function BlockRefExport(guiAction) { MiscBlock.call(this, guiAction); } BlockRefExport.prototype = new MiscBlock(); BlockRefExport.prototype.beginEvent = function() { MiscBlock.prototype.beginEvent.call(this); var fileName = this.getFileName(); if (isNull(fileName)) { this.terminate(); return; } var file = new QFile(fileName); var flags = makeQIODeviceOpenMode(QIODevice.WriteOnly, QIODevice.Text); if (!file.open(flags)) { this.terminate(); return; } var ts = new QTextStream(file); setUtf8Codec(ts); ts.writeString("Block Name\tX\tY"); var doc = this.getDocument(); var block; var result = doc.queryAllBlocks(); result = doc.sortBlocks(result); for (var i=0; i