批号lisp需要帮助!
我有一个lisp文件,按升序插入批号。我的问题是,这个lisp不适用于子批次的编号,因为对于子批次,批次编号将按字母顺序排列。例如,一个母地块的批号为234,分为两个地块。第一个批号为“234-A”,第二个批号为“234-B”。有人能帮我吗?只是lisp编程的新手。提前感谢!批号。lsp 您可以在while(setq p1(getpoint“\nText location:”)中完成一些事情。如果按enter键,则会退出。
不知道为什么这样做
(command "text"
"J"
"MC"
(setq p p1)
(setq p "")
(setq p "")
(setq p n1)
)
(command "text" "J" "MC" p1 "" "" n) ; my version
;sublot do a press <CR> for next lot any key for a sub lot this would drop to A and keep going till you do a sub lot again then reset to A.
; maybe do defuns bit easier to do if's
需要考虑一下其他人可能会立即发布答案。 谢谢你的帮助。我试试看。 (defun c:lotn ( / _text _NextString mode opt str p1 p2 n1 stra)
;;; 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))
)
)
)
(defun _NextString (n m)
(strcat n
(if m
(strcat "-" (setq a (chr (1+ (ascii a)))))
""
)
)
)
(setq mode '(( "S" "Sub-lot mode")( "L" "Lot mode")))
(initget "L S")
(setq opt (cond ( (getkword "\nChoose <Lot>: ") ) ( "L" )))
(setq mode (if (setq l (eq opt "L")) mode (reverse mode)))
(princ (strcat "\n<<< " (cadr (assoc opt Mode)) " >>>"))
(setq a "@"
n1(getint "\nEnter starting lot number: ")
str (itoa n1))
(setqp1 (getpoint "\nText location: "))
(_text (_NextString (itoa n1) (if l nil T)) p1)
(while
(progn
(princ (strcat "\n<<< " (cadadr mode) " >>>"))
(initget (caar mode))
(setq
p2 (getpoint
p1
(strcat
"\nPick next location/Press \""
(caar mode)
"\" for " (cadar mode) " : "
)
)
)
)
(cond
((listp p2)
(if (eq (caar mode) "L")
(_text (setq str (_NextString (itoa n1) T)) p2)
(_text (_NextString (itoa (setq n1 (1+ n1))) nil) p2)
)
(setq p1 p2)
)
((eq p2 "S")
(setq str (_NextString (itoa n1) T))
(setq mode (reverse mode))
)
((eq p2 "L")
(setq mode (reverse mode) a"@"))
)
)
(princ)
)
“L”表示批次模式
“S”表示子批次模式
command: Lotn
Choose <Lot>: S
<<< Sub-lot mode >>>
Enter starting lot number: 12
Text location:
<<< Sub-lot mode >>>
Pick next location/Press "L" for Lot mode :
<<< Sub-lot mode >>>
Pick next location/Press "L" for Lot mode :L
<<< Lot mode >>>
Pick next location/Press "S" for Sub-lot mode :
pBe公司
系统变量cmdecho在例程中有何用途?
如果用户选择S并在继续拾取点的同时超过Y字符,他们将面对面地面对奇怪的符号,而不是字母字符。
顺便说一句,好主意。
(setq scmde (getvar "cmdecho"))
从OP上看,也不知道为什么
我也想过。我当时指望的是,子批次不会超过字母表中的26个字母。但是我们可以修改代码,以便在将来考虑这种情况。好的,顺便说一句。
谢谢tharwat 简单但不错的想法pBE
我的grread 0.02美元
老鼠留给妈妈
右键单击可保存一个步骤
谢谢你的邀请
我也想过。为了保持运行OSNAP和易于理解的编码以利于OP,这就是为什么我保持它简单的原因。 对不起,字母表中有52个字符,但小写会让人困惑。 非常感谢pBe和你们所有人。
页:
[1]
2