Steven P Posted February 18, 2021 Share Posted February 18, 2021 16 hours ago, engstar88 said: thanks at first how can i turn the script into a lisp in cad or how can i use the script into the cad? I reckon Lee Mac has it covered here: How to Run an AutoLISP Program | Lee Mac Programming (lee-mac.com) Quote Link to comment Share on other sites More sharing options...
smitaranjan Posted February 1 Share Posted February 1 On 11/23/2012 at 12:45 AM, Lee Mac said: Try the following version: [color=GREEN];; Text Increment - Lee Mac[/color] [color=GREEN];; Increments numerical data found in a selected Text, MText or Attribute object[/color] [color=GREEN];; by a value specified by the user.[/color] ([color=BLUE]defun[/color] c:txtinc ( [color=BLUE]/[/color] e i l ) ([color=BLUE]if[/color] ([color=BLUE]null[/color] *inc*) ([color=BLUE]setq[/color] *inc* 1.0) ) ([color=BLUE]if[/color] ([color=BLUE]setq[/color] i ([color=BLUE]getreal[/color] ([color=BLUE]strcat[/color] [color=MAROON]"\nSpecify Increment <"[/color] ([color=BLUE]rtos[/color] *inc* 2) [color=MAROON]">: "[/color]))) ([color=BLUE]setq[/color] *inc* i) ) ([color=BLUE]if[/color] ([color=BLUE]equal[/color] 0.0 ([color=BLUE]rem[/color] *inc* 1) 1e- ([color=BLUE]setq[/color] *inc* ([color=BLUE]fix[/color] *inc*)) ) ([color=BLUE]while[/color] ([color=BLUE]progn[/color] ([color=BLUE]setvar[/color] 'errno 0) ([color=BLUE]setq[/color] e ([color=BLUE]car[/color] ([color=BLUE]nentsel[/color] [color=MAROON]"\nSelect Text, MText or Attribute: "[/color]))) ([color=BLUE]cond[/color] ( ([color=BLUE]=[/color] 7 ([color=BLUE]getvar[/color] 'errno)) ([color=BLUE]princ[/color] [color=MAROON]"\nMissed, try again."[/color]) ) ( ([color=BLUE]=[/color] 'ename ([color=BLUE]type[/color] e)) ([color=BLUE]if[/color] ([color=BLUE]wcmatch[/color] ([color=BLUE]cdr[/color] ([color=BLUE]assoc[/color] 0 ([color=BLUE]setq[/color] e ([color=BLUE]entget[/color] e)))) [color=MAROON]"*TEXT,ATTRIB"[/color]) ([color=BLUE]if[/color] ([color=BLUE]vl-some[/color] '[color=BLUE]numberp[/color] ([color=BLUE]setq[/color] l (LM:SplitString ([color=BLUE]cdr[/color] ([color=BLUE]assoc[/color] 1 e))))) ([color=BLUE]entmod[/color] ([color=BLUE]subst[/color] ([color=BLUE]cons[/color] 1 ([color=BLUE]apply[/color] '[color=BLUE]strcat[/color] ([color=BLUE]mapcar[/color] ([color=BLUE]function[/color] ([color=BLUE]lambda[/color] ( x ) ([color=BLUE]if[/color] ([color=BLUE]and[/color] ([color=BLUE]=[/color] 'int ([color=BLUE]type[/color] x)) ([color=BLUE]=[/color] 'int ([color=BLUE]type[/color] *inc*))) ([color=BLUE]itoa[/color] ([color=BLUE]+[/color] x *inc*)) ([color=BLUE]if[/color] ([color=BLUE]member[/color] ([color=BLUE]type[/color] x) '(int real)) ([color=BLUE]rtos[/color] ([color=BLUE]+[/color] x *inc*) 2) x ) ) ) ) l ) ) ) ([color=BLUE]assoc[/color] 1 e) e ) ) ([color=BLUE]princ[/color] [color=MAROON]"\nText contains no numerical data."[/color]) ) ([color=BLUE]princ[/color] [color=MAROON]"\nInvalid object selected."[/color]) ) ) ) ) ) ([color=BLUE]princ[/color]) ) [color=GREEN];; Split String - Lee Mac[/color] [color=GREEN];; Splits a string into a list of text and numbers[/color] ([color=BLUE]defun[/color] LM:SplitString ( s ) ( ([color=BLUE]lambda[/color] ( l ) ([color=BLUE]read[/color] ([color=BLUE]strcat[/color] [color=MAROON]"("[/color] ([color=BLUE]vl-list->string[/color] ([color=BLUE]apply[/color] '[color=BLUE]append[/color] ([color=BLUE]mapcar[/color] ([color=BLUE]function[/color] ([color=BLUE]lambda[/color] ( a b c ) ([color=BLUE]if[/color] ([color=BLUE]or[/color] ([color=BLUE]<[/color] 47 b 58) ([color=BLUE]and[/color] ([color=BLUE]=[/color] 45 b) ([color=BLUE]<[/color] 47 c 58) ([color=BLUE]not[/color] ([color=BLUE]<[/color] 47 a 58))) ([color=BLUE]and[/color] ([color=BLUE]=[/color] 46 b) ([color=BLUE]<[/color] 47 a 58) ([color=BLUE]<[/color] 47 c 58)) ) ([color=BLUE]list[/color] b) ([color=BLUE]list[/color] 32 34 b 34 32) ) ) ) ([color=BLUE]cons[/color] [color=BLUE]nil[/color] l) l ([color=BLUE]append[/color] ([color=BLUE]cdr[/color] l) ([color=BLUE]list[/color] [color=BLUE]nil[/color])) ) ) ) [color=MAROON]")"[/color] ) ) ) ([color=BLUE]vl-string->list[/color] s) ) ) ([color=BLUE]princ[/color]) IF a mtext is in (0+00) format, how addition and subtraction of some particular value will change selected mtext in that format{required for station marking } {eg. if A station marking is 5+47 and I want to add 50' with it, it will change to 5+97...and lisp should continue to change of selecting mtext until stop) mtext should not change its layer and color after the addition and subtraction Quote Link to comment Share on other sites More sharing options...
smitaranjan Posted February 1 Share Posted February 1 (edited) station marking example: are in mtext format Edited February 1 by smitaranjan Quote Link to comment Share on other sites More sharing options...
BIGAL Posted February 2 Share Posted February 2 Need lee-mac string to list so splits 2+47 into (2 47) then add your amount so becomes 2 & 97 then join back into a string 2+97. I just name each function based on the ascii character number. ; tab 9 space 32 + is 43 ; thanks to Lee-mac for this defun (defun csv->lst43 ( str / pos ) (if (setq pos (vl-string-position 43 str)) (cons (substr str 1 pos) (csv->lst43 (substr str (+ pos 2)))) (list str) ) ) (csv->lst43 "2+34") ("2" "34") Quote Link to comment Share on other sites More sharing options...
smitaranjan Posted February 13 Share Posted February 13 On 2/2/2024 at 6:00 AM, BIGAL said: Need lee-mac string to list so splits 2+47 into (2 47) then add your amount so becomes 2 & 97 then join back into a string 2+97. I just name each function based on the ascii character number. ; tab 9 space 32 + is 43 ; thanks to Lee-mac for this defun (defun csv->lst43 ( str / pos ) (if (setq pos (vl-string-position 43 str)) (cons (substr str 1 pos) (csv->lst43 (substr str (+ pos 2)))) (list str) ) ) (csv->lst43 "2+34") ("2" "34") Hi Bigal, can you post complete code so I can test and let you know. Quote Link to comment Share on other sites More sharing options...
BIGAL Posted February 14 Share Posted February 14 (edited) You have the split string so convert to say a real and add your offset value, using atof then make a new string using Rtos. No comments till a dwg supplied. Edited February 14 by BIGAL Quote Link to comment Share on other sites More sharing options...
smitaranjan Posted February 14 Share Posted February 14 15 hours ago, BIGAL said: You have the split string so convert to say a real and add your offset value, using atof then make a new string using Rtos. No comments till a dwg supplied. SRS.dwg Please check Quote Link to comment Share on other sites More sharing options...
smitaranjan Posted February 21 Share Posted February 21 On 2/14/2024 at 9:09 PM, smitaranjan said: SRS.dwg Please check @BIGAL have you checked? Quote Link to comment Share on other sites More sharing options...
BIGAL Posted February 22 Share Posted February 22 Not sure what happened to this, previously posted or its posted on another forum like forum/autodesk. Quote Link to comment Share on other sites More sharing options...
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.