Lisp Not working
Hello:
I am writing this lisp for a co-worker and it is not working. The idea is to define the spacing of the snap and then to turn the snaps on, draw a linear dimension and then set the snaps back to their previous (before running the command) value.
If I step through the code one line at a time and paste the code into BC everything works, as soon as I load the lisp file and run it, the snaps are not set...
[code];Undefine the original dimlinear command
(command ".undefine" "dimlinear")
(princ "\nDEFAULT LINEAR DIMENSION UNDEFINED")
;Redefine the command
(defun c:dimlinear ()
;Save the current snap mode
(setq psnapmode (getvar "snapmode"))
;Set the target spacing of the dimension lines
(setq TargetSpace 0.375)
;Calculate the snap spacing
(setq SnapSpace (* (* (getvar "userr1") (getvar "userr5")) TargetSpace))
;Set up the snaps
(setvar "snapunit" (list SnapSpace SnapSpace))
(setvar "snapmode" 1)
(command ".dimlinear")
;Reset the snaps
(setvar "snapmode" psnapmode)
(princ)
)[/code]
0
Comments
-
Hi Scott,
your lisp isn't working because it doesn't stop at the .dimlinear command, but carries on. You can see this by placing a few flags
[code];Undefine the original dimlinear command
(command ".undefine" "dimlinear")
(princ "\nDEFAULT LINEAR DIMENSION UNDEFINED")
;Redefine the command
(defun c:dimlinear ()
;Save the current snap mode
(setq psnapmode (getvar "snapmode"))
;Set the target spacing of the dimension lines
(setq TargetSpace 0.375)
;Calculate the snap spacing
(setq SnapSpace (* (* (getvar "userr1") (getvar "userr5")) TargetSpace))
;Set up the snaps
(setvar "snapunit" (list SnapSpace SnapSpace))
(princ "\ngot here1")
(setvar "snapmode" 1)
(princ "\ngot here2")
(command ".dimlinear")
(princ "\ngot here3")
;Reset the snaps
(setvar "snapmode" psnapmode)
(princ "\ngot here4")
(princ)
)[/code]
Try adding some pauses to the .dimlinear e.g.
[code](command ".dimlinear" pause pause)[/code]
Regards,Jason Bourhill
0 -
Thanks Jason, I just could not see that one yesterday, I will make the changes...0
This discussion has been closed.