Go Back   Cadalyst Discussion Forums > Forums > Hot Tip Harry: AutoCAD Customization
FAQ Members List Social Groups Calendar Search Today's Posts Mark Forums Read

Notices

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  
Old 11-28-2007, 03:37 PM
mattsibum mattsibum is offline
Member
 
Join Date: Nov 2007
Posts: 34
Post Need Modified Lengthen Command

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  
Old 06-11-2008, 10:50 PM
mattsibum mattsibum is offline
Member
 
Join Date: Nov 2007
Posts: 34
Default How about this

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  
Old 06-18-2008, 12:02 PM
Harry_Is_Alive's Avatar
Harry_Is_Alive Harry_Is_Alive is offline
Guest
 
Join Date: Jan 2006
Location: Silicon Cornfields, OH
Posts: 277
Default

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)
  )
Keep on programmin',
Hot Tip Harry (Bill Kramer)
  #4  
Old 06-18-2008, 10:15 PM
mattsibum mattsibum is offline
Member
 
Join Date: Nov 2007
Posts: 34
Default

Quote:
Howzabout...

Code:
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)) &nbsp;) (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) )
Keep on programmin',
Hot Tip Harry (Bill Kramer)
Thanks HTH,


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  
Old 06-19-2008, 05:29 AM
Harry_Is_Alive's Avatar
Harry_Is_Alive Harry_Is_Alive is offline
Guest
 
Join Date: Jan 2006
Location: Silicon Cornfields, OH
Posts: 277
Default

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)
)
Two changes are seen in the above section of code.

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  
Old 06-19-2008, 06:34 PM
mattsibum mattsibum is offline
Member
 
Join Date: Nov 2007
Posts: 34
Default Thanks A Lot

Thanks HTH

The program works awesome. Exactly what i needed...

Will be using this one a lot.




Matt Sibum
  #7  
Old 06-19-2008, 06:54 PM
mattsibum mattsibum is offline
Member
 
Join Date: Nov 2007
Posts: 34
Default

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:
it is not normal when related to other AutoCAD commands
it seems like a handy function to use to speed things up.

Just curious to know what you think about it!


Matt
  #8  
Old 06-19-2008, 07:59 PM
Harry_Is_Alive's Avatar
Harry_Is_Alive Harry_Is_Alive is offline
Guest
 
Join Date: Jan 2006
Location: Silicon Cornfields, OH
Posts: 277
Default

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  
Old 06-22-2008, 02:21 PM
CAB's Avatar
CAB CAB is offline
Senior Member
 
Join Date: Dec 2003
Posts: 189
Default

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  
Old 06-23-2008, 08:38 AM
CAB's Avatar
CAB CAB is offline
Senior Member
 
Join Date: Dec 2003
Posts: 189
Default

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.
Command repeats until you press ENTER
Commands remembers the last distance & Lengthen or Shorten Mode.

Comments and suggestions welcome.
Attached Files
File Type: zip Lengthen - CAB011.zip (1.5 KB, 13 views)
__________________
From TheSwamp.org
 

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -6. The time now is 05:17 AM.





Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.