PDA

View Full Version : Text Rotate LISP routine appears to cause cad 'memory loss'


jgrande26
2007-03-14, 06:03 PM
I just had something totally bizarre happen to me. I was adding some notes to a drawing in paperspace and I wanted to rotate a line of mtext to align with a line and I have a tool I use called rotate text, that I downloaded form Cadalyst a while ago. I don't think I've ever tried to use it while in paperspace before but I had no reason to believe it would do anything weird. What happened when i invoked the command was that all the work I had done since the last save disappeared as if it never existed, even from the undo-redo history. Even the layers I had created are gone. :shock:
Fortunately, it's not a lot to redo, but what could cause that kind of behavior? The text window doesn't offer any clues.:? The only thing I can see is that I made the mistake of selecting the text first instead of the line which should have just given me an error message.

[ Forum Moderator Action Mode = ON ] Copyright material removed.

Routine can be downloaded from here [ Rotate Text (http://new.cadalyst.com/code/tips/CodeSearch_Detail.cfm?ID=1783) ].

Unless permission is obtained from CADalyst or the Author (of a routine), please do not post CADalyst - Get the Code - here on AUGI.com [ Forum Moderator Action Mode = OFF ]

Mike.Perry
2007-03-15, 12:47 PM
Hi "jgrande26"

Please note I have *moved* this thread from the AutoCAD General (http://forums.augi.com/forumdisplay.php?f=120) forum to this one, as I believe it will be better served here.

Thanks, Mike

Forum Manager

Mike.Perry
2007-03-15, 12:48 PM
Hi

Until someone takes a look at the routine in question, have you looked at using the Express Tools command TOrient instead?

Have a good one, Mike

kennet.sjoberg
2007-03-15, 01:13 PM
Hi

Until someone takes a look at the routine in question, . . .
Mike, I think the URL is wrong

: ) Happy Computing !

kennet

Mike.Perry
2007-03-16, 12:42 PM
Mike, I think the URL is wrong

: ) Happy Computing !

kennetHi Kennet

:Oops: my bad... thanks for the heads-up.

I have updated the link, please try again.

:beer: Mike

kennet.sjoberg
2007-03-16, 02:24 PM
I just had something totally bizarre happen to me. . . .
The code that you have used is very simple and not completed,
it do not take care of user variables and reset them in a good way.
Not either is there any undo flags or error handler.
And I can not strongly enough point out how important it is to declare all used variables as local if they are local.
The program by itself should probably not do the harm as you described, but together with other bad written program they can.
When there is no build in security to empty a SelectionSet or other important variables they will always exist and unexpected things can happens and do harm.

So once again
Always declare all used variables as local ( if they are local )
everything else is BAD BAD BAD programming.

: ) Happy Computing !

kennet

BTW
If you ask in this forum for a similar program, I think you will get a better and newer one.
a lot of people here can do it.

Avatart
2007-03-16, 04:57 PM
So, Kennet, I am guessing that you were not very impressed with the code...!

I took a look at it and can see what you mean completely, there are a series of generically named variables (ELIST and ENT for example) that are not declared and may pre-populate another routine and cause all sorts of damage. Also, the routine execution mnemonic (RT) is too short and easily overwritten by sometning else, which could also cause problems.

As Kennet says, if you writing code, declare your variables, if it has to be a global variable (ie undeclared), then name it in a way that makes it unique and obviously tied to your program (ie Rotate_Text_Elist).