import coordinates including point number, height and code
Moderator: andrew
Forum rules
Always indicate your operating system and QCAD version.
Attach drawing files and screenshots.
Post one question per topic.
Always indicate your operating system and QCAD version.
Attach drawing files and screenshots.
Post one question per topic.
import coordinates including point number, height and code
Hello.
This topic appears more often here (topic for land surveyors), but I did not find a solution. I'm trying use QCAD instead of Bentley products. I need import a list of measured points (txt file) in the format "point number", "Y", "X", "H" and "code". QCAD is 2D sw, so number, height and code can be displayed only as text (number to the left of the point, height at the top right, code at the bottom right). And optimally so that the number, point, height and code are in a separate layer. I can import points using the link https://qcad.org/en/tutorial-using-a-li ... oordinates, but that's not enough for my purposes.
Please help with the solution.
Thank you.
This topic appears more often here (topic for land surveyors), but I did not find a solution. I'm trying use QCAD instead of Bentley products. I need import a list of measured points (txt file) in the format "point number", "Y", "X", "H" and "code". QCAD is 2D sw, so number, height and code can be displayed only as text (number to the left of the point, height at the top right, code at the bottom right). And optimally so that the number, point, height and code are in a separate layer. I can import points using the link https://qcad.org/en/tutorial-using-a-li ... oordinates, but that's not enough for my purposes.
Please help with the solution.
Thank you.
- Attachments
-
- solution in MicroStation
- MicroStation.PNG (17.2 KiB) Viewed 10663 times
QCADpro 3.26.4.7 / Win10pro 64 bit and FedoraWorkstation_32 64 bit
Re: import coordinates including point number, height and code
Scripting is the way I think.
I offered it twice but left hanging when I asked if there was any kind of normalisation.
This time 5 things, mostly text, no blocks but different layers.
Its not that hard to put something in the drawing with a script.
Reading the source, casting this or that way and hardening for errors is complexer.
And now my time is limited ...
Regards,
CVH
I offered it twice but left hanging when I asked if there was any kind of normalisation.
This time 5 things, mostly text, no blocks but different layers.
Its not that hard to put something in the drawing with a script.
Reading the source, casting this or that way and hardening for errors is complexer.
And now my time is limited ...
Regards,
CVH
Re: import coordinates including point number, height and code
Hello,
thank you for answer.
There is no standard for displaying points. The habits of surveyors will be determined by their practice and software. Blocks will be preferred by AutoCAD users, layers by Bentley product users. In principle, it is generally a possibility to import, together with the point, additional information according to which the drawing is then realized. The standards are then except for the types of lines and cells, but they will be different for each country. As a user of Bentley products, I prefer layers due to the possibility of different views during processing and printing. In general, a simple import from a txt file (csv file) would be enough to display the required ID, point, H, code. In my case, this survey of points into MicroStation uses an extension for surveyors, which can do much more (quadrant selection, number of decimal places, attributes for layers, bidirectional coordinate transfer, the ability to transfer one, more or all points, etc.) but I understand that this is well beyond the scope of the simple import question. Here I am generally interested in the possibility of extended import from the input file.
Thank you for your time.
thank you for answer.
There is no standard for displaying points. The habits of surveyors will be determined by their practice and software. Blocks will be preferred by AutoCAD users, layers by Bentley product users. In principle, it is generally a possibility to import, together with the point, additional information according to which the drawing is then realized. The standards are then except for the types of lines and cells, but they will be different for each country. As a user of Bentley products, I prefer layers due to the possibility of different views during processing and printing. In general, a simple import from a txt file (csv file) would be enough to display the required ID, point, H, code. In my case, this survey of points into MicroStation uses an extension for surveyors, which can do much more (quadrant selection, number of decimal places, attributes for layers, bidirectional coordinate transfer, the ability to transfer one, more or all points, etc.) but I understand that this is well beyond the scope of the simple import question. Here I am generally interested in the possibility of extended import from the input file.
Thank you for your time.
QCADpro 3.26.4.7 / Win10pro 64 bit and FedoraWorkstation_32 64 bit
Re: import coordinates including point number, height and code
OK,
scripting is the way. I managed to solve my problem for one point. It's a good start, now the hard part - how to do it from input file.
The following set of commands creates layers, creates a point, and the desired text descriptions.
Tomek.
addLayer("point", "white", "CONTINUOUS", RLineweight.Weight025);
addLayer("number", "white", "CONTINUOUS", RLineweight.Weight025);
addLayer("height", "yellow", "CONTINUOUS", RLineweight.Weight025);
addLayer("code", "blue", "CONTINUOUS", RLineweight.Weight025);
setCurrentLayer("number"); addPoint (0, 0);
setCurrentLayer("number"); addSimpleText("500", 0,0, 0.15, 0, "Standard", RS.VAlignMiddle, RS.HAlignRight, false, false);
setCurrentLayer("height"); addSimpleText("507,300", 0,0, 0.10, 0, "Standard", RS.VAlignBase, RS.HAlignLeft, false, false);
setCurrentLayer("code"); addSimpleText("CODE", 0,0, 0.10, 0, "Standard", RS.VAlignTop, RS.HAlignLeft, false, false);
scripting is the way. I managed to solve my problem for one point. It's a good start, now the hard part - how to do it from input file.
The following set of commands creates layers, creates a point, and the desired text descriptions.
Tomek.
addLayer("point", "white", "CONTINUOUS", RLineweight.Weight025);
addLayer("number", "white", "CONTINUOUS", RLineweight.Weight025);
addLayer("height", "yellow", "CONTINUOUS", RLineweight.Weight025);
addLayer("code", "blue", "CONTINUOUS", RLineweight.Weight025);
setCurrentLayer("number"); addPoint (0, 0);
setCurrentLayer("number"); addSimpleText("500", 0,0, 0.15, 0, "Standard", RS.VAlignMiddle, RS.HAlignRight, false, false);
setCurrentLayer("height"); addSimpleText("507,300", 0,0, 0.10, 0, "Standard", RS.VAlignBase, RS.HAlignLeft, false, false);
setCurrentLayer("code"); addSimpleText("CODE", 0,0, 0.10, 0, "Standard", RS.VAlignTop, RS.HAlignLeft, false, false);
QCADpro 3.26.4.7 / Win10pro 64 bit and FedoraWorkstation_32 64 bit
Re: import coordinates including point number, height and code
The basics for reading a text source can be found here:
ImportPoints.js
the script that sits under Menu ... Misc ... Import/Export ... Import Points
In a standard installation only compiled present.
I have a copy of the sources from github at hand.
https://github.com/qcad/qcad
With the layer and the text thing you are on the right track.
Regards,
CVH
ImportPoints.js
the script that sits under Menu ... Misc ... Import/Export ... Import Points
In a standard installation only compiled present.
I have a copy of the sources from github at hand.
https://github.com/qcad/qcad
With the layer and the text thing you are on the right track.
Regards,
CVH
Re: import coordinates including point number, height and code
I was busy for a long time. However, below is the code for the required function (for other surveyors). GUI and other options (quadrant selection, attributes, coordinate order) would be desirable, but the basic functionality is solved. Thanks for the help.
include("scripts/EAction.js");
include("scripts/simple.js");
function ImportPoints(guiAction) {
EAction.call(this, guiAction);
}
ImportPoints.prototype = new EAction();
ImportPoints.prototype.beginEvent = function() {
EAction.prototype.beginEvent.call(this);
var appWin = EAction.getMainWindow();
var initialPath = QDir.homePath();
var filterAll = qsTr("All Files") + " (*)";
var fileDialog = new QFileDialog(appWin, qsTr("Import Points"), initialPath, "");
fileDialog.setNameFilters([ filterAll ]);
fileDialog.selectNameFilter(filterAll);
fileDialog.setOption(QFileDialog.DontUseNativeDialog, getDontUseNativeDialog());
if (!isNull(QFileDialog.DontUseCustomDirectoryIcons)) {
fileDialog.setOption(QFileDialog.DontUseCustomDirectoryIcons, true);
}
fileDialog.fileMode = QFileDialog.ExistingFiles;
if (!fileDialog.exec()) {
fileDialog.destroy();
EAction.activateMainWindow();
this.terminate();
return;
}
var files = fileDialog.selectedFiles();
if (files.length===0) {
fileDialog.destroy();
EAction.activateMainWindow();
this.terminate();
return;
}
fileDialog.destroy();
EAction.activateMainWindow();
var fileName = files[0];
var document = this.getDocument();
var di = this.getDocumentInterface();
var file = new QFile(fileName);
var flags = new QIODevice.OpenMode(QIODevice.ReadOnly | QIODevice.Text);
if (!file.open(flags)) {
this.terminate();
return;
}
var ts = new QTextStream(file);
ts.setCodec("UTF-8");
var line;
var coordinates;
addLayer ("point", "white", "CONTINUOUS", RLineweight.Weight025);
addLayer ("number", "white", "CONTINUOUS", RLineweight.Weight025);
addLayer ("height", "yellow", "CONTINUOUS", RLineweight.Weight025);
addLayer ("code", "blue", "CONTINUOUS", RLineweight.Weight025);
var operation = new RAddObjectsOperation();
do {
line = ts.readLine();
coordinates = line.split(',');
if (coordinates.length!==5) {
// skip line with invalid point format
continue;
}
var v = new RVector(parseFloat(coordinates[1]), parseFloat(coordinates[2]));
point = new RPointEntity(document, new RPointData(v));
setCurrentLayer ("number"); addSimpleText(coordinates[0], new RVector(parseFloat(coordinates[1]), parseFloat(coordinates[2])), 0.15, 0, "Standard", RS.VAlignMiddle, RS.HAlignRight, false, false);
setCurrentLayer ("height"); addSimpleText(coordinates[3], new RVector(parseFloat(coordinates[1]), parseFloat(coordinates[2])), 0.10, 0, "Standard", RS.VAlignBase, RS.HAlignLeft, false, false);
setCurrentLayer ("code"); addSimpleText(coordinates[4], new RVector(parseFloat(coordinates[1]), parseFloat(coordinates[2])), 0.10, 0, "Standard", RS.VAlignTop, RS.HAlignLeft, false, false);
setCurrentLayer ("point"); operation.addObject(point);
} while(!ts.atEnd());
file.close();
di.applyOperation(operation);
this.terminate();
};
/**
* Adds a menu for this action to Examples/Math Examples/ImportPoints.
*/
ImportPoints.init = function(basePath) {
var action = new RGuiAction(qsTr("&Import Points"), RMainWindowQt.getMainWindow());
action.setRequiresDocument(true);
action.setScriptFile(basePath + "/ImportPoints.js");
action.setGroupSortOrder(52100);
action.setSortOrder(100);
action.setWidgetNames(["MiscIOMenu", "MiscIOToolBar", "MiscIOToolsPanel"]);
};
include("scripts/EAction.js");
include("scripts/simple.js");
function ImportPoints(guiAction) {
EAction.call(this, guiAction);
}
ImportPoints.prototype = new EAction();
ImportPoints.prototype.beginEvent = function() {
EAction.prototype.beginEvent.call(this);
var appWin = EAction.getMainWindow();
var initialPath = QDir.homePath();
var filterAll = qsTr("All Files") + " (*)";
var fileDialog = new QFileDialog(appWin, qsTr("Import Points"), initialPath, "");
fileDialog.setNameFilters([ filterAll ]);
fileDialog.selectNameFilter(filterAll);
fileDialog.setOption(QFileDialog.DontUseNativeDialog, getDontUseNativeDialog());
if (!isNull(QFileDialog.DontUseCustomDirectoryIcons)) {
fileDialog.setOption(QFileDialog.DontUseCustomDirectoryIcons, true);
}
fileDialog.fileMode = QFileDialog.ExistingFiles;
if (!fileDialog.exec()) {
fileDialog.destroy();
EAction.activateMainWindow();
this.terminate();
return;
}
var files = fileDialog.selectedFiles();
if (files.length===0) {
fileDialog.destroy();
EAction.activateMainWindow();
this.terminate();
return;
}
fileDialog.destroy();
EAction.activateMainWindow();
var fileName = files[0];
var document = this.getDocument();
var di = this.getDocumentInterface();
var file = new QFile(fileName);
var flags = new QIODevice.OpenMode(QIODevice.ReadOnly | QIODevice.Text);
if (!file.open(flags)) {
this.terminate();
return;
}
var ts = new QTextStream(file);
ts.setCodec("UTF-8");
var line;
var coordinates;
addLayer ("point", "white", "CONTINUOUS", RLineweight.Weight025);
addLayer ("number", "white", "CONTINUOUS", RLineweight.Weight025);
addLayer ("height", "yellow", "CONTINUOUS", RLineweight.Weight025);
addLayer ("code", "blue", "CONTINUOUS", RLineweight.Weight025);
var operation = new RAddObjectsOperation();
do {
line = ts.readLine();
coordinates = line.split(',');
if (coordinates.length!==5) {
// skip line with invalid point format
continue;
}
var v = new RVector(parseFloat(coordinates[1]), parseFloat(coordinates[2]));
point = new RPointEntity(document, new RPointData(v));
setCurrentLayer ("number"); addSimpleText(coordinates[0], new RVector(parseFloat(coordinates[1]), parseFloat(coordinates[2])), 0.15, 0, "Standard", RS.VAlignMiddle, RS.HAlignRight, false, false);
setCurrentLayer ("height"); addSimpleText(coordinates[3], new RVector(parseFloat(coordinates[1]), parseFloat(coordinates[2])), 0.10, 0, "Standard", RS.VAlignBase, RS.HAlignLeft, false, false);
setCurrentLayer ("code"); addSimpleText(coordinates[4], new RVector(parseFloat(coordinates[1]), parseFloat(coordinates[2])), 0.10, 0, "Standard", RS.VAlignTop, RS.HAlignLeft, false, false);
setCurrentLayer ("point"); operation.addObject(point);
} while(!ts.atEnd());
file.close();
di.applyOperation(operation);
this.terminate();
};
/**
* Adds a menu for this action to Examples/Math Examples/ImportPoints.
*/
ImportPoints.init = function(basePath) {
var action = new RGuiAction(qsTr("&Import Points"), RMainWindowQt.getMainWindow());
action.setRequiresDocument(true);
action.setScriptFile(basePath + "/ImportPoints.js");
action.setGroupSortOrder(52100);
action.setSortOrder(100);
action.setWidgetNames(["MiscIOMenu", "MiscIOToolBar", "MiscIOToolsPanel"]);
};
QCADpro 3.26.4.7 / Win10pro 64 bit and FedoraWorkstation_32 64 bit
Re: import coordinates including point number, height and code
Great,
two things:
A) On this forum one can use a code plane (in editmode, above, icon 5)
(And you can edit your previous posts )
B) You should at least choose a unique script and function name.
Why not ImportSurveyorPoints?
For this you change any text 'ImportPoints' in the new name.
Next adapt the init section:
ImportPoints is 52100/100, MOL import 52100/200
The choise is yours 150 or 300
new RGuiAction: Adapt textual, the '&' is for the key-in navigator
Extra's: (but none is really required)
If you use it fairly often or when testing I add "MainToolsPanel" to the list setWidgetNames.
Finally, put your script under a subfolder of folder 'MiscIO' with the same name as the script except the extention.
Keep us posted.
Regards,
CVH
two things:
A) On this forum one can use a code plane (in editmode, above, icon 5)
(And you can edit your previous posts )
B) You should at least choose a unique script and function name.
Why not ImportSurveyorPoints?
For this you change any text 'ImportPoints' in the new name.
Next adapt the init section:
ImportPoints is 52100/100, MOL import 52100/200
The choise is yours 150 or 300
new RGuiAction: Adapt textual, the '&' is for the key-in navigator
Extra's: (but none is really required)
Code: Select all
action.setRequiresSelection(false);
action.setIcon(basePath + "/ImportPoints.svg");
action.setDefaultShortcut(new QKeySequence("Your sequence")); // Look up if free in APP.Prefs
action.setDefaultCommands(["Long command", "Shortcommand"]); // An Array
var tip = qsTr("What your function does");
action.setStatusTip(tip + " " + qsTr("somewhat more in specific")); // Overtakes and displays left in the Status Bar
action.setToolTip(tip); // Displays aside Toolbars
Finally, put your script under a subfolder of folder 'MiscIO' with the same name as the script except the extention.
Keep us posted.
Regards,
CVH
Last edited by CVH on Thu Jul 30, 2020 8:50 am, edited 4 times in total.
Re: import coordinates including point number, height and code
Now I come to think of it ...
I don't see startTransaction(...), nor endTransaction()
It's faster as a group and meanwhile it collects your castings in one operation one can undo in one go.
See: simple_transaction.js
The 'simple' form of operation.addObject(point); is addpoint(v);
You can reuse var v for any new RVector(parseFloat(coordinates[1]), parseFloat(coordinates[2])) that follows.
Andrew has not the habbit of putting more commands on one script-line.
Regards,
CVH
I don't see startTransaction(...), nor endTransaction()
It's faster as a group and meanwhile it collects your castings in one operation one can undo in one go.
See: simple_transaction.js
The 'simple' form of operation.addObject(point); is addpoint(v);
You can reuse var v for any new RVector(parseFloat(coordinates[1]), parseFloat(coordinates[2])) that follows.
Andrew has not the habbit of putting more commands on one script-line.
Regards,
CVH
Re: import coordinates including point number, height and code
What we don't appreciate in this forum!
Changing previous post content is extremely confusing for everybody who reads a thread and tries to understand how it came to a final conclusion.
Work smart, not hard: QCad Pro
Win10/64, QcadPro, QcadCam version: Current.
If a thread is considered as "solved" please change the title of the first post to "[solved] Title..."
Win10/64, QcadPro, QcadCam version: Current.
If a thread is considered as "solved" please change the title of the first post to "[solved] Title..."
Re: import coordinates including point number, height and code
In this case it looks better in a code plane.
The content remains the same.
CVH
The content remains the same.
CVH
Re: import coordinates including point number, height and code
I downloaded QCAD yesterday, so I too am a newbee, and am also interested in "Survey" Points Which are very different than regular CAD points, unfortunately we all call them by the same name "points". 20 years ago I reverse engineered the "survey" points from a major CAD program. What I think I remember was that they were actually blocks. One was a block with the point (x) with the insertion point extracted and containing the yxz (northing, easting, elevation) info. inserted into that block were three text blocks, one extracting the unique identifier (point number/name), next the extracted elevation number, next the extracted description/code, all four on separate layers. I am not a programmer, but let me know if any of this seems helfull, and I can elaborate much more.
Thank you,
WI-RLS
Thank you,
WI-RLS
Re: import coordinates including point number, height and code
QCAD 3.26.4 comes with a new tool to import point data with labels from CSV:
https://qcad.org/en/tutorial-importing- ... s-from-csv
https://qcad.org/en/tutorial-importing- ... s-from-csv