|
|||||||
| Hot Tip Harry: AutoCAD Customization Cadalyst's popular Hot Tip Harry and his entourage are here to assist you with AutoCAD customization. Request help with a programming problem, locate a needed routine, or just keep up with Harry's latest activities. You'll find Harry's archive of AutoLISP and VBA code and hatch patterns at www.cadalyst.com/cadtips. Moderated by R.K. McSwain. |
|
|
Thread Tools | Display Modes |
|
#1
|
|||
|
|||
|
Hi,
Just wondering if there is a lisp for this command. With the lengthen command, when you lengthen something (Delta option) you have to either specify a positive number (for increasing length) or a negative number (to decrease length). What i am looking for is an option similar to that of the trim/extend commands where you hold down shift to change from trim mode to extend mode and vice versa. By choosing a positive number for the lengthen Delta command, you can increase length, and by holding down shift and clicking a line etc. you can decrease length by the same amount. Thanks for your help. I use the lengthen Delta command all the time so it would be very handy. Thanks Matt Sibum Last edited by mattsibum; 11-28-2007 at 06:15 PM. |
|
#2
|
|||
|
|||
|
I am judging by the silence that what i requested cannot be done (easily)
Just wondering how you would write the code differently. Here's what i have in mind... - start the command - specify (only positive) value to store for lengthen delta command - Run the following prompt "Select entities to lengthen or <Shorten>" (Shorten by hitting Enter or "S") - the command would be fed a positive value unless enter or "S" is called, which would change the sign of the number to negative. - If in "negative" mode (i.e. shorten) the following prompt would display "Select entities to shorten or <lengthen>". - Hitting enter or "L" would change the mode back to lengthen (positive value). Any help would be great. Thanks |
|
#3
|
||||
|
||||
|
Howzabout...
Code:
(defun C:NLENGTHEN ()
(if (null DefaultLengthen) (setq DefaultLengthen 1.0))
(setq TMP (getdist (strcat "\nDefault NLENGTHEN value <" (rtos (abs DefaultLengthen)) ">: "))
DefaultLengthen (if TMP TMP (abs DefaultLengthen))
)
(while
(progn
(setq TMP (if (minusp DefaultLengthen) "Longer" "Shorter"))
(initget 0 TMP)
(prompt (if (minusp DefaultLengthen)
"\nShorten active, "
"\nLonger active, "))
(setq TMP (entsel (strcat "Select entity or <" TMP ">: "))))
(cond
((= (type TMP) 'STR)
(setq DefaultLengthen (* -1.0 DefaultLengthen)))
(t
(command "_LENGTHEN" "DE" DefaultLengthen TMP "")
)
)
)
(princ)
)
Hot Tip Harry (Bill Kramer) |
|
#4
|
|||
|
|||
|
Quote:
Just wondering how i could modify the program so it doesn't end if nothing is selected, and also if the enter key could be used to switch between lengthen and shorten modes (as well as typing "S" or "L" )??? (currently typing "S" activates the shorten mode, but typing "L" doesn't work for setting lengthen mode) Thanks for your help. Last edited by mattsibum; 06-18-2008 at 10:18 PM. |
|
#5
|
||||
|
||||
|
Oops!
Change the "Longer" string to "Bigger" or ANYTHING that does not start with a character that the entity selection system might interpret as an option. "L" means "Last" in the eyes of ENTSEL running on an English speaking platform (and others). As to flipping the sign on the enter key entry; that can be done however it is not normal when related to other AutoCAD commands and means that an alternative exit strategy for the loop must be determined. For example if you say "loop until ESC" then it will blow out of the function into the *ERROR* routine (if available). Or if you say "loop until Quit" is input then you still end up with a character input to activate the option. My preference is to keep it like AutoCAD as much as possible then new operators to the command function are not confused. So how to do it? By expanding the code inside the (PROGN) predicate of the (WHILE) loop. Code:
(progn
(setq TMP (if (minusp DefaultLengthen) "Bigger" "Shorter"))
(initget 0 (strcat "Quit " TMP))
(prompt (if (minusp DefaultLengthen)
"\nShorten active, "
"\nBigger active, "))
(setq TMP (entsel (strcat "Select entity or <" TMP " or Quit>: ")))
(if (null TMP) (setq TMP "Flip It"))
(if (and (= (type TMP) 'STR) (= TMP "Quit"))
(setq TMP nil)
TMP)
)
1) Changed "Lengthen" to "Bigger" to get rid of the "L" = Last problem. 2) Added logic for the "Quit" option (initget addition, prompt in entsel, and a final test at the end to see if we have a Quit option) You can exit the function now by pressing ESC or by entering Q. To flip the sign of the delta you can either enter "Bigger" (just B is needed) or "Shorter" or simply enter nothing when asked to select an entity. NOTE that this is not a "standard" way of interfacing and could result in some slight operator confusion - nothing new there though A complete listing is available for download at http://www.autocode.com/lisp/nlengthen.htm Keep on programmin' Hot Tip Harry (Bill Kramer) Last edited by Harry_Is_Alive; 06-19-2008 at 07:09 AM. |
|
#6
|
|||
|
|||
|
Thanks HTH
The program works awesome. Exactly what i needed... Will be using this one a lot. Matt Sibum |
|
#7
|
|||
|
|||
|
This program actually works better than i thought, now that i have had time to use it...
Because the program switches modes between shorten and lengthen when "nil" is returned (i.e. enter) the program also switches when nothing is selected. Instead of just allowing me to have another crack at picking the object it actually switches from "bigger" to "shorter" aswell. At first glance it seemed like something that would frustrate me but now that i think about it, it saves me having to use the keyboard a whole lot. Instead of hitting enter i can just click anywhere on screen to change modes... Very handy .I think you created a winner Harry (for me anyway)Even though Quote:
Just curious to know what you think about it! Matt |
|
#8
|
||||
|
||||
|
Well, actually I used it as an example of evolving from idea to code in the Hot Tip Harry newsletter for this month (due out next week). I took your basic outline and turned it into pseudo code then turned that into LISP (in the newsletter).
My philosophy in programming stuff is pretty simple. What ever works best works best. When programming for the masses keep it like everything else to avoid confusing others. Keep on programmin' Hot Tip Harry (Bill Kramer) |
|
#9
|
||||
|
||||
|
Here is another version using the grread function.
__________________
From TheSwamp.org Last edited by CAB; 06-23-2008 at 08:40 AM. Reason: Removed Old Code |
|
#10
|
||||
|
||||
|
LengthenDE is a modified use of the LENGTHEN command. It allows the user to switch between Lengthen & Shorten while the command is running.
Use it like this: Code:
LengthenDE
Enter LENGTHEN value <10>: 15
Select object to make Longer
Press the S or - key to switch to Shorter
Press the L or + key to switch to Longer
Right Click to change the amount.
Commands remembers the last distance & Lengthen or Shorten Mode. Comments and suggestions welcome.
__________________
From TheSwamp.org |
| Thread Tools | |
| Display Modes | |
|
|