Make existing to number longer

Make existing to number longer

mike2334
Enthusiast Enthusiast
816 Views
3 Replies
Message 1 of 4

Make existing to number longer

mike2334
Enthusiast
Enthusiast

If I have this (setq serm "16552D2") I would like to add three random digits {like 9Z5} to serm so it would look like                                               this  "16552D29Z5"

Michael Fyfe
0 Likes
Accepted solutions (2)
817 Views
3 Replies
Replies (3)
Message 2 of 4

cadffm
Consultant
Consultant
Accepted solution

And the question is...

Ooen your Help[F1] 

Look for STRCAT AutoLisp

 

HTH

Sebastian

Message 3 of 4

Sea-Haven
Mentor
Mentor
Accepted solution

If you want alpha's and numbers then need to look at random number generator lisp.

a-z 97-122

A-Z 65-90

0-9 48-57

 

So use a range on the random number 48-122.

;; Random in Range  -  Lee Mac
;; Returns a pseudo-random integral number in a given range (inclusive)

(defun LM:randrange ( a b )
    (+ (min a b) (fix (* (LM:rand) (1+ (abs (- a b))))))
)

 Check for unwanted numbers and do again 

0 Likes
Message 4 of 4

Sea-Haven
Mentor
Mentor

Need this also sorry missed in prior post

 

To be able to edit prior post come on Autodesk update your forum.

 

: Random number generator by Lee-mac

(defun LM:rand ( / a c m )
    (setq m   4294967296.0
          a   1664525.0
          c   1013904223.0
          $xn (rem (+ c (* a (cond ($xn) ((getvar 'date))))) m)
    )
    (/ $xn m)
)

 sorry 

0 Likes