@pbejse Here is a version that will create your DCL on the fly 🙂
(defun c:nebula (/ _writefile lm:rand dch lm:randrange a d f ms p sp)
;; ronjonp | pbe | Lee Mac ;;
;; http://www.lee-mac.com/random.html
;; Rand - Lee Mac
;; PRNG implementing a linear congruential generator with
;; parameters derived from the book 'Numerical Recipes'
(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)
)
(defun _writefile (fn l / f)
(cond ((and (eq 'str (type fn)) (setq f (open fn "w")))
(foreach x l (write-line x f))
(close f)
fn
)
)
)
(defun lm:randrange (a b) (+ (min a b) (fix (* (lm:rand) (1+ (abs (- a b)))))))
(or initval (setq initval '(("size" "250000") ("dcnt" "2000") ("scnt" "100") ("srot" "0"))))
(foreach var initval
(if (setq dflt (eval (read (car var))))
dflt
(set (read (car var)) (cadr var))
)
)
;; RJP added DCL creation
(or (findfile (setq f (strcat (getenv "TEMP") "Galaxy 2.0.dcl")))
(_writefile
f
'("dcl_settings : default_dcl_settings { audit_level = 3; }"
"ed : edit_box {\tfixed_width = true; width = 6; alignment = right;}"
"tx : text {alignment = left; height = 0.1;}"
"" "Nebula : dialog {"
"//label = \"Create virtual galaxy\";" "\tkey = \"mine\";"
" : boxed_column {" "\tlabel = \"Quantities of...\";"
"\t: row {" " \t: column {"
" \tspacer_0 ;" " \t: tx { label = \"\\tGalaxy Size:\" ; }"
" \t: tx { label = \"\\tDust particles:\" ; }"
"\t: tx { label = \"\\tStars:\" ; }"
"\t: tx { label = \"\\tStar axis rotation increment:\" ; }"
" \t\t}" "\t: column {"
"\t : ed { key = \"size\"; } " "\t : ed { key = \"dcnt\"; } "
"\t : ed { key = \"scnt\"; }" "\t : ed { key = \"srot\"; }"
"\t \t}" "\t \t}"
"\tspacer ; " "\t}//bc1"
" spacer_1;" " ok_cancel;"
"}"
)
)
)
(cond ((<= (setq dch (load_dialog f)) 0) (princ "\nUnable to find/load Nebula.dcl file."))
((not (new_dialog "Nebula" dch)) (princ "\nUnable to display dialog."))
((set_tile "mine" (strcat (getvar 'loginname) "'s Galaxy"))
(foreach key '("size" "dcnt" "scnt" "srot")
(set_tile key (eval (read key)))
(action_tile key (vl-prin1-to-string (quote (set (read $key) (get_tile $key)))))
)
(mode_tile "srot" 1)
(action_tile "accept" "(done_dialog 1)")
(action_tile "cancel" "(done_dialog 0)")
(setq flag (start_dialog))
)
)
(if (< 0 dch)
(unload_dialog dch)
)
(if (zerop flag)
(princ "\n<<< User cancelled >>>")
(progn (setq ms (vla-get-modelspace (vla-get-activedocument (vlax-get-acad-object))))
(setq d (distof size))
(setq a (lm:randrange 1 (/ d 20.))) ;<-- we will do this later ;;
;; For now we are using 3DSolid ;;
(repeat (atoi scnt)
(setq p (list (lm:randrange (- d) d) (lm:randrange (- d) d) (lm:randrange (- d) d)))
(if (setq sp (vlax-invoke ms 'addsphere p (lm:randrange 1 a)))
(vla-put-color sp (lm:randrange 1 255))
)
)
(repeat (atoi dcnt)
(setq p (list (lm:randrange (- d) d) (lm:randrange (- d) d) (lm:randrange (- d) d)))
(entmake (list '(0 . "POINT") (cons 10 p) (cons 62 (lm:randrange 1 255))))
)
)
)
(princ)
)