Command won't work the first time in new drawing
I am new to bricscad and am trying to get some lisp programs from autocad to run. The attached program has been reworked to work with both autocad and bricscad.
The way the command is supposed to work is that you select a polyline or rectangle and it changes the layer to defpoints and then it puts in a hatch with the needed settings on a hatch layer that is either created or set to current if it exists already.
The problem i am having is that in a new drawing if you draw a rectangle and run one of the commands it will repeat the last command (rectangle) the first time but it will say in the command line to select an entity. Attached is a picture of what i am seeing.
If you escape and run the command again it will work with no issues. I have also found that if you first put in a block or an object with a hatch before running this command it will work the first time it is run.
Any ideas what i can do to fix this?
Thanks
Comments
-
It seems to work for me if I remove one of the three pairs of quotation marks in (command "layer" etc).
With all three, it creates the Hatch layer and then uses that third "" to repeat the Rectangle command, and then creates havoc.0 -
That worked for me! Thanks for the quick reply glad it was such a simple fix
0 -
Ah I see, if the HATCH layer exists due to previous work or previous execution then the (IF (NOT (TBLSEARCH "LAYER" "HATCH")) isn't executed, and the command rerun of the last command doesn't occur.
0 -
Steve,
Yes, that's what made me suspect the problem was in the (command "layer" etc.) function, since that's only evaluated "first time in a new drawing," as the thread title says. And when I saw that it did in fact create the Hatch layer before going awry, I was sure of it.
Also, my own problems with the lisp functions that I write are almost always with the number of "" pairs -- either too many or too few. When something doesn't work, I just remove or add pairs until it works.
And I figured that if I could see what's wrong, then it's probably too simple a problem for the real lisp programmers to bother with, so I'd better post a reply.
0