- (defun c:lotn ( / _text [color="blue"]_NextString [/color]mode opt str p1 p2 n1 str a)
- ;;; pBe 16 Mar2015 ;;;
- (defun _text (str pt)
- (entmakex (list (cons 0 "TEXT")
- (cons 10 pt)
- (cons 11 pt)
- (cons 40 (getvar 'textsize))
- '(72 . 4)
- '(73 . 2)
- (cons 1 (strcat "LOT " str))
- )
- )
- )
- [color="blue"](defun _NextString (n m)
- (strcat n
- (if m
- (strcat "-" (setq a (chr (1+ (ascii a)))))
- ""
- )
- )
- )[/color]
- [color="blue"](setq mode '(( "S" "Sub-lot mode")( "L" "Lot mode")))
- (initget "L S")
- (setq opt (cond ( (getkword "\nChoose [Lot/Sub lot] <Lot>: ") ) ( "L" )))
- (setq mode (if (setq l (eq opt "L")) mode (reverse mode)))
- (princ (strcat "\n<<< " (cadr (assoc opt Mode)) " >>>"))[/color]
- (setq a "@"
- n1 (getint "\nEnter starting lot number: ")
- str (itoa n1))
- (setq p1 (getpoint "\nText location: "))
- (_text [color="blue"](_NextString (itoa n1) (if l nil T))[/color] p1)
- (while
- (progn
- [color="blue"](princ (strcat "\n<<< " (cadadr mode) " >>>"))[/color]
- (initget [color="blue"](caar mode)[/color])
- (setq
- p2 (getpoint
- p1
- (strcat
- "\nPick next location/Press ""
- [color="blue"](caar mode)[/color]
- "" for " [color="blue"](cadar mode) [/color]" : "
- )
- )
- )
- )
- (cond
- ((listp p2)
- (if (eq [color="blue"](caar mode)[/color] "L")
- (_text (setq str [color="blue"](_NextString (itoa n1) T)[/color]) p2)
- (_text[color="blue"] (_NextString (itoa (setq n1 (1+ n1)))[/color] nil) p2)
- )
- (setq p1 p2)
- )
- ((eq p2 "S")
- (setq str [color="blue"](_NextString (itoa n1) T)[/color])
- [color="blue"] (setq mode (reverse mode))[/color]
- )
- ((eq p2 [color="blue"]"L"[/color])
- (setq [color="blue"]mode (reverse mode)[/color] a "@"))
- )
- )
- (princ)
- )
“L”表示批次模式
“S”表示子批次模式
- command: Lotn
- Choose [Lot/Sub lot] <Lot>: [color="red"][b]S[/b][/color]
- <<< Sub-lot mode >>>
- Enter starting lot number: [b][color="red"]12[/color][/b]
- Text location:
- <<< Sub-lot mode >>>
- Pick next location/Press "L" for Lot mode :
- <<< Sub-lot mode >>>
- Pick next location/Press "L" for Lot mode : [b][color="red"]L[/color][/b]
- <<< Lot mode >>>
- Pick next location/Press "S" for Sub-lot mode :
|