LISP that draws specific block with parameters to coordinates from file

First, allow me to introduce myself. My name is Wile E. Coyote, genius :D
Older members will know what this means :)

Now, I have a rather serious problem. To avoid details, I'm starting my own small business, which involves land surveying.
I'm familiar with BricsCAD, especially V13, because that's the CAD we're using atm.
Whan I start my own, I also plan to use BricsCAD as CAD tool.

All operations including importing surveyed points and stuff we're doing from Excel, using some macros or whatever it's called.
Basically, Excel ''reads'' data from sheets and draws stuff in BricsCAD. Of course, there are specialized ''survey softwares'' that do that, but...
This way is cheaper.

As stated before, since I'm starting my own small business, I will not be able to buy ''survey software'' at start, but I'm planing to do that when I earn some money.
Untill then, I am hoping to use few lisps to help me do that, import ''data'' into CAD.

I hope you understand my ''problem'' atm.

I will attach a .dwg file with blocks that I need to be inserted using data from .txt or .csv file.
Also, I will attach how it looks when it's inserted in BricsCAD.

For example, the most basic block is ''visina'', which is inserted at coordinates from file, and ''shows'' the elevation of that point.
Data for that would be some file that looks like: Pt_id, X, Y, Z
For example:
1, 1000, 1000, 100

And that lisp should draw block named ''visina'' at coordinates 1000, 1000, 100... and ''write'' 100 on screen.

The sam principle applies for other blocks, they just have a different set of values to be ''written'' and inserted in block.

Uffff... I kinda complicated it, I really hope you understand.

Anyway, I thank you in advance, hoping someone can help me with this.

Best regards, Goran.

Comments

  • In the image I see an attribute displaying a non-zero elevation, yet the block is inserted at Z=0. This does not match your description.

  • In the image there are 3 blocks, inserted at same point.

    Basically, it's not that important that all blocks have a ''real'' elevation, except the block named ''visine'', since these other blocks are ment to be, in the ''end'', delivered to local cadastre via CD. And they, atm, work with data (points) with X and Y coordinate, they are not ''interested'' in Z value (elevation), since their digital maps (points in these maps) have 0 elevation. In fact, they expect that entire drawing (lines, points, centroids...) delivered to them have 0 elevation.

    Only block called ''visine'' should have real elevation, since that block (drawing containing that blocks) will be delivered to architects for their projects.

    I hope it's more clear now.

    I know, it's kinda... well, not stupid, but... something not very good :)
    Since we (surveyors) collect a lot of data on the field, but atm... that is all that cadastre expects from us in .dwg file that we deliver - points (boundary or building vertices), lines (boundary and building outer lines) and centroids (defining the type of building etc.), all in specific layers.

  • I think you are not aware of blocks with attributes. This is a block that has special text objects. These attribute texts can be visible or invisible, preset or blank, set to prompt the user for a value, or not prompt them. Other utility programs can find and extract this information. In your case, I suspect your LISP routine should read the values from your database, then insert a special block that has attributes, and then populate those attribute fields.

    I have created a VBA program that runs within Excel, and sends a script to BricsCAD to BricsCAD. It does this in steps.

    1) Create a new, blank drawing
    2) Draw the object, and convert it to a block.
    3) Copy the block the clipboard, and close the temporary drawing.
    4) Switches back to the original drawing, with the past operation already started.

    The discussion may serve you in your own plans. But, it is spread out among several threads, as I struggled with various problems over the months that I created the program. (the links are below) The most important lesson was that if you want VBA to be able to talk to two programs, and one of the programs is running as administrator, then the other program must also be set to run as administrator.

    Here are some links that may be helpful;

    Generating a Script using a Spreadsheet » CAD Concepts
    http://www.cadconcepts.co.nz/news/generating-a-script-using-a-spreadsheet/

    Send AutoCAD Commands From Excel & VBA ~ My Engineering World
    http://www.myengineeringworld.net/2014/10/send-autocad-commands-from-excel-vba.html

    Here are some of my own threads about creating my VBA.

    Looking for alternatives to dynamic blocks - BricsCAD Forum
    https://forum.bricsys.com/discussion/32051/looking-for-alternatives-to-dynamic-blocks#latest

    Using SendKeys VBA command from Excel - BricsCAD Forum
    https://forum.bricsys.com/discussion/32147/using-sendkeys-vba-command-from-excel#latest

    A working Excel Spreadsheet with VBA to draw objects in BricsCAD - BricsCAD Forum
    https://forum.bricsys.com/discussion/32858/a-working-excel-spreadsheet-with-vba-to-draw-objects-in-bricscad#latest

    The following is a link I found after I created my program. It is LISP based.
    Solved: Lisp import excel data and place the blocks in the coordinates (start-end) - Autodesk Community
    https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-import-excel-data-and-place-the-blocks-in-the-coordinates/td-p/7240487

    I am sure you can find many other examples, now that you know what words to search for. I would expect that you can find some fairly well done LISP for free to do most of what you want. Then, you may be able to modify it to add more functions.

    I would search Google using; Survey LISP (Excel OR CSV)
    You might also try adding the words Attribute or Block.

    -Joe

  • Thank you, I will study this thoroughly.

    The problem with Excel is that atm everything is kinda working in Excel 2007, and my new Excel will be 2016, or higher as time goes by. I tried few ''old'' scripts from Excel 2007 in Excel 2016 (excel 365 to be exact), but it won't work.

    I even tried in another Excel 2007, but not at the same PC where those scripts work, and it won't work.
    Ok, it was just copy / paste of excel file with scripts, without ''modifying'' that other Excel 2007.

    So, atm I'm still not sure what's better, to do it with Excel or with lisps. Excel based solution tends to create problems when I'm not working on ''original'' PC, and lisps... well, lisps are lisps, it's much more convenient to work directly with / from Excel.

    Anyway, thank you, I'll have to study that, and figure out which solution is better.

  • Yes, the weaknesses you mentioned with Excel are true. For me, my main motivation for choosing Excel VBA is that I was already familiar with it. But, I think that LISP would have been a better choice in terms of long-term viability. This is especially true if you have your data in CSV format, which will not change.

    -Joe

  • GoranSV
    edited February 2018

    Well... data collected with GPS instrument, when exported to .txt file, looks like this. This is for a single point named A. Followed by coordinates (X, Y, Z), point description (Code - in this case POG)... and a lot of other data.

    A,299426.35,4968260.23,27.62,POG,HSDV:0.009,VSDV:0.019,STATUS:FIXED,SATS:11,AGE:1.0,PDOP:2.510,HDOP:1.100,VDOP:2.256,TDOP:0.580,GDOP:2.576,NSDV:0.007,ESDV:0.005,DATE:01-31-2018,TIME:13:57:49

    Depending on a request for a specific job, I need to insert predefined blocks containing some of that data.

    For example, for basic processing I need Point name (A), coordinates (X, Y, Z) and description... well, I need block inserted at X, Y, Z that ''shows'' point name, and description (Code).
    Ok, data like HSDV, VSDV and other is also useful because it shows precision of measured point... and other stuff... but it's not necessary for basic processing. You can always check those values in Excel, and ignore points that have high values for that - meaning these points are not reliable.

    When mailing to architects I need block inserted at X, Y, Z that ''shows'' Z (elevation), without point name and description.

    And so on...

    Excel is more convenient to manipulate with all that data, but as mentioned before... working with Excel has it's disadvantages.

  • Roy Klein Gebbinck
    edited February 2018

    @GoranSV:
    Lisp is very much suitable for processing this type of data. The core of what you want would not require a lot of code. But it is obvious that you want much more than a basic solution.
    If you search the Lisp forums you are bound to find some examples that you might use as a starting point for your custom solution.

  • Just a suggestion... you can use Excel, or you can write a proprietary database with a compiler by C, Pascal, or VBA. I use Pascal, but I parallel it with a simple XYZ ASCII file that includes point number and a description with the coordinates. I can operate with either. So if you don't want to be constricted to Excel or a compiler, you can do everything with a simple ASCII file. LISP works very well for manipulating, updating, setting, and reading data by an ASCII file. Point data can be clustered within a single block (named as Pnt0015, etc), which can be modified by moving items by double-clicking the block without changing the insert point and its cluster data. It is faster than a compiler with COM transfers, but I have never use Excel.

    Rick

  • @GoranSV said:
    Excel is more convenient to manipulate with all that data, but as mentioned before... working with Excel has it's disadvantages.

    You can still use Excel for the manipulation of the raw data, since it can open and save CSVs. There is always the warning that some formatting won't save. But, perhaps you can create a quick macro in Excel to save the CSV.

    There are probably only a few ways to manipulate the data that you would need. So, perhaps you can just do all it in lisp. To me, the biggest advantage of VBA, or other high level languages, is how easy it is to create a nice user interface. You could use VBA in BricsCAD if you have a a higher level version that includes it.

    -joe

  • I will probably try to find / modify / create few LISPs for each task. Basically, 3 LISPs for start (basic input, elevation input, 5-6 attribute input), until I buy ''decent'' software.
    Or at least 1 LISP, to import basic data - point_id at measured coordinates. I already have LISP for that, and I'll try to modify it to import (show) elevation. Or modify block to show other attribute. Or modify data file, and create ''elevation'' file, so that point_id is replaced with elevation. Instead of point_id, it will import (show) elevation. Anyway, some basic solution will be found :)

    For some time, I can probably do the other things manually, since I won't be doing some major jobs when I start.

    Anyway, thank you all for constructive suggestions. Ofc, every ''new'' suggestion or ''solution'' is more than welcome :)

  • Wiebe van der Worp
    edited February 2018

    Just some extra pennies...

    As Roy suggest, in LISP it is not hard to analyse text files and retrieve data. Example (in Dutch): http://wiki.nedcad.nl/3TLIN .

    Another construction we use: Let GDAL do conversions for you. In particular, ogr2ogr (http://www.gdal.org/ogr2ogr.html) can directly convert GIS data to DXF. The construction we use is in LISP, where LISP first builds a batch file. This file contains instructions for ogr2ogr. Then the batch file is ran. Then LISP takes care for inserting the generated DXF's and deleting the garbage (i.e. the DXF's and the batch file). Works on all operating systems.

    I highly recommend this method, since it is very straightforward and reliable.

  • Here is an example that can be used as a basis for further customization.

  • Thank you, I will try it as soon as possible... maybe tomorrow after I come back from field.

  • @GoranSV

    I am current working on a lisp based application for Land Surveyors. See attached pic of what the imported block looks like. It shows the point number, Descriptor and Elevation as attributes. These attributes are on separate layers so they can be turned on and off independently. You can also create your line work with a command to draw line work by entering the point number. You can then annotate your line work with the bearing and distance in various formats as shown in the ribbon menu. I currently finishing up my cogo and area computation module. It can read coordinate data from a .txt or .csv file. Attached is a sample file showing a space delimited coordinate sample.

    If you like, you can contact me at kevin@cadtechie.com and after I get some info from you, I can send you the application to use as a "beta tester". I will send updated versions as I add features.

    Where are you located and what units do you use?

    Many Thanks,
    Kevin

  • It should also be possible to include a routine that will examine all the 2D coordinate blocks, and extract the z-value to place the ''visine'' block in 3D space.

    In regards to having the z-value on a different layer, another approach might be to have that as a hidden attribute. There is a variable to tell AutoCAD to show hidden attributes. I don't know if this is also in BricsCAD. Though, I suppose the layer version may still be better, because you can turn them on/off for each viewport in a drawing. Plus many end users may not know about toggling hidden attributes on/off.

    -Joe

  • That looks like excellent work.

    Rick

  • GoranSV
    edited February 2018

    1st of all, thank you all for help, suggestions and advice.
    2nd... this week will be kinda ''hell'', because it's my last week in this company. Friday is my last day here, and from Saturday... I'm on my own :)

    So, please excuse me if I don't answer quickly, I have a lot of things to do. My current boss is pressing me to finish some jobs, I need to collect and deliver a lot of ''papers'' to various institutions, and so on...

    Anyway...

    @Kevin Simmons

    I'll be more than happy to contact You, and ''beta test'' Your application. I'm from Croatia, and my work is based here.
    We use meters as ''measuring'' units, and our drawings are in meters. Angular units... well, total station is measuring in grads, but drawings are in degrees, because everyone else works with degrees (architects and so), so we basically measure in grads, but deliver our product in meters / degrees.
    We work in HTRS96/TM, and I think this is it http://spatialreference.org/ref/epsg/htrs96-croatia-tm/

    Here is in .pdf, in Croatian and English https://www.google.hr/url?sa=t&rct=j&q=&esrc=s&source=web&cd=3&ved=0ahUKEwjIpcPT8Z_ZAhVCUhQKHUxdAmoQFggyMAI&url=https://hrcak.srce.hr/file/20088&usg=AOvVaw1N8UwCXdNamcAJi5bI1WMG

    If You need any more information, just ask :)

    Ah, yes... we can do it over the mail, it might be easier, I will contact You as soon as I get some time. Hope today.

  • GoranSV
    edited February 2018

    @Roy Klein Gebbinck

    Tried to run Your LISP... got problem with .dwg

    Invalid file version.
    The file seems to be corrupted.
    Try using ''Recover'' to load the file.

    After that... Shell command failed and so on... and shuts down my BricsCAD v13.

    My 1st guess is that Your .dwg is higher than BricsCAD v13 can open. So... if You can make .dwg in lower version, it would be great. Thank You.

    If not, I'll try to convert it somehow in lower version.

  • @GoranSV:
    I have downloaded the zip file and tested with V13. Everything works fine. Maybe something went wrong with your download?

  • ... Here is the dwg again (unzipped this time).

  • ProcessPoints.dwg Y U NO WORK :)

    Anyway, thank you for trying, but still won't open.

    Also, BricsCAD v13 went berserk on me :) It is... well, weird.

    When I draw pline, it shows line on the screen only when I click on 2nd point. When I click on 1st point and ''draw'', nothing, until I click on 2nd point.

    SNAP markers for endpoint (square), midpoint (triangle) and so do not show when I try to snap. It writes ''endpoint'', midpoint'', ''node''... but snap symbol won't show.

    When I try to select entities on screen... selection window (square) is kinda late. it doesn't follow the mouse (pointer), but kinda stays behind. But selects everything to mouse, no matter what selection window suggests will be selected...

    Ah, well, I hope you got the idea :)

    Will try to fix, but I don't have any idea how. latest drivers for GPU installed, win updates and stuff... blah...

  • @GoranSV said:
    Also, BricsCAD v13 went berserk on me :) It is... well, weird.
    When I draw pline, it shows line on the screen only when I click on 2nd point. When I click on 1st point and ''draw'', nothing, until I click on 2nd point.
    SNAP markers for endpoint (square), midpoint (triangle) and so do not show when I try to snap. It writes ''endpoint'', midpoint'', ''node''... but snap symbol won't show.

    I have the exact same issues I quoted above, on my v14. Though, i don't think I ever had them all at once. I have had these problems show themselves, off-and-on for years, but it was actually quite rare. Closing and then re-opening BricsCAD would normally solve it in the past. But, more recently, the lack of highlighting of entity snaps has persisted.

    I am guessing that there is some setting in BricsCAD that should toggle these types of displays. Each may have a different setting. For example, I think there is an option that will turn off the display of an object while it is being moved. But, I can't recall, or find them in the settings menu, or even the help files.

    I have never had the lagging selection window problem.

    -Joe

  • I will try to uninstall / install BCAD, and see what happens. If it doesn't help, I will... don't know, that's the problem of some other Goran... Goran from the future :smiley:

    But I have some weird feeling that it will become my problem soon :)

    Anyway, I will try that, and report here what happened. Because I can accept that snap and pline issues are result of some settings, but I can't accept that lagging selection window is caused by some settings.

This discussion has been closed.