|
|
| Home » Knowledge Base » Knowledge Base Article | Login | Become a Member | What's New | Site Map |
|
WOODWEB DISCLAIMS any and all RESPONSIBILITY and LIABILITY for the accuracy and application of the information below. Readers agree to evaluate the significance and limitations of the information provided, and accept full responsibility for the application of this information. Read More ... |
|
|
Would you like to add information to this article? Interested in writing or submitting an article? Have a question about this article? Macro to Note Dimensions in CAD Question
Here is the macro: ^C^C_pedit;\;;_list;@;;_explode;last;_dimangular; @;t;$M=$(substr,$(getvar,PERIMETER),1,$(-,$(strlen,$(getvar,PERIMETER)),$(-,8,$(getvar,dimdec))));\ Forum Responses
;Save to dimarc.lsp file and
(cons 1 (rtos ArcLength 4 5));<-------
From the original questioner: Thanks. That actually worked, considering I've never done it before. Here's my recap: I went to vlisp (never been there before), typed in the ...string... and then used the command, but it was never saved. So I assume that's why it won't work in any other drawing. Any advice? From contributor J: Type vlisp Enter the lisp routine Save the lisp routine in a folder that you can find In AutoCAD type appload Click on the suitcase where it says start up suite Navigate to the folder where you saved the lisp file and add it to your start up suite Close AutoCAD, start AutoCAD and it will be there every time you open a new or old drawing If you run the lisp routine from vlisp it will go away when you close the drawing and you will have to reload it every time you want to use it. By adding it to your start up suite, it will automatically load for you.
From the original questioner: That's just what I needed - thanks. From contributor B: I too am a rookie when it comes to lisp routines. Is there a way to change modes on the fly? Some drawings may require (2) decimal format while others may require (4) architectural (ft and fractional) or others may need (5) fractional, etc. Thanks in advance for any further advice on this. From the original questioner: Correct me if I'm wrong, but the lisp file above lists all units in order to mimic the dim style, and not actually use it. For some reason, when I use it its dim-ing in arch units, but I actually use fractions with a suffix (") in order to dim in inches. So how do I ensure it uses the correct units and is there a way to rewrite the fraction units to incorporate the suffix? From the original questioner: Nix the units part - I found where you specified which to use (still trying to learn the lingo). But I've still yet to figure out where to add a suffix. From contributor J: See the section of the code above: (cons 1 (rtos ArcLength 4 5));<------- (assoc 1 dimobj)dimobj)) (entmod dimobj)) (princ "\nThat ain't no arc")) (princ)) Replace it with this:
I changed the type to fractions by changing the #4 to a 5 in the statement (rtos ArcLength 4 5). The first # represents the type to display, hence the 1-5 list at the beginning of the post. The second # is the precision. When dealing with fractions (first # is set to 5), the precision is how the fraction is displayed. 1 = Whole number (if a dimension is 2 ½ it will read 2)
If you notice, the replacement code has something added (strcat(rtos ArcLength 5 4) “\“”)). Here is how this code fragment breaks down. The ArchLength is a variable that holds the actual arch length of the arc you selected. (Example: 15.7500) Rtos is a lisp command that converts a real number (that’s a number that has a decimal in it) to a string (that is anything enclosed in quote marks “15.7500”). The two numbers you see after ArchLength tells Rtos how to convert the variable ArcLength. In this case, we told it to use fractions by putting the 5 in there and we want a precision of 1/16 so Rtos now returns “15 ¾”. Now we add another lisp command strcat. This command combines several strings into one single string. Notice the “\””. This is a string that contains \”. Remember, a string always starts with a quote” and ends with a quote” so to turn \” into a string you add the starting and ending quotes “\”” (are you lost yet?). The \” will create the inch mark you asked for. So strcat puts the two strings “15 ¾” and “\”” together to make 15 ¾”. Any questions?
From the original questioner: Thanks so much - you have helped me tremendously. Now the command works! From contributor J: Contributor B, you can tackle your request two different ways. First way:
2. Do a save as new name.lsp 3. Repeat the procedure until you have a routine set up for each type that you want. 4. Now add them to your start up suite. You can either type the name of the routine or you can create a couple of buttons to call the various routines for you. Example: if you named one of the routines c:dimarc2, make a button and enter the macro ^C^Cdimarc2; and it will call the routine when clicked. The ^C^C clears the last command. You don’t need to put the C: just the name and make sure you put the semicolon at the end. Second way (on the fly):
You can’t use the word type because it is a lisp command, so let's use typ and prec. Now set up the prompt question you will be asked. To keep from entering bad input, we will use the initget command to limit what the response will be. (initget “S D E A F” 1) the s is for Scientific. The d is for decimal and so on. You can delete the letter of the ones that you don’t want, just make sure there is a space between each letter. Now prompt for the answer (answ is the variable that will hold the prompt answer).
Now write a couple of if statements to set the two variables to what you want. I suggest that you predetermine the precision for each type to keep things simple. On with the show. I’ll do one, you do the rest. You will need one for each available answer. (if (= answ “S”)(setq typ 1 prec 3));_end if Scientific ß-- this is a note.
Now create the other if statements, one for each type you want. Now we have three things to do.
2. Find a place to put all of the cool code we created at the beginning. Looking at the code, contributor D was anticipating user error, like any good programmer should. You will find a spot right after it asks you to “Select an Arc” that double checks the selection to be an “ARC”. If the object is an ARC, it processes the next lines of code. If not, it bypasses them and goes to a message “This ain’t no arc”. So we want our stuff to be in the part that only runs if the object is an arc. That is right after the lisp command (prong . Paste all that radical new code you created right after the (prong
3. Kill your variable! As a good programmer, you give life and must take it away. Otherwise, your variable will get you when you least expect it. They have no respect for their creator and therefore must die when they are no longer needed. To kill your variable, simply add them to the ones contributor D created
Save your routine now! Load it up and give it a spin, if it works. Great job! If it crashes your computer and it explodes into a billion pieces, I never met you and don’t have a clue what you're talking about.
From contributor D: The third way might be just to replace the line (cons 1 (rtos ArcLength 4 5)) with (cons 1 (rtos ArcLength (getvar "LUNITS")(getvar "LUPREC"))) This should pick up your current unit settings. From contributor J: First of all, that would be way too easy and it would work in some cases. The precision of a dimension is not controlled by luprec and the type of dimstyle is not controlled by lunits, but you did hit the nail on the head. The fourth and final way is to replace
This will pick up your current dimension style settings.
(setq dimobj (entget (entlast))
place the above code between:
Have you reviewed the related Knowledge Base areas below?
|