Found old "Nudge" routine...

Found old "Nudge" routine...

Anonymous
Not applicable
1,587 Views
13 Replies
Message 1 of 14

Found old "Nudge" routine...

Anonymous
Not applicable

Hello!

 

I found an old routine, on this site's forum, called "Nudge" from many, many years ago, I tried it out but it doesn't work.  In VLIDE it loads and checks ok but nothing happens. 

 

It appears to be something I can use as I did not find any other routines that would do what I was looking for.  Which is to move or rotate selected objects around a selected point in 45 degree increments.  I am hoping someone here would be able to figure out why it doesn't work with AutoCAD 2014?

 

Thank you!

 

Drafter_Joe

0 Likes
Accepted solutions (1)
1,588 Views
13 Replies
Replies (13)
Message 2 of 14

ВeekeeCZ
Consultant
Consultant
Rename it to anything but C:NUDGE. Then it works.
0 Likes
Message 3 of 14

Kent1Cooper
Consultant
Consultant

@Anonymous wrote:

... an old routine, on this site's forum, called "Nudge" from many, many years ago, I tried it out but it doesn't work. ....


It doesn't work for me either, even back in Acad2004, and even when I changed the name as suggested by BeekeeCZ.  Unfortunately, I suspect you are the victim of the change(s) in website hosting or handling or whatever the issues have been, since many years ago.  There was a time when some things contained between pointy brackets in code would simply disappear from the code when posted.  That included [but was not limited to] the typical-for-AutoCAD defaults offered in prompts, which is why a lot of us complained to the AutoDesk people a lot about it at the time, and eventually they straightened it out, but there was a lot of faulty code left hanging around, and they didn't have any way of going back and fixing it all.  If in this case content didn't disappear at the time of posting, it seems to have in the translation to the new website, or from the old NTTP system to the website-based system, or something.

 

Notice where the prompt says:

 

(prompt
  "\nUse the arrows on the number keypad, S for settings,  to exit..."
)

 

but it probably originally had a default offering in pointy brackets, saying something like:

 

(prompt
  "\nUse the arrows on the number keypad, S for settings, <Enter> to exit..."
)

 

[which is why there are two spaces there*], or perhaps <Esc> or something else instead.  Whatever that was is a Darwinian victim -- it didn't survive the evolution of the Forums.

 

It didn't happen necessarily with every instance of pointy brackets -- see the "New nudge increment value" prompt -- but I was never able to discern what specific bracketed conditions caused dropouts and what did not.  Sometimes people would use pointy brackets for some reason in comments, and it could lose much more than just a single default-offering word like that, even multiple whole lines of code, and that may be the case here, but it's impossible to say what may be missing, or where, without a thorough evaluation of the operation of the command [even then, it might be difficult, depending on how much is missing].

 

I'm assuming you found this code in the message itself, wherever it came from, and that you copied/pasted it into a file that you loaded.  If it happens to be available as a file attachment rather than [or in addition to] being in the body of a message, that version should be complete, and may work.

 

[* Speaking of two spaces, the current website system has its own automatic operations that have the potential to cause problems.  In your .lsp file, there are two spaces there where the default offering is missing, and I copied it out of there, but when I pasted it into this message, "the system" decided I didn't really mean to have two spaces, and it removed one of them, which I had to add back in.]

Kent Cooper, AIA
0 Likes
Message 4 of 14

ВeekeeCZ
Consultant
Consultant

@Kent1Cooper wrote:

It doesn't work for me either, even back in Acad2004, and even when I changed the name as suggested by BeekeeCZ.  Unfortunately, I suspect you are the victim of the change(s) in website hosting or handling or whatever the issues have been, since many years ago....


I do not share this experience... After rename, it worked as I expected (AutoCAD 2015).

0 Likes
Message 5 of 14

Kent1Cooper
Consultant
Consultant

BeekeeCZ wrote:

I do not share this experience... After rename, it worked as I expected (AutoCAD 2015).


So it would seem the issue may not be from anything missing because of pointy brackets, but I'm very curious -- why change the name?  Nudging is an operation you can do with Ctrl+ArrowKeys in grip-editing, but NUDGE is not a command name that this routine could be in conflict with, either in my older or the latest version.  How does changing the command name make it work if it doesn't work with the original name?

Kent Cooper, AIA
0 Likes
Message 6 of 14

ВeekeeCZ
Consultant
Consultant

@Kent1Cooper wrote:

@ВeekeeCZ wrote:

I do not share this experience... After rename, it worked as I expected (AutoCAD 2015).


So it would seem the issue may not be from anything missing because of pointy brackets, but I'm very curious -- why change the name?  Nudging is an operation you can do with Ctrl+ArrowKeys in grip-editing, but NUDGE is not a command name that this routine could be in conflict with, either in my older or the latest version.  How does changing the command name make it work if it doesn't work with the original name?


If you type NUDGE into command line (no routine, ACAD 2012+), it returns nothing. No unknown command, nothing. So it is the command which is this routine in conflict with. You can try undefine NUDGE - it works... then the routine could keep the name.

 

Btw this Ctrl+Arrows... no grip-editing needed... if you pre-select something then it move it... If you don't, it moves with the cursor.

 

My only experience with NUDGE was when I tried to redefine Ctrl+Arrows to some other function (in  CUI)... but this cannot be changed.

0 Likes
Message 7 of 14

Anonymous
Not applicable

Thank you BeekeeCZ and Kent1Cooper! 

 

I appreciate the discussion.  I changed the "C:NUDGE" and the routine now works.  Unfortunately, I didn't look at the code close enough to see that it would not do what I thought it would do.  Some of the code from this routine might be useful for what I am trying to do.  I will continue my search.

 

Thanks again!

 

Drafter_Joe   

0 Likes
Message 8 of 14

ВeekeeCZ
Consultant
Consultant

@Anonymous wrote:

...  Which is to move or rotate selected objects around a selected point in 45 degree increments. ...

 

Drafter_Joe


 

Oou... I overlooked your expectations... then try this simple one...

 

(defun c:45 ( / ss pt dr done key)

  (if (and (setq ss (ssget))
	   (setq pt (getpoint "\nBase point: "))
	   (setq dr 1)
	   )
    (while (not done)
      (initget "Contra - eXit +")
      (setq key (getkword (strcat "\nRotate 45 degrees or [Contra/eXit] <next " (itoa (* dr 45)) " degrees>: ")))
      (cond ((or (= key "Contra")
		 (= key "-"))
	     (setq dr (* -1 dr)))
	    ((or (= key "eXit")
		 (= key "+"))
	     (setq done T))
	    ((command "_.ROTATE" ss "" "_none" pt (angtos (* pi 0.25 dr))))))
    )
  (princ)
)

 

0 Likes
Message 9 of 14

Anonymous
Not applicable

That works very well!  Thank you BeekeeCZ!  Smiley Very Happy

 

That is a great start to my overall goal.  I will see what I can do with it.  I will post my findings so that you'll know if I'm successful or not.  I'll need a few hints if I can't figure out what I'm trying to do.

 

Thanks again!  Smiley Happy

 

Drafter_Joe

0 Likes
Message 10 of 14

Kent1Cooper
Consultant
Consultant

@Anonymous wrote:

.... what I was looking for ... is to move or rotate selected objects around a selected point in 45 degree increments.  ....


Here's another way to do that, making use of the nifty (grread) function: SPIN45.lsp with its eponymous command name.

 

After selecting objects and giving a base point, it Rotates the selection by +45 degrees immediately upon pressing the + key, and by -45 degrees immediately upon pressing the - key.  No Enter/space is required to register the input from those keys, and it is not necessary to call for an option to reverse the direction -- you can just go around or back and forth directly as desired with the +/- keys.  It eXits upon hitting Enter or space or [since it shows <eXit> as the default] x or X [see the comment about that at the top of the file].

 

Later I'll revise it into a generic version that asks the User for a rotation increment [probably with 45 degrees as the initial default, because of this thread], so it can be used for any angle.  It could then become effectively a rotational "nudge" operation with a small angle, etc.  But anyone who has other intervals they regularly need for this kind of thing can also make other angle-specific commands by simply substituting whatever angle they want in place of all instances of 45 except in the

 

(equal input '(2 45))

 

that is checking for the User having pressed the - key -- that one needs to remain as 45, whatever the angle involved.

Kent Cooper, AIA
0 Likes
Message 11 of 14

Anonymous
Not applicable

Great Kent!  Smiley Happy 

 

I'll be looking forward to trying it out.  I also appreciate the helpful description you provided.  Hopefully others that can use this type of routine will stumble upon this thread.

 

Thank you very much!  Smiley Very Happy

 

Drafter_Joe

0 Likes
Message 12 of 14

Anonymous
Not applicable

Kent,

 

When I try this routine, it works fine, but the prompt repeats until I press the "+" or "-" key.  I think it has to do with the while loop, but I'm not sure exactly what to do to fix it. 

 

Drafter_Joe

0 Likes
Message 13 of 14

Kent1Cooper
Consultant
Consultant
Accepted solution

@Anonymous wrote:

... the prompt repeats until I press the "+" or "-" key.  I think it has to do with the while loop, but I'm not sure exactly what to do to fix it. 

 

....

Yes, I fixed that in the attached.  That was something that would happen a lot more if you moved the cursor, because (grread) feeds something in every time you do.  But I realized that the prompt could be before the (while) loop, since nothing that occurs in the loop puts anything onto the Command: line to move the prompt out of view, so it will appear only once, and sit there until you eXit.

 

[I also realized some more concise ways to accomplish a couple of other aspects, which you can find by comparing the code, if you're interested enough.]

 

The attached SPIN.lsp [no number as part of the name this time], with its likewise eponymous command name, is the generic version I was describing.  I changed my mind about the initial default value to offer for the rotational increment, going with the POLARANG System Variable value instead of 45 degrees.  If you would always want an initial default of 45 degrees offered, regardless of the value of POLARANG, you can get that by replacing this:

 

(getvar 'polarang)

 

with this:

 

(/ pi 4)

 

in both places where that occurs.  [You can do the same for any preferred initial default -- just express it in radians.]  In any case, once you've chosen an angle, default or otherwise, that will remain the offered default in subsequent use within the same editing session, unless and until you give it a different one.

Kent Cooper, AIA
0 Likes
Message 14 of 14

Anonymous
Not applicable

Very well done, Kent!  I can see the differences between the codes, not sure what all the changes mean though.  But it does work very well, it's very slick, this should come in very handy!

 

Thank you very much!

 

Drafter_Joe

0 Likes