makimaki Posted March 9, 2015 Posted March 9, 2015 I have a lisp file the inserts lot numbers in ascending order. My problem is that this lisp is not applicable in numbering sublots, because for sublots, lot numbering will be alphabetical. For example, A mother lot has a lot number of 234 and is divided into two lots. The first lot number would be "234-A" and the second would be "234-B". Can someone help me with this? Just a newbie in lisp programming. Thanks in advance! lot number.lsp Quote
BIGAL Posted March 9, 2015 Posted March 9, 2015 A couple of things your while you can make it (while (setq p1 (getpoint "\nText location: ")) this will exit if you press enter . not sure why done this way (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 [b]sub lot[/b] 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 Need to have a think some one else may post an answer straight away. Quote
makimaki Posted March 15, 2015 Author Posted March 15, 2015 Thanks for the help BIGAL. I'll try it. Quote
pBe Posted March 15, 2015 Posted March 15, 2015 (edited) (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" for Lot mode "S" for Sub-lot mode 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 : Edited March 19, 2015 by pBe remove cmdecho Quote
Tharwat Posted March 15, 2015 Posted March 15, 2015 pBe What is the use of the system variable cmdecho in your routine ? If a user went with the option S and exceeded Y char while keep on picking points , they would face strange symbols face to face instead of alphabetical chars . Good idea by the way . Quote
pBe Posted March 15, 2015 Posted March 15, 2015 What is the use of the system variable cmdecho in your routine ? (setq scmde (getvar "cmdecho")) From the OP, no idea why either If a user went with the option S and exceeded Y char while keep on picking points , they would face strange symbols face to face instead of alphabetical chars . Thought about that too. I was counting on the sub-lots would not exceed the 26 letters of the alphabet. but we could modify the code to consider that scenario in the future if it comes to that. Good catch btw. pBe Good idea by the way . Thank you tharwat Quote
hanhphuc Posted March 16, 2015 Posted March 16, 2015 c:lotn simple but nice idea pBE my $0.02 by grread mouse left for mother right click for children ,can save one step Quote
pBe Posted March 16, 2015 Posted March 16, 2015 simple but nice idea pBE Thank you for that hanhphuc ...grread... I thought about that too. To preserved running osnaps and an easy to understand coding for the benefit of the OP is why i kept it simple. Quote
BIGAL Posted March 18, 2015 Posted March 18, 2015 Sorry guys 52 characters in alphabet but lower case would be confusing. Quote
makimaki Posted March 18, 2015 Author Posted March 18, 2015 THank you so much pBe and all you guys. Quote
makimaki Posted March 18, 2015 Author Posted March 18, 2015 pBe, about the code you posted, i've been trying to edit it but i failed, because what i want is that before you will pick the insertion point of the text, you must choose first if it is only a lot number (1,2,3) or sub lot(1-A, 1-B, etc). lastly, how to insert the word "LOT" before the number/as prefix? because i would like my final output to be "LOT 1" for lot numbers and "LOT 1-A" for sublots. Thank you so much sir pBe. I really need this. Quote
BIGAL Posted March 18, 2015 Posted March 18, 2015 Sure Pbe wont mind change this (cons 1 (strcat "LOT " str)) Quote
pBe Posted March 18, 2015 Posted March 18, 2015 Thank you so much sir pBe. You are Welcome, Glad i could help. ...because what i want is that before you will pick the insertion point of the text, you must choose first if it is only a lot number (1,2,3) or sub lot(1-A, 1-B, etc) That is exactly how the routine is setup now. Pick next location/Press "S" for sub-lot: [b]S[/b] Or are you meaning before the very FIRST point? Sure Pbe wont mind change this (cons 1 (strcat "LOT " str)) No worries BIGAL, Not at all Cheers pBe Quote
makimaki Posted March 19, 2015 Author Posted March 19, 2015 yes sir pBe, before the very first point. i dont know how to re arrange the your code. Also I don't know where to insert or put sir BIGAL's suggestion about inserting the word "LOT". Thank you so much again. Quote
pBe Posted March 19, 2015 Posted March 19, 2015 yes sir pBe, before the very first point. i dont know how to re arrange the your code. Also I don't know where to insert or put sir BIGAL's suggestion about inserting the word "LOT". Thank you so much again. Yes its easy to do that, but will that be it or there'll be more addition to this? and what of the prefix, will it be always "LOT" ? just make sure before we do any mod on the code. Quote
makimaki Posted March 19, 2015 Author Posted March 19, 2015 Yes sir pBe. The prefix is always the word "LOT". so the output would be like "LOT 123" (for Lot numbers) or "LOT 123-A" (for Sub Lot Numbers). Again, before inserting the first number, the lisp routine will allow the user to select first if it will be a lot number or for sub lot number. Thanks again sir pBe. More power! Quote
BIGAL Posted March 19, 2015 Posted March 19, 2015 re change this old code (cons 1 str) new code (cons 1 (strcat "LOT " str)) Quote
makimaki Posted March 19, 2015 Author Posted March 19, 2015 Thank you sir BIGAL. much appreciated. Quote
pBe Posted March 19, 2015 Posted March 19, 2015 ..The prefix is always the word "LOT"....Again, before inserting the first number,.... Updated Code at Post#4 Thanks again sir pBe. More power! You are welcome. Quote
makimaki Posted March 19, 2015 Author Posted March 19, 2015 That code at post #4 was perfect mr pBe, or shall I call you master pBe. you're my hero. A million thanks master and all you guys (BIGAL, tharwat, hanhphuc) who posted, and shared your thoughts with regards to my problem. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.