Again, as I mentioned conditions that would cause the lisp to fail are:
1. Layer Vport is on is Locked
2. No Vports found in current Layout
So to make sure the Layer is not locked include this with the Layer commands at the beginning like this.
Perhaps share a sample dwg where the code fails
(defun c:LL()
; Layer Unlock everything
(Command "_.-LAYER" "UNL" "*" "")
; Layer Make sets Layer current
(Command "_.-LAYER" "_MAKE" "$X-ANNO-VPRT" "")
; Layer New creates Layer but does not set as current so you decide which one you want to use
;(Command "_.-LAYER" "_NEW" "$X-ANNO-VPRT" "")
; Now before running Mview command you need to first set Tilemode to 0
(COMMAND "_.TILEMODE" "0")
; then make sure is in Paper space & not in Model space inside a Vport
(Command "_.PSPACE")
; now run Mview command to Lock & turn On all Vports in current Layout
(Command "_.MVIEW" "_LOCK" "_ON" "_ALL" "")
; Chprop command Previous will only succeed if the current Vport's Layer is NOT Locked and there are Vports found in the current Layout
(Command "_.CHPROP" "_P" "" "_LAYER" "$X-ANNO-VPRT" "_COLOR" "BYLAYER" "")
; Draworder command only works if there are Previous Vports found
(Command "_.DRAWORDER" "_P" "" "_FRONT")
; Layer Locks the Vport layer
(Command "_.-LAYER" "_LOCK" "$X-ANNO-VPRT" "")
(princ)
)
; automatically run the command
(c:LL)