ZWcad, Autolisp and the UNDO command

654 views
Skip to first unread message

Hennie Maartens

unread,
Jul 4, 2009, 3:19:07 PM7/4/09
to zwcad...@googlegroups.com
After spending many many hours analyzing problems I'm having with
the UNDO command, I arrived at the conclusion that the presence of
lisp routines causes the UNDO command to become dysfunctional. I
have up to now always invoked lisp routines via customised pulldown
menus. This means that the lisp routine or routines are lurking in
the background for the duration of the session.

My experience has been that as soon as a lisp routine is invoked,
either by means of a keyboard hotkey, or a pulldown menu, the UNDO
command becomes dysfunctional. The UNDO item under EDIT becomes
greyed out, and UNDo cannot be invoked by any means whatsoever. A
partial, but clumsy, remedy seems to be to save the drawing,
whereafter UNDO again works properly until a lisp routine is called
up.

This leaves me with the agonizing choice of abandoning hundreds of
hours of lisp programmes developed over almost twenty years, or
abandoning ZWCad. I think lisp development will win the
contest...unless of course R&D at ZW Cad pays attention to this
shortcoming.

Moral of the story is that ZWCAD and Autolisp may not be such good
friends as the salespeople would like us to believe.

wcas...@disedig.com

unread,
Jul 4, 2009, 11:44:43 PM7/4/09
to ZWCad Users
Hello, Hennie,

I'm using ZwCAD with my own lisp programs and I haven't deal yet with
the bug you mentioned.
I wonder if you are missusing the Undo command inside your lisp
routines.
I use initiallization and termination subs inside every routine, so I
can set the original state of variables, layers, properties, etc.
after a lisp ejecucion.
In example: in my inicialization sub I use (command "undo" "begin"),
then in the finalization sub I use (command "undo" "end"),
I also use that expresions in a error trapper sub (if the lisp routine
fails in the middle of something).

I hope this can be usefull for you,

Regards,
William

Lars

unread,
Jul 5, 2009, 5:21:44 AM7/5/09
to ZWCad Users
Hi Hennie,

which contact do you have to ZWCAD ? Are you user or do you sell
ZWCAD ?
There will be a new update of ZWCAD on 30.07. and i think many bugs
will be fixed. Maybe your problem could be included when it's pushed
to the right people at ZWSOFT.

Regards,
Lars

Hennie Maartens

unread,
Jul 5, 2009, 1:42:07 PM7/5/09
to zwcad...@googlegroups.com
On 4 Jul 2009 at 20:44, wcas...@disedig.com wrote:

> I'm using ZwCAD with my own lisp programs and I haven't deal yet
> with the bug you mentioned.

OK, how exactly do you start the lisp programs ? I start mine from
customised pulldown menus and keyboard hotkeys. This means they sit
and wait while the session is in progress. The longer the session
lasts, the more programmes sit and wait. I've never experienced any
hiccups in Autocad following the same procedure.

> I wonder if you are missusing the Undo command inside your lisp
> routines.

Nowhere in the lisp programs do I use the UNDO command. I assigned
UNDO to the U key in the ALIAS function inside ZWCAd

> I use initiallization and termination subs inside every routine, so I
> can set the original state of variables, layers, properties, etc. after
> a lisp ejecucion.

As far as possible I also try to reset everything, but I do not
think this should cause any problems. Just some irritation perhaps.
I may sit with a different UCS or angular units after lisp, but
notheing that cannot be reset quickly.


Hennie Maartens

unread,
Jul 5, 2009, 1:42:07 PM7/5/09
to zwcad...@googlegroups.com
On 5 Jul 2009 at 2:21, Lars wrote:

>
> Hi Hennie,
>
> which contact do you have to ZWCAD ? Are you user or do you sell
> ZWCAD ?

I am a user, migrating from Autocad.


> There will be a new update of ZWCAD on 30.07. and i think many bugs will
> be fixed. Maybe your problem could be included when it's pushed to the
> right people at ZWSOFT.


I sent my modified zwcad.lsp, and keyboard hot-keys which I use, to
support, but have not received any response.

I use a modified zwcad.lsp, which sets a few system variables and
loads a number of keyboard hotkeys.


Siem Eikelenboom

unread,
Jul 5, 2009, 6:28:09 PM7/5/09
to ZWCad Users
Hi Hennie,

This is indeed a problem. I discovered it myself last week and will
also send my feedback to ZwCAD support. They are usually very serious
about solving bugs. This is a real serious one and you can count on me
that I will make it very clear that it needs to be solved. We have
hundreds of Lisp-routines for ZwCAD that we sell and support in The
Netherlands and Belgium.

Best regards and please give them some time to solve it!

Siem
ZwCAD Distributor The Netherlands

mac

unread,
Jul 5, 2009, 11:16:34 PM7/5/09
to ZWCad Users
Hi Hennie,

Instead of having all your lisp routine loaded on all at once with
ZWCAD.lsp, try breaking them down to 1 file per routine, and placing
them in a folder. This way only the ones you need are loaded as you
need them. I use autoload to run my routines which allows the computer
to load the routine as i call on them and (if i understand it
correctly) unloads them as soon as they are done.


Mac

Hennie Maartens

unread,
Jul 6, 2009, 4:54:31 PM7/6/09
to zwcad...@googlegroups.com
Siem Eikelenboom wrote:

> Hi Hennie,

> This is indeed a problem. I discovered it myself last week and will also
> send my feedback to ZwCAD support.

Thank you very much. I am convinced a request by a dealer carries
more weight than from a single user...the very reason why this
mailing list was started.

> They are usually very serious about
> solving bugs. This is a real serious one and you can count on me that I
> will make it very clear that it needs to be solved. We have hundreds of
> Lisp-routines for ZwCAD that we sell and support in The Netherlands and
> Belgium.

Indeed a serious problem. There must be hundreds if not thousands of
users who bring with them decades of in-house developed custom
lisps. If they have to choose between ZWCAd and custom programmes,
the choice is obvious.



> Best regards and please give them some time to solve it!

Like another user once said, at a tenth of the price something will
have to be sacrificed. As long as I know the problem is receiving
attention, a reasonable time is not much to ask. But if the problem
persists, a choice will eventually have to be made.


>
> Siem
> ZwCAD Distributor The Netherlands

Forgive me for expressing my utter disgust to the fact that a dealer
from the Netherlands lends his support to this problem while my own
dealer, who is subscribed to this list as well as the ZWCad forum,
just maintains a deadly silence.


Hennie Maartens

unread,
Jul 6, 2009, 6:02:48 PM7/6/09
to zwcad...@googlegroups.com
mac wrote:


> Hi Hennie,
>
> Instead of having all your lisp routine loaded on all at once with
> ZWCAD.lsp, try breaking them down to 1 file per routine, and
> placing them in a folder.

This is how I start some lisps - the "bigger" ones. The are fired
up by means of a pulldown menu, through a custom add-on menu file
which is loaded through the ZWcad custom feature.

Typically, the menu item looks like this:

[Parallel]^C^C(if(not c:forcepar)(load"c:/data/lisp/forcepar");+
(princ "Already loaded.."));forcepar

The routine FORCEPAR is to force a text string parallel to a line
or another text string.

> This way only the ones you need are loaded as
> you need them. I use autoload to run my routines which allows the
> computer to load the routine as i call on them and (if i understand it
> correctly) unloads them as soon as they are done.

Is "autoload" the same as "load" ? Sorry I am no hotshot lisp geek.
Problem is some of them define keyboard hotkeys where ALIAS falls
short. For instance, to draw a line it is quite sufficient to assign
the command LINE to the alias L. But, if you frequently draw lines
between nodes, its handy to have hotkeys like LNN (thats line node
node) do the job. That needs a small lisp which must be present
always. BTW I also tried invoking the hotkeys from outside the
keyboard lisp file, using LOAD.

Either way, the presence of lisp routines screws up the ZWcad UNDO
command.

Pavel

unread,
Jul 8, 2009, 8:50:14 AM7/8/09
to ZWCad Users
Hi, everybody

I have submit to zwsoft the similar problem with UNDO in the lisp and
have receive the following answer:

As for the lisp problem you mentioned, I have made a sample of UNDO
command according to your email, but the CRASH problem didn’t occur in
my PC. Maybe I haven’t got your mind exactly, so I attached my
sample, please check it. If it is different from yours, please send us
your complete sample. Thanks.
The lisp code:

(defun c:undocrash ()

(command "undo" "group")

(setq prt1 (getpoint "the start point of line"))
(setq prt2 (getpoint "the end point of line"))
(command "line" prt1 prt2 "")
(setq en1 (entnext))
(setq ed (entget en1))
(command "layer" "n" "1" "c" "red" "1" "")
(setq ed (subst (cons 8 "1") (assoc 8 ed) ed))
(entmod ed)

(command "undo" "end")

(getpoint"press mouse button to continue...")
(command "undo" "1")

)

Hennie Maartens

unread,
Jul 8, 2009, 10:01:43 AM7/8/09
to zwcad...@googlegroups.com
On 8 Jul 2009 at 5:50, Pavel wrote:


> Hi, everybody

> I have submit to zwsoft the similar problem with UNDO in the lisp and
> have receive the following answer:

> As for the lisp problem you mentioned, I have made a sample of UNDO
> command according to your email, but the CRASH problem didn´t occur in
> my PC. Maybe I haven´t got your mind exactly, so I attached my sample,
> please check it. If it is different from yours, please send us your
> complete sample. Thanks.

The problem in this discussion is not the lisp code. It has to do
with the fact that a lisp program, while resident in program memory,
seems to prevent the UNDO command from working. In other words, if
one loads a lisp routine and executes it, then you cannot undo (or
redo) anything. The ZWcad command UNDO, either by typing UNDO, or
by pressing CtrlZ, or by using the EDIT pulldown menu, or by typing
U (if so defined as an alias) refuses to work. It matters not what
the lisp code consists of.


Pavel

unread,
Jul 8, 2009, 10:18:55 AM7/8/09
to ZWCad Users
Actually, in my case the UNDO bug depends on ZWCAD's vernum and
localized version. I found the crash happens in Russian vernum
2009.03.31 only :( As for a resident program perhaps you're right.
I'll test it more

ZWCAD_Support<Sirius>

unread,
Jul 9, 2009, 3:32:35 AM7/9/09
to zwcad...@googlegroups.com
Hi Hennie,

I supposed this issue is not due to hot key nor aliases, but lisp command.

After debugging your lisp applications, I found that it is caused by the
lisp function " c:LL( )".
I simulated another lisp routine as follow:
(defun c:LL( )
(command "lengthen" "DY" )
)

Then I loaded it with ZWCAD and did the following operations as you
mentioned before:
>Draw two lines that don't touch
>Now fillet them (type FILLET or just F) Now type UNDO, or just U, and
>the lines are apart again.
>Now fillet them again
>Now type LL and lengthen one of them dynamically.

Nothing will get UNDO working then, not by typingthe command, or the alias U
(BTW, you don’t have to set "U" as alias of UNDO. It has been defined by
default.), or CtrlZ, or the pulldown under EDIT.
You don't have to load the menu files, lisp applications or aliases files.

Then I got to a conclusion: it's caused by the lisp function.
I have forwarded this issue to our developers to solve. Thanks for your
great effort for the enhancement of ZWCAD! Any progress, I would keep you
updated of it.

Best Regards
Sirius -- Customer Center
-----------------------------------------------

ADD:Rm.508, No. 886, Tianhe North Road, 
Guangzhou 510635, P. R. China
Tel: (86)20-38289780-156
Fax: (86)20-38288676
Skype: Sirius_ZWCAD_Tech
MSN: Sirius_Te...@hotmail.com
(Available from 8:30am to 5:30 pm GMT+8)
http://www.zwcad.org

Hennie Maartens

unread,
Jul 9, 2009, 4:30:37 AM7/9/09
to zwcad...@googlegroups.com
On 9 Jul 2009 at 15:32, ZWCAD_SupportSirius wrote:


> Hi Hennie,
>
> I supposed this issue is not due to hot key nor aliases, but lisp
> command.

That is correct - my conclusion too.

> After debugging your lisp applications, I found that it is caused by
> the lisp function " c:LL( )".
> I simulated another lisp routine as
> follow:
>
>(defun c:LL( )
>(command "lengthen" "DY" )
> )


Just to get the right perspective: "debugging" normally means
removing mistakes. The lisp routine is a short, simple three liner
which adds a bit more speed and power to the lengthen command. There
is nothing wrong with the code as such, it is the PRESENCE of the
code, and others like it, that causes the problem.

In other words, changing the code will not solve anything.

> (BTW, you don´t have to set "U" as alias of UNDO. It has been
> defined by
> default.),


That is correct. But there are other aliases which I have been using
for 20 years, which are not the same as as the ZW default aliases.
Therefore, I defined my own .ica file, making use of the ZWcad
facility for custom aliases.


> Then I got to a conclusion: it's caused by the lisp function.
> I have forwarded this issue to our developers to solve.

Again, yes, that was my conclusion too. But again, for clarity, it
is not the lisp function that is at fault, but the PRESENCE of the
function, or any (maybe some) other functions as well. I can hardly
imagine a simpler function than the LL.lsp one.


> Thanks for
> your
> great effort for the enhancement of ZWCAD!

I gladly share two decades of cad customisation with others based on
the open source principle. However, there are people out there far
more knowledgable than I am. Some of them do contribute, but just
imagine what can be achieved if more people will contribute.

mac

unread,
Jul 9, 2009, 5:00:37 AM7/9/09
to ZWCad Users
Hennie,

autoload is pretty much the same as load expect that it removes/
unloads the routine from the memory once it has finished executing.
The syntax use for this is:

(autoload "forcepar" ' ("forcepar")

Take note that the folder where your lisp routines are located should
be included in you search path.

I have also noticed is that osnap options/commands behaves
differenctly in ZWCAD from ACAD. I needed to rework some of my
routines to make them work.


Mac

ZWCAD_Support<Sirius>

unread,
Jul 9, 2009, 5:06:44 AM7/9/09
to zwcad...@googlegroups.com
Hi Hennie,

Absolutely there is nothing wrong with the small lisp routine. But the
PRESENCE of the code causes the problem.
What I am trying to do is to make the issue simple and clear. And the
developers could find out the essential of this issue by this thread.
I hope it could be fixed in our latest release.

Most importantly, we appreciate your share, as well as what other
contributors have done.

Best Regards
Sirius -- Customer Center
-----------------------------------------------

ADD:Rm.508, No. 886, Tianhe North Road, 
Guangzhou 510635, P. R. China
Tel: (86)20-38289780-156
Fax: (86)20-38288676
Skype: Sirius_ZWCAD_Tech
MSN: Sirius_Te...@hotmail.com
(Available from 8:30am to 5:30 pm GMT+8)
http://www.zwcad.org


-----Original Message-----
From: zwcad...@googlegroups.com [mailto:zwcad...@googlegroups.com] On
Behalf Of Hennie Maartens
Sent: Thursday, July 09, 2009 4:31 PM
To: zwcad...@googlegroups.com
Subject: [ZWCad Users:59] Re: [ZWCad Users:58]Re: ZWcad, Autolisp and the
UNDO command


Hennie Maartens

unread,
Jul 9, 2009, 6:36:20 AM7/9/09
to zwcad...@googlegroups.com
On 9 Jul 2009 at 2:00, mac wrote:

>
> Hennie,
>
> autoload is pretty much the same as load expect that it removes/
> unloads the routine from the memory once it has finished
> executing.
> The syntax use for this is:
>
> (autoload "forcepar" ' ("forcepar")

Maybe just add a ) at the end.....

Okay I tried tis, it works but does not solve the problem of the
dysfunctional UNDO command.


More on autoload from Autocad HELP file:

When you automatically load a command using the load or command
functions, the command's definition takes up memory whether or not
you actually use the command. The AutoLISP autoload function makes a
command available without loading the entire routine into memory.
Adding the following code to your acaddoc.lsp file automatically
loads the commands CMD1, CMD2, and CMD3 from the cmds.lsp file and
the NEWCMD command from the newcmd.lsp file.

(autoload "CMDS" '("CMD1" "CMD2" "CMD3"))
(autoload "NEWCMD" '("NEWCMD"))

Siem Eikelenboom

unread,
Jul 9, 2009, 11:33:34 AM7/9/09
to ZWCad Users
Hi there,

Good news: this bug has been solved in version 2009.07.08(10843),
which is ZwCAD 2009i Beta. I tested it myself. If you are a beta
tester, you received a link from ZwCAD. If you are not, please contact
ZwCAD support to download the patch (it is not yet on www.zwcad.org).

Best regards,
Siem
www.ideoma.nl

mac

unread,
Jul 10, 2009, 12:34:09 AM7/10/09
to ZWCad Users

> After debugging your lisp applications, I found that it is caused by the
> lisp function " c:LL( )".
> I simulated another lisp routine as follow:
>  (defun c:LL( )
> (command "lengthen" "DY" )
> )
>
> Then I loaded it with ZWCAD and did the following operations as you
> mentioned before:
>
> >Draw two lines that don't touch
> >Now fillet them (type FILLET or just F) Now type UNDO, or just U, and
> >the lines are apart again.
> >Now fillet them again
> >Now type LL and lengthen one of them dynamically.
>
> Nothing will get UNDO working then, not by typingthe command, or the alias U
> (BTW, you don’t have to set "U" as alias of UNDO. It has been defined by
> default.), or CtrlZ, or the pulldown under EDIT.
> You don't have to load the menu files, lisp applications or aliases files.
>


As it turns out it is not the routine that is causing the problem
here, it is ZWCAD's inability to termnate the routine properly as is
should. By adding a few more functions to the code:

(defun c:ll ()
(command "lengthen" "dy" pause pause "")
)

Undo works after running the "ll" routine. Although is a work around
the problem, but may not be as efficient as the original routine.


To did some further testing with this, by doing a very simple routine:

(defun c:l2 () (command "line" ))

and

(defun c:l2 () (command "line" pause pause "")

On the first "l2" routine, oonce you excute the routine and dra a
series of line, then terminate the routine either with an "enter" or
"^C", undo will no work thereafter. As for the second routine "l2"
routine, everything works fine after drawing a line.


mac

mac

unread,
Jul 10, 2009, 12:36:05 AM7/10/09
to ZWCad Users

> > Hennie,
>
> > autoload is pretty much the same as load expect that it removes/
> > unloads the routine from the memory once it has finished
> > executing.
> > The syntax use for this is:
>
> >  (autoload "forcepar" ' ("forcepar")
>
> Maybe just add a ) at the end.....
>
> Okay I tried tis, it works but does not solve the problem of the
> dysfunctional UNDO command.
>

You're right it should read:

(autoload "forcepar" ' ("forcepar"))

Thanks for the correction.

mac

Hennie Maartens

unread,
Jul 10, 2009, 1:35:10 AM7/10/09
to zwcad...@googlegroups.com
Thank you

Death to the bugs !!

Hennie Maartens

unread,
Jul 10, 2009, 1:38:09 AM7/10/09
to zwcad...@googlegroups.com
On 9 Jul 2009 at 21:36, mac wrote:


> > >  (autoload "forcepar" ' ("forcepar")
> >
> > Maybe just add a ) at the end.....
> >
> > Okay I tried tis, it works but does not solve the problem of the
> > dysfunctional UNDO command.
> >
>
> You're right it should read:
>
> (autoload "forcepar" ' ("forcepar"))
>
> Thanks for the correction.


I suppose everybody knows that LISP stands for List Processing.

Well you are all wrong.

It stands for Lost In Stupid Parenthesis

Hennie Maartens

unread,
Jul 10, 2009, 2:01:07 AM7/10/09
to zwcad...@googlegroups.com
On 9 Jul 2009 at 21:34, mac wrote:

 
> As it turns out it is not the routine that is causing the problem
> here, it is ZWCAD's inability to termnate the routine properly as
> is  should. By adding a few more functions to the code:
>
> (defun c:ll ()
> (command "lengthen" "dy" pause pause "")
> )

 
> Undo works after running the "ll" routine. Although is a work
> around  the problem, but may not be as efficient as the original routine.

YEs, it seems that adding pause pause ""  causes UNDO to work again. But, it opens another can of worms. Some, maybe all, other editing commands are now dysfunctional. For instance, you cannot copy or move an entity.

I think you hit the nail on the head with "ZWCAD's inability to terminate the routine properly".

  

Hennie Maartens

unread,
Jul 13, 2009, 4:37:13 AM7/13/09
to zwcad...@googlegroups.com
I lost the blue shaded command promt in the drawing area. It must be
some setting or system variable but I cannot find it. The help file
is also silent on the matter. Any suggestions welcome.

Pavel

unread,
Jul 13, 2009, 4:47:30 AM7/13/09
to ZWCad Users
DYNMODE ?

On Jul 13, 12:37 pm, "Hennie Maartens" <dashd...@vodamail.co.za>
wrote:

Lars Holfort

unread,
Jul 13, 2009, 5:05:54 AM7/13/09
to zwcad...@googlegroups.com
Hi Hennie,

you can switch it on again by klicking the 'DYN' button at the bottom of
your screen or type 'DYNMODE' and give the value '1'.

mit freundlichen Grüßen / best regards,
Lars Holfort

lars.h...@konstruktionswerk.de
www.konstruktionswerk.de
www.zw-cad.de
Skype: lars.holfort

Tel.: +49.(0)211.17129761
Mobil: +49.(0)151.24036651
Fax : +49.(0)211.17129762

Konstruktionswerk GmbH
Oststrasse 55
D-40211 Düsseldorf
Germany




Hennie Maartens schrieb:

Hennie Maartens

unread,
Jul 13, 2009, 5:07:37 AM7/13/09
to zwcad...@googlegroups.com
On 13 Jul 2009 at 1:47, Pavel wrote:

>
> DYNMODE ?

Yes.
Thanks.
Just wodering why it disappeared.

Hennie Maartens

unread,
Jul 13, 2009, 5:36:06 AM7/13/09
to zwcad...@googlegroups.com

On 13 Jul 2009 at 11:05, Lars Holfort wrote:

> you can switch it on again by klicking the 'DYN' button at the
> bottom of your screen or type 'DYNMODE' and give the value '1'.

Danke schön. I also included the line

(setvar "dynmode" 1)

in my zwcad.lsp file.

Just wondering: Autocad has a file acaddoc.lsp which loads with every drawing (as opposed to acad.lsp which loads with every session. As far as I know, zwcad has no equivalent to acaddoc.lsp - is that correct ?

Hennie Maartens

unread,
Feb 9, 2010, 5:33:28 PM2/9/10
to zwcad...@googlegroups.com
I live in South Africa and it seems this product has been abandoned
by the official distributors. Anybody experienced the same ? Who is
the current distributor - I need to know because I have to replace
my dongle

Hennie Maartens

unread,
Feb 25, 2010, 4:36:46 PM2/25/10
to zwcad...@googlegroups.com
I installed ZWCAD 2010 tonight, just to discover that some of my
lisp routines, which took weeks to get ZWCAD friendly, now refuse to
work in the 2010 release of ZWCAD. This is something everybody
should know - if you use lisp and choose to upgrade, be prepared to
spend lots of time to get your stuff to work.

William

unread,
Feb 25, 2010, 8:10:26 PM2/25/10
to ZWCad Users
Hello Hennie,

I don't have problems with my lisp in 2010.

William

Hennie Maartens

unread,
Feb 26, 2010, 1:26:23 AM2/26/10
to zwcad...@googlegroups.com, r...@applied.co.za, jenn...@netskills.co.za, ZWCAD_SupportIvy
The following line of lisp code should return point p1 only if an
intersection is found. If no intersection is found, it will return
NIL.

(setq p1 (osnap (getpoint "\Pick intersection: ") "int"))

It works perfectly in 2009i, but crashes in 2010.

If the safety feature is omitted, namely:

(setq p1 (getpoint "\Pick point: ") )

it works in 2010, but it will now snap onto anything, even a void.

How do I work around this, other than to go back to 2009i. I need
the safety feature like I need oxygen.

Hennie Maartens

unread,
Feb 26, 2010, 1:29:17 AM2/26/10
to William, zwcad...@googlegroups.com
Thank you, but look at this :

> --
> You received this message because you are subscribed to the Google
> Groups "ZWCad Users" group. To post to this group, send email to
> zwcad...@googlegroups.com. To unsubscribe from this group, send
> email to zwcadusers+...@googlegroups.com. For more options,
> visit this group at http://groups.google.com/group/zwcadusers?hl=en.
>


ZwCADtools

unread,
Feb 26, 2010, 2:32:34 AM2/26/10
to ZWCad Users
I gave up on ZwCAD and LISP. If you give BricsCAD a try you will
immediatly know why. You not only don't have to modify ANY code, LISP
runs even faster in BricsCAD then in any ACAD version. I ported over
2600 LISP and ARX functions to BricsCAD in less then 4 hours. It's
just brilliant !


Reply all
Reply to author
Forward
0 new messages