Lisp For Autocad Software. Terrain for AutoCAD v.1.1. Terrain for AutoCAD is a terrain modeling plug-in for AutoCAD. This plug-in gives AutoCAD the ability to create a terrain mesh from a set of unordered points, lines, polylines and splines.
I have posted an AutoCAD tip how you can create your own label coordinate in AutoCAD using block attributes. It is nice that you can create your own block, create your own block shapes, and customize it to look anything you want to.
But there is a limitation. It will only recognize the point position from global coordinate. If you move the UCS, it will still use global coordinate. It makes sense, because if we want to label our coordinate, then usually we do use global coordinate. But what if you want to label the coordinate from UCS?
Because I’m currently learning AutoLISP, then I decided to take it as a challenge to create a program to do that. You can download the file in link you’ll find below this post.
How to use the program?
- Download the LISP file
- Load the LISP program. There are several ways to load AutoLISP program, but this is the easiest way.
- I wrote the code to run when I type LB then [enter]. You should be able to use it after you load the program.
- You need to click twice: the point you want to label and label location.
- It will use leader command. So if it’s too large, too small, or you want to customize it, change your style.
- It is also use file UNITS settings. If you want to change the format to decimal or architecture format, change it in UNITS settings.
- The program will continue to ask you for points until you press [esc] or [enter]. I decide to make it this way because mostly we want to create several labels at once. So you don’t need to reactivate it after you have labeled one point.
If you are following AutoLISP tutorial in CAD Notes, be patience! We will get there. Here is the code.
; Automatic coordinate labeling
; Edwin Prakoso
; https://www.cad-notes.com
;
; Limitation
; ----------
; Will use current leader style and current units setting
(defun c:lb (/ p x y ptcoord textloc)
(while
(setq p (getpoint '
Pick Point: '))
(setq textloc (getpoint '
Pick Label Location: '))
(setq x (rtos (car p)))
(setq y (rtos (cadr p)))
(setq z (rtos (caddr p)))
(setq ptcoord (strcat x ', ' y ', ' z))
(command '_LEADER' p textloc ' ptcoord ')
)
)
And if you want to simply download and use it, download this file. There are two files in the zip file.
- LB.lsp is for Labeling Coordinate (X and Y only)
- LBZ.lsp is for Labeling Coordinate (X, Y, and Z)
Enjoy the LISP, and share it to your friends!
Notes: After I wrote this, I realize that Shawki abo zeed have published similar code in labeling coordinate tips. It looks it has more features. If this one doesn’t work fine, you may want to try his code too. Thank you to Shawki!
Saving the AutoLISP File
Before we can run any programs we must make sure that the program file (.lsp file in this case) resides on the system.
If you are downloading programs from my site, the method of saving the AutoLISP file may depend on the browser you are using. For example, IE8 may prompt you to save the file directly to your computer, but I believe Firefox allows you to view the file contents in the browser itself, in which case, you can either go to File » Save Page As making sure that the Save as Type panel is set to All Files; or, you can simply copy the contents into an open Notepad file and save this as 'filename.lsp' (again, ensuring File Type is set to 'All Files').
Note that the filename used to save the source code is arbitrary and will not affect the program in any way - however, the majority of users use the function syntax (and perhaps include the program version) for convenience.
Loading the Program
Method 1: Using AppLoad
At the AutoCAD command line, type AppLoad (alternatively go to Tools » Load Application).
Select the program file as previously saved and click Load to load the program into the current drawing session. Click Close to close the Appload Dialog.
The command line should display whether the program has indeed loaded successfully, and any loading messages the author may have decided to include.
Method 2: Using the ACADDOC.lsp
Another way to load an AutoLISP program is to include a load call in the ACADDOC.lsp.
Everytime a new drawing is opened, AutoCAD will search the Support Paths for any ACADDOC.lsp files, and will proceed to load the first one it discovers.
First we must check that an ACADDOC.lsp file exists - to do this type at the AutoCAD command line:
If this returns a filepath, navigate to the existing ACADDOC.lsp file and in the steps that follow, amend its contents.
Else, you can create a new ACADDOC.lsp file by opening a new Notepad document (or other plain text editor) and saving it as ACADDOC.lsp in an AutoCAD Support Path (ensuring the Save As Type panel is once again set to All Files).
In the ACADDOC.lsp, add a line similar to this:
If the LISP file does not reside in the AutoCAD Support Path, a full filepath is needed so that the LISP file may be located; in this case, be sure to use double backslashes when specifying the path.
Mtk usb serial port driver x86 assembly language system. Download MTK USB All Drivers. MTK USB All Driver is compatible with all versions of Windows OS, including Windows XP to Windows 10 (x32 or x64 bit). If in case you were looking for the latest version of the MTK USB All Driver, then use the following links to get it on your computer: v0.8.0: MTKUSBAllv0.8.0.zip. V0.8.2: MTKUSBAllv0.8.2.zip.
When finished, open a new drawing and the LISP files should load.
Note: if using this method to load many LISP files on startup is causing drawings to open slower, refer to my tutorial on the use of AutoLoad to demand load LISP files.
Method 3: Using the Visual LISP Integrated Development Environment (VLIDE)
This method is aimed primarily at developers, as the VLIDE offers many debugging utilities when writing & loading code.
To load a program using this method, type VLIDE at the AutoCAD command line. In the window that subsequently appears, go to File » Open File (alternatively, Ctrl+O), and select the previously saved file.
Now go to Tools » Load Text in Editor (alternatively, Ctrl+Alt+E)
Running the Program
If the program has loaded successfully, you can now proceed to run the program in the current drawing session.
The syntax (command name) to call the program may be displayed in the author's loading messages, or perhaps noted in the program header. If it cannot be found in either of these locations, you can inspect the source code itself to determine the command to use.
The syntax will be located after the c: in a defun function call, for example:
In the above example, the command would be MyCommand.
If the c: does not appear after the defun function, this indicates that the function is a subfunction and is designed to be called from another program.
When the command syntax is known, it may be typed at the AutoCAD command line to invoke the program.
Loading Programs Automatically
See my tutorial on Loading Programs at Startup