Here is a
collection of some of my lisp routines that I use very frequently on a daily
basis and are also often used by others in the office. They are very rough
and ready, but they do the job quite nicely. I have quite a few ideas to
beef them up, but I'm sure there are many other coders out there that will
also enjoy toying around with them and tidying them up.
Add or subtract a constant from a selection set of text.
This routine will automatically screen out non text entities and text
entities that are not numerical and then apply the constant (+ve or -ve) to
the remaining numerical text entities.
Units Conversion Calculator v2.0 2002
This lisp routine will convert most units in the following categories:
The first dialog requests that you choose which category of
units you wish to convert.
The second dialog requests that you choose the units to convert from and to.
You can type in a value for the measurement of the convert from units in the
space provided, then click convert, and the calculation is done. The default
conversion value is 1. Accepting this when clicking convert will give you
the actual conversion factor.
Co-ordinate Table Generator
Important: Your UCS must be set to read the correct coordinates
First prompt "Write co-ordinates to file y/N:". If you reply YES,
you will be prompted for output filename and then "Format for file (C)omma
delimited <(S)paced>:". The default extension for the file will
Comma delimited, Label Y-coord X-coord and Level will be separated by
Space delimited, Label Y-coord X-coord and Level will be separated by spaces
(same as TAB delimited).
You will then be prompted for the table insertion point, then the rotation
angle for the table followed by the scale of the drawing (this is the scale
that you intend to plot the drawing at).
A dialog box will come up asking if you want to include labels, if yes, then
if you wish to type them in or pick them as text entities from the drawing.
The same for the levels, with added option to automatically read levels from
3D node points. Remember if you choose to type in the values, all of the
values have to be typed, similarly if you choose to pick values all of the
values have to be picked. As you pick the points you will see that the table
starts taking shape.
When you are finished picking points press enter. You will then be prompted
for the table heading.
Import Co-ordinates from file
You will be prompted for a file to read coordinates from file. The file can
be Comma delimited or Space delimited. The comma delimited file must be in
the format :
The space delimited file must be formatted as :
Label Y-Coord X-Coord Level
The file can be manually typed with at least 6 spaces between each column.
If all the Labels are of the same length eg 3 digits and the other columns
also the same length then the spaces may be changed for tab spacing.
After you have selected the file, you will be prompted as follows :
Scale of drawing, number of decimals and rotation angle for text.
Then you will be asked what format the file is in Comma or Space delimited.
The points will then be read in from the file and placed as follows :
a point will be drawn on POINTS layer, the level will be placed on
ELEVATIONS layer and the label will be placed on CODES layer. Point size and
shape can be controlled with PDMODE and PDSIZE. Colors are all BYLAYER.
Embankment Line Generator
Chainages Lisp Routine
This lisp routine will draw chainages at user defined intervals along a 2D
polyline. It use a block called "sv.dwg" which contains a single
attribute for the chainage text. IMPORTANT: the chainages will go from the
start of the polyline in the direction that it was drawn.
As a bonus you can also number bend points or PI's (points of intersection
of curves) by typing BENDS (currently this only numbers the ends of the
polyline segments, it does not number the intersection of straights at
This routine will label the northing(X-coord) and easting(Y-coord) of a
Important : UCS must be set to read correct co-ordinates.
You will be prompted for scale of drawing, number of decimals for
coordinates, rotation angle for text and then to pick points or enter to
Create Longsection from 2D Contours DC_LSEC.lsp v1.0
Operation of the routine :
1. Type DC_LSEC at the command prompt.
2. You will be prompted as follows :
Horizontal scale: This is the horizontal scale you wish for the longsection
(it is assumed that your contour drawing is full scale ie 1:1)
Vertical scale: This is the vertical scale for the longsection.
Datum: This is the datum level for the longsection.
Start of longsection: This is an arbitrary point near to where you would
like your longsection to start
The chainage 0 will be you first point or contour picked.
End of longsection: This again is an arbitrary point near the end of your
The end chainage will be the final point that you pick.
You are then prompted to pick points along the line drawn for your
longsection. At each pick you are prompted for a level of contour. The
routine will automatically snap to intersection of the line and contour but
you may pick a point (spot height) anywhere in between the contours.
Upon completion of picking points press enter and then you will be prompted
to pick insertion point of longsection. This is the intersection point of
the Datum and chainage 0.
3. The longsection will now be drawn and upon completion you will be
prompted as follows:
Horizontal grid spacing: This is the distance between the vertical lines
that will be drawn as a grid over the longsection.
Vertical grid spacing: This is the distance between the horizontal lines of
the grid. Each of these lines will be labelled with a level relative to the
Section Arrow Lisp Routine
This routine will automatically insert, align and label section indication
arrows. If ortho mode is off, the arrows will be aligned with the points
picked. If ortho mode is on, the arrows will align with the UCS. User input
required is to pick the two points on either side of the
"section", you will then be prompted for the section label.
Slope Annotation Lisp routine
This routine will prompt for (in order) text height, text angle, prefix
(enter for none), start number, final number and increment. Then simply pick
the position of each consecutive number in order from start to end. This is
useful for numbering erven or town plot layouts.
Create a file of co-ordinates by picking points from the
You will be prompted for the file name and then a dialog box will come up
asking if you want to include labels, if yes, then if you wish to type them
in or pick them as text entities from the drawing. The same for the levels.
Remember if you choose to type in the values, all of the values have to be
typed, similarly if you choose to pick values all of the values have to be
picked (MTEXT and attributes are not recognised).
When complete press enter and the file will be closed.
This routine does just that ! It takes each selected block entity and adds
the angle input by you to each block entities current rotation angle, i.e.
the blocks in your selection set need not all have the same rotation angle.
Positive angles are measured counter clockwise and negative angles are
This routine does just that ! It takes each selected text entity and adds
the angle input by you to each text entities current rotation angle, ie the
text in your selection set need not all have the same rotation angle.
Positive angles are measured counter clockwise and negative angles are
Use this routine if you are changing the scale of a drawing, or, if you wish
to change the size of text within a drawing. This is very useful if you have
various text heights and you do not want to lose the proportions of these
You will be prompted for the old scale of the drawing and then the new scale
for the drawing. A scale factor is then calculated.
You are then prompted to select the text. You can use "ALL" as
your selection set as non text entities will be ignored. The scale factor is
then applied to all text entities found.
Survey Co-ordinate Grid SGRID.lsp version 3.1
Explanation of Dialog Control Box:
Northing: This is the notation for the axis (latitude) that you wish to use.
In the southern hemisphere this will normally be X. If you select X here
your easting axis will automatically be labelled Y
Text Orientation: This determines whether the text will be written Upright
or Inverted. This will depend on the orientation of your UCS. Normally we
orientate our drawings so that North points towards he top of the screen but
in order to read correct co-ordinates our UCSICON is rotated so that it
points to the bottom of the screen. In this case to get your text written so
that it is correct on screen you select the text to be inverted.
Text Alignment: This determines whether the text will be Aligned (parallel)
with the axes or Horizontal. Again this would depend on your current UCS.
Horizontal will align the text to the x-axis of your UCS.
Cross Length: This will determine the size of the cross at each co-ordinate
point. The length that you input here will be scaled according to the
Drawing Scale as discussed later. I have found that a good size to use would
Grid Style: This determines the style of grid you wish to use. If you choose
Full you will be prompted for the lower left point of the grid and then the
upper right point of the grid. The routine will then draw in all the grid
crosses and co-ordinates that will fit between these two points based on the
Grid Interval that you have selected. If you choose Partial you will be
prompted to pick points for each grid cross where you want each of them to
Grid Interval: This will determine the spacing of the crosses. You will
notice that the grid snap is set to this spacing that you choose, this is to
make it easier for picking the points as discussed in Grid Style.
Drawing Scale: This will scale the cross length and the text height. The
text height is programmed such that when plotted out the text height will be
3D Node Ordinate Table
This routine is used for creating a table of X, Y and Z ordinates of 3D
objects by picking the points to be co-ordinated. It will also give the
option to add a label to each set of ordinates.
Once the 3D object has been set up in the 3D view that you wish and the UCS
is set to view. Load the lisp routine XYZTBL.LSP and type
"3DTABLE" at the command prompt. You will be prompted for
insertion point of table, then rotation angle, scale and number of decimals.
The dialog box will then be shown, asking whether or not you wish to label
points. If you choose to label points you are further prompted to opt to
enter or pick labels. Enter labels requires keyboard input when requested
and pick labels requires you to pick text entities that were put in prior to
running the lisp routine using normal drafting methods. (NOTE this pick
label routine does not recognise MTEXT entities). The table of ordinates
will be created as you pick the points. When finished picking points, press
enter and you will be prompted for the table heading. All of the above will
be placed on a layer COORD_TBL which is automatically created and made
current by the routine.
About the table:
The layer coord_tbl will have a colour assignment of yellow and linetype
The text style will be the current style and colour yellow as well, and
height 2.5mm x the scale specified.
The table heading will be color red and height 3mm x scale specified.
The columns will be as follows: Node 15mm wide
X,Y,Z 25mm wide.
You can download DC-Tools here.
( 98kb )