TheSwamp
Code Red => AutoLISP (Vanilla / Visual) => Topic started by: vincent.r on September 17, 2019, 01:32:52 AM
-
I received a message from watch window of VL console. Do anybody gone through this error ? What is that ? Screenshot attached.
-
You should indent your code better. And there is no reason to quote integers.
(setq LST (entget ent))
Is perhaps the problem. Initially ent is nil.
-
What is that ?
there's something in your block that 'Inspect window' doesn't like
i don't think it could be fixed
-
setq closest nil before run
-
setq closest nil before run
To build on this answer I would wrap the entire function in a lambda statement like so:
((lambda ( / ) ; insert local variables here
; insert all of your code here
)) ; close lambda function
The reason I use lambda is I don't need to make a function, however I need to localize my variables. I see that your code evaluates the variable closest in an if statement. When closest is not localized it will run "correctly" the first time, however if it is not set to nil the next time, it will run incorrectly. If you use lambda and put all the variables you use past the "/" the variables will be nil at the start of the program.
-
The reason I use lambda is I don't need to make a function, however I need to localize my variables.
A lambda is also a function.
-
The reason I use lambda is I don't need to make a function, however I need to localize my variables.
A lambda is also a function.
In this context it is single use, notice how I didn't save it to a variable. Additionally, it is created then it is called once and never used again.
The defun creates a callable function and saves it to a variable. That is what I meant with "make a function."
-
The reason I use lambda is I don't need to make a function, however I need to localize my variables.
A lambda is also a function.
In this context it is single use, notice how I didn't save it to a variable. Additionally, it is created then it is called once and never used again.
The defun creates a callable function and saves it to a variable. That is what I meant with "make a function."
)) ; close lambda function :)
-
Thanks guys for your efforts. I tried in many ways but result was same. Then created block newly and it works fine. I believe problem was with block. Don't know why.
Thanks a lot guys for your kind help.