How to write lisp program
Adding label. Add the name of the program:. Start BricsCAD and it should load label automatically. There are two solutions. Or steal the value stored in system variable LUPrec — the precision specified by the user through the Units command — under the not necessarily true assumption that the user wants consistent units. The code to do this is as follows:. That was the easy part.
The tough part is applying the precision to the x,y,z-coordinates, which takes three steps: 1 pick apart the coordinate triplet; 2 apply the precision factor; and 3 join together the coordinates. The exclamation mark forces BricsCAD to print the value of variable xyz, which holds the x,y,z-coordinates.
Your results will differ, depending on where you picked. LISP has several functions for picking apart a list. Here you use the car and cdr functions, and combinations thereof. The car function extracts the first item the x-coordinate from a list. Try it now: : car xyz 6. You use variable PtX to store the x-coordinate, PtY for the y-coordinate, and so on.
In addition, a form of LISP shorthand was used in the code above that allows you apply the setq function to several variables. Now that the three coordinates are separated, you can finally reduce the number of decimal places. There are a couple of ways to do this.
Use the rtos function, because it does two things at once: 1 changes the number of decimal places to any number between 0 and 8; and 2 converts the real number into a string. Why a string? For now, here is the rtos function at work:. The rtos function uses three parameters: ptx, 2, and uprec. PtX Name of the variable holding the real number. The number 2 is based on system variable LUnits, which defines five modes of units:.
UPrec Name of the variable holding the precision the code for that is at the beginning of this section. This varies, depending on the type of units. For example, a value of 2 for decimal means two decimal places; a 2 for architectural means quarter-inch. Assuming, then, that the precision in UPrec is 1, the rtos function in the code fragment above reduces 6. Notice that you can set a variable equal to itself: PtX holds the new value of the x-coordinate after rtos gets finished processing the earlier value stored in PtX.
Reusing a variable name like this helps conserve memory. With the coordinates truncated, you now have to string pardon the pun them together with the strcat function, short for string concatenation. Back to the text editor. Lsp labels a picked point with its x,y,z-coordinates. In the previous tutorial, we began to worry about user interface enhancements. What started out as two lines of code has now bulged out into In this tutorial, we learn how to fight feature bloat more later and add the ability to save data to a file.
Saving the data to file is easily done with the open , write-line , and close functions. Step 1. Open the file. Step 2. Write the data to the file. Step 3. Close the file. LISP has the open function for opening files. The function lets you open files for one of three purposes: 1 read data from the file; 2 write data to the file; or 3 append data to the file.
You must choose one of these at a time; LISP cannot do all three at once. In all cases, LISP takes care of creating the file if it does not already exist.
Turn on suggestions. Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type. Showing results for. Search instead for. Did you mean:. This page has been translated for your convenience with an automatic translation service.
This is not an official translation and may contain errors and inaccurate translations. Autodesk does not warrant, either expressly or implied, the accuracy, reliability or completeness of the information translated by the machine translation service and will not be liable for damages or losses caused by the trust placed in the translation service.
Back to Topic Listing Previous Next. Filter by Lables. All these functions outputs the printed representation of object to output-stream. The object is effectively printed and the output characters are made into a string, which is returned. It writes the characters of the specified substring of string to the output-stream. The function finish-output attempts to ensure that all output sent to output-stream has reached its destination, and only then returns nil.
The function force-output initiates the emptying of any internal buffers but returns nil without waiting for completion or acknowledgment. The function clear-output attempts to abort any outstanding output operation in progress in order to allow as little output as possible to continue to the destination.
The function format is used for producing nicely formatted text. Arnold Higuit. Only 75 emoji are allowed. Display as a link instead. Clear editor. Upload or insert images from URL.
Share More sharing options Followers 0. Reply to this topic Start new topic. Recommended Posts. Posted April 17, Dear Sir, i had 3 years experience in 2d, but i want to work with less effort and give more out put. Link to comment Share on other sites More sharing options JohnM Posted April 17,
0コメント