Jump to content

Recommended Posts

  • 2 years later...
  • Replies 28
  • Created
  • Last Reply

Top Posters In This Topic

  • Lee Mac

    7

  • smitaranjan

    5

  • BIGAL

    3

  • VisDak

    2

Top Posters In This Topic

Posted Images

Posted
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

Posted (edited)

station marking example:  are in mtext formatimage.thumb.png.25188762bcea3b675f35b603f3eb0fd6.png

Edited by smitaranjan
Posted

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")

  • 2 weeks later...
Posted
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.

Posted (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 by BIGAL
Posted
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

Posted
On 2/14/2024 at 9:09 PM, smitaranjan said:

SRS.dwg Please check

@BIGAL have you checked?

 

Posted

Not sure what happened to this, previously posted or its posted on another forum like forum/autodesk.

 

 

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...