PDA

View Full Version : Macro to plot in AutoCad Lite 2004



mdmackillop
08-10-2005, 09:25 AM
I'm trying to assist a colleague with an AutoCad project, but I know nothing about coding for this application, or even if it can be done with this version.

I have a number of tables of degrees and distances from a pipeline survey and I would hope that with a simple macro, I could get AutoCad to import the data and draw these lines. Ideally, I would like to place a cross or other marker at the end of each line, but this is not critical. The data is in Excel, but can be exported to a text file etc. if this is simpler to handle.

Regards
MD

Tommy
08-10-2005, 10:28 AM
Hi MD, :hi:

This cannot be done in AutoCad Lite. I could write a script to run, draw lines setup dwg etc, write dxf, however you want. The main problem is AutoCad Lite will not take Autolisp, VBA, ARX or anything else. Anyway this can be done, just not the obvious way.

Unless you specify differently the degrees is the direction of travel and the dist is the length of travel. THe start point will be 0,0 unless specified otherwise, a cross with a circle will be inserted at each intersection(point).

lucas
08-10-2005, 10:34 AM
Question Malcolm,
Does each row represent a line that is attached to the line represented by the row above it?

Hope you can understand what I'm getting at. I don't think they would all start at the same point of origin?

Also is measurement in meters, miles, etc. or does the unit matter?

I think Tommy and I were posting here at the same time....

lucas
08-10-2005, 10:36 AM
Hey Tommy,

Glad you showed up.:hi:

Tommy
08-10-2005, 11:54 AM
MD, If you don't mind will you check this out and see if this is what is required? It works in Acad. You will need to open acad lite and and run the script in "C:\acad" called "PlotCords.scr"

Let me know :)

mdmackillop
08-10-2005, 03:16 PM
Hi Steve,
Distance is in metres. This is a survey along a pipeline and the positions are Flag points. I eventually need a line connecting these points and a position of the Bases used in the survey. The drawn lines are not required and will be deleted from the final presentation. Our AutoCad Technician is quite proficient, but it just seemed unnecessary to type in all the data, hence the request.
Tommy,
I can't try this at home, but will give it a go tomorrow.
Thanks
Malcolm

lucas
08-10-2005, 05:17 PM
Hi Steve,
Distance is in metres. This is a survey along a pipeline and the positions are Flag points. I eventually need a line connecting these points and a position of the Bases used in the survey. The drawn lines are not required and will be deleted from the final presentation. Our AutoCad Technician is quite proficient, but it just seemed unnecessary to type in all the data, hence the request.
Tommy,
I can't try this at home, but will give it a go tomorrow.
Thanks
Malcolm

Your right about it being unnecessary to type in all the data and Tommy's solution looks top notch Malcolm. I'm anxious to hear how it works out for you.

Tommy
08-10-2005, 06:12 PM
Malcolm if you can tell me exactly what is required from this data I can adjust as required. If this is in Autocad instead of Autocad Lite let me know, the script will run either way, a few steps could be eliminated if it was actually Autocad. Not to mention more automation.

mdmackillop
08-11-2005, 09:26 AM
Hi Tommy,
Very close to ideal. I've adjusted the code a little as the co-ordinates
were all measured from one location. I think your calculation moved from one point to the next.
I've also added the facility to create the script name based on the ActiveCell value, and to create the file from the data at that location.

Further refinements if possible:
1. Draw a line between points if they are described as a Flag. This represents the pipeline location. (I've tried an "If" function which is partly successful). The other points are survey bases, which should be shown as isolated points.
2. Add a label next to each point as shown. (Please note the labels indicated have been added for demo purposes, and may not be correctly placed.) Any labels landing on the line will be moved manually for the final presentation.

This is going to save a great deal of tedious data entry. Thanks for your help.

Regards
Malcolm

Tommy
08-11-2005, 11:10 AM
I think your calculation moved from one point to the next.
Further refinements if possible:
1. Draw a line between points if they are described as a Flag. This represents the pipeline location. (I've tried an "If" function which is partly successful). The other points are survey bases, which should be shown as isolated points.
2. Add a label next to each point as shown. (Please note the labels indicated have been added for demo purposes, and may not be correctly placed.) Any labels landing on the line will be moved manually for the final presentation.

This is going to save a great deal of tedious data entry. Thanks for your help.

Regards
Malcolm

This is all real doable. I will work seriously on it tonight. Is there a file that needs to be read or is the information in an excel file? btw I changed the circles and lines to a POINT set at 5% screen resolution. I can adjust the text NP and draw the lines NP. Just to make sure all points are relative to 0,0 right? (or the input in cell)

mdmackillop
08-11-2005, 11:19 AM
Hi Tommy,
Yes, all the points are relative to 0,0 (this is the theodilite position).
I don't understand NP, but I'm sure its OK
I'll be adding this all into the workbook with the data and copying the relevant blocks of data into one worksheet, from here I can run the code to create the script files.

Tommy
08-11-2005, 11:32 AM
NP = No Problem
Do I need to check for a range of cells? or is a 1000 lines of data going to be ok?

mdmackillop
08-11-2005, 11:36 AM
:beerchug:
50 rows will suffice. There are a lot of small sections and I can adjust this if things change in the future.

Tommy
08-11-2005, 12:36 PM
Here Ya go. If there is trouble with the text set the text size to 3.
The text is there, the lines are drawn just for flags, and the points are there some tweaking can be done to speed up the editing process, so let me know what you need:yes

mdmackillop
08-11-2005, 01:09 PM
Hi Tommy,
This looks vey promising. Our surveyor used to draw his results in two weeks and wore out three sets of spectacles doing this. I reckon a couple of hours now!
Regards
Malcolm

Tommy
08-11-2005, 01:28 PM
LOL I'd find a reason to stay at the computer too, dragging that stripped stick around the swamp attracts the wrong kinda critters around here. Lots of teeth, a really big grin, all this is attached to those eyeballs that were floating just a little ways over there.:wot Yeah I think I would find a way to work on the computer longer. :yes

If I need to create and put certain items on different layers let me know. If this works like it is supposed to, changing layers/colors/linetypes will be easy.

mdmackillop
08-13-2005, 02:52 AM
Hi Tommy,
This is now working well. After I found that I had forgotten to change cell references for the Polar line, it all fell into place. I'll speak to our ACAD technician on Monday re any use for layers.
Thanks again
Malcolm

mdmackillop
08-19-2005, 11:15 AM
Hi Tommy,
A strange problem here!:banghead:
The script appears fine, checked against calculated data, but some points are being superimposed on each other. The attached drawing is based on the data listed at AB1 on the spreadsheet. Any ideas? (The scr files are written to C:\ACAD)

Tommy
08-19-2005, 11:24 AM
Malcolm,
I have to change the version from 2004 to 2000, I would like a corrected copy also (if this is not already done). I am just letting you know I am working on it :), but it may take a while.

mdmackillop
08-19-2005, 12:33 PM
Hi Tommy,
I've saved one that happened to come out correctly on my PC here, along with a copy of the overlap alongside. Also, a copy of Halbeath Farm, drawn on my home PC, but shows similar overlap errors!

Tommy
08-19-2005, 12:58 PM
Lets try this first. Polar tracking turn off, object snap turn off (this is most likely the problem), these will be under tools - drafting settings.

I have a question. Why the -1 in polar?

mdmackillop
08-19-2005, 01:19 PM
The theodolite measures angles clockwise, AutoCad, anticlockwise so this corrects the layout error. In the past we copied and flipped, but that is not so handy with text.

Turning off as suggested has got it! Thanks once again.:cloud9:

Tommy
08-19-2005, 02:23 PM
In units there is a switch to do that :) but it only works when you draw by hand :( in code you have to subtract 360.

I wrote a lisp program once that we had that problem on took about 2 days to figure it out. It worked correctly on 18 just a lot of dots on 6, it was during a roll out for 52 pcs, now that is the first thing I check when problems show up inconsistent from my pc to another CAD pc.

mdmackillop
08-19-2005, 02:48 PM
As I said, AutoCad is not a programme I use at all, but maybe learning some of this script code might help production in the office, although we don't do a lot of this type of plot. I'll be having a close look at this in due course.