CAD Forum - tips, tricks, discussion and utilities for AutoCAD, Inventor, Revit and other Autodesk products [www.cadforum.cz] ARKANCE | CONTACT - CZ | SK | EN | DE

CAD tip CAD tip # 1366:

Question

CAD 
 %  platform  category 
A
Use the following function for a LISP generator of pseudo-random numbers:
(defun rnd (/ modulus multiplier increment random)
  (if (not seed)
    (setq seed (getvar "DATE"))
  )
  (setq modulus    65536
        multiplier 25173
        increment  13849
        seed  (rem (+ (* multiplier seed) increment) modulus)
        random     (/ seed modulus)
  )
)
Each call of the function (rnd) then returns a pseudo-random number in the range (0,1). E.g. to get random integers from 0 to 20, use (fix(* 20 (rnd))).
ACAD
100% *CAD
1.6.2001    20491×  
applies to: AutoCAD ·

See also:
Tip 14686:Environment variables in AutoCAD.
Tip 14650:3D rotation of a DWG object to the target point.
Tip 14643:Easy insertion of arrows into MText content.
Tip 14630:Extended ASCPOINT - import coordinates from CSV file, including blocks with attributes, GPS coordinates, etc.
Tip 14620:Converting object data (OD) to XData (XD) in AutoCAD Map 3D.


Back    All CAD Tips



Have we helped you? If you want to support the CAD Forum web service, consider buying one of our CAD applications, or our custom software development offerings, or donating via PayPal (see above). You may also add a link to your web - like this "fan" link: CAD Forum - tips, utilities, blocks for Autodesk products
CAD: 
OS: 
Categ: 
Text:
 FAQ
  



Featuring:
Extend your AutoCAD LT productivity with our popular add-on
ARKANCE LT Extension More info


Please use these tips at your own risk.
ARKANCE is not responsible for possible problems that may occur as a result of using any of these tips.
TOPlist