Using these two lisps alternately, CAD does not recognize one or the other, it says 'unknown command' and executes then the one which was used first:
(defun c:os1 ()
(command ".undo" "begin")
(while (vl-cmdf "offset" ".25" pause pause "")
(vl-cmdf "chprop" "l" "" "lt" "continuous" ""))
(command "undo" "end")
(princ)
)
(defun c:os2 ()
(command ".undo" "begin")
(while (vl-cmdf "offset" ".2" pause pause "")
(vl-cmdf "chprop" "l" "" "lt" "continuous" ""))
(command "undo" "end")
(princ)
)
I must have done something wrong when I added repeating functionality, as they worked fine before that (below):
(defun c:os1 ()
(command ".undo" "begin")
(command "offset" ".25" pause pause "")
(command "chprop" "l" "" "lt" "continuous" "")
(command "undo" "end")
(princ)
)
thanks!
@robert06 wrote:
Using these two lisps alternately, CAD does not recognize one or the other, it says 'unknown command' and executes then the one which was used first:
(defun c:os1 ()
(command ".undo" "begin")
(while (vl-cmdf "offset" ".25" pause pause "")
(vl-cmdf "chprop" "l" "" "lt" "continuous" ""))
(command "undo" "end")
(princ)
)
...
The AutoLISP Reference says that (vl-cmdf) returns T, apparently regardless of anything the User does, which means the (while) loop won't ever end on its own. But you could try a different way of going about it, that also doesn't require changing the linetypes of each resulting object individually:
(defun C:OS1 (/ celt)
(command "_.undo" "_begin")
(setq celt (getvar 'celtype)); save current value
(command "_.offset" 0.25); leave User at selection prompt
(while (> (getvar 'cmdactive) 0) (command pause)); let User keep offsetting things until they end it
(setvar 'celtype celt); reset
(command "_.undo" "_end")
(princ)
)
It could probably use an error handler, to make sure CELTYPE gets reset if the User cancels or something.