PDA

View Full Version : Mtext in LISP


ticad02
2009-04-17, 10:23 PM
I have a routine that runs a leader with mtext as the note and places the note on a special text layer. At the end of the routine, like many of my office's routines, the layer and other variables are set back to what they were before the lisp routine. I'm having a problem though, after the mtext is ran I get an error message and the routine is ended after the mtext is place, therefor leaving me on the text layer rather than the original layer. The note is place properly and on the right text layer, but the routine does not finish. Is there something odd about mtext in a lisp routine that I'm missing? Is there a special wawy to invoke mtext in a lisp? Thank you for any help.

howardjosh
2009-04-18, 12:44 AM
if you don't know how to use the Vlisp IDE to track down the error I would suggest doing a search on Error handling and just plan for the error to take place. I sometimes design routines to use error handling as it's "finalize/clean up" statement. Meaning I'll cause an error to make sure it hits. In that error handler I restore any variables that need be returned to their previous state, and restore the error handler back to the way I found it.

Mostly I would suggest doing a search for the visual lisp developers bible... That way you can cure the problem instead of the symptom. I know I've run into it on multiple occasions looking for other things anyway.

irneb
2009-04-20, 03:38 PM
Are you using (command "mtext" ....) to make the mtext, entmake, or vla-Add? In any one of these, it's good practice have some form of error handling which reverts any settings (such as CLAYER) back to orriginal. howardjosh is correct about that:mrgreen: This forum has several examples of error handling, just do a search.

As to actually fixing the problem, howardjoshtook the words from my mouth again :p

I use the VLIDE's watch & step debugging, to see exactly what happened. But even if you find & correct the error, still look at error handling ... what happens if the user presses ESC instead of enter (or some Exit option) when stopping your routine?

RobertB
2009-04-20, 08:26 PM
Is there a special [way] to invoke mtext in a lisp?If you are using a pause in the MText command, you need to switch the TextEval system variable to 1.

ticad02
2009-04-21, 03:59 PM
Thanks all. I'm looking into these options and hopefully will find an answer.