Insert multiple block, and then randomize the size

HiIs it possible somehow with BricsCad to insert a block multiple times, and then use a command or lsp file which will generate different sizes for each block?I need this in a illustrative plan, where eq. a tree with radius 5 meters, is inserted along a line. With 500 trees on a line this looks to regular, so if it somehow is possible to make BricsCad randomize the inserted block lets say with radius between 4 and 6 meters, this would be a great illustrative tool.Best regardsMads Boserup Lauritsen, Denmark

Comments

  • oh, fun, this will do the scaling : )load and type doit

    (DEFUN C:DOIT (/ C E O S SCL) (VL-LOAD-COM) (SETQ E (ENTGET (CAR (ENTSEL "Select a Block")))) (IF (EQ (CDR (ASSOC 0 E)) "INSERT") (PROGN (SETQ S (SSGET "X" (LIST (ASSOC 0 E) (ASSOC 2 E)))) (IF S (PROGN (SETQ C 0) (WHILE (< C (SSLENGTH S)) (SETQ O (VLAX-ENAME->VLA-OBJECT (CDR (CAR (ENTGET (SSNAME S C))))) SCL (* (GETRANDNUM 1 10) 0.25) ;; adjust this C (1+ C) ) (VLA-SCALEENTITY O (VLA-GET-INSERTIONPOINT O) SCL) ) ) (ALERT (STRCAT "Could Not find any " (CDR (ASSOC 2 E)) " Blocks")) ) ) ) (PRINC))(DEFUN RANDNUM (/ INCREMENT MODULUS MULTIPLIER RANDOM) (IF (NOT *SEED*) (SETQ *SEED* (GETVAR "DATE")) ) (SETQ MODULUS 65536 MULTIPLIER 25173 INCREMENT 13849 *SEED* (REM (+ (* MULTIPLIER *SEED*) INCREMENT) MODULUS) RANDOM (/ *SEED* MODULUS) ))(DEFUN GETRANDNUM (MINNUM MAXNUM / RANDOM TMP) (IF (NOT (< MINNUM MAXNUM)) (PROGN (SETQ TMP MINNUM MINNUM MAXNUM MAXNUM TMP ) ) ) (SETQ RANDOM (+ (* (RANDNUM) (- MAXNUM MINNUM)) MINNUM)))
  • Hi DanielNice.. did you write the code?If I somehow would learn how to "control" your plugin where should I start? It is quite extreme in its randomizing of the "trees" but looks very promissing.Thx for your quick reply.Best regards,/mads

  • You can adjust the numbers in this line , the 1 and 10 is the range, and the 0.25 is the scale factor SCL (* (GETRANDNUM 1 10) 0.25)

  • Hi DanielThx.We are some collegues, in Denmark, that are working on a Open Soruce forum where we will share usefull codes and scripting for different programs.Are we allowed to share your code? And if we do, do you want your name mentioned in the script?Best regards, and once again thank youMads

  • Sure your free to share this, here are the credits for the random number generator;; GetRandNum;; Written by Stig Madsen;; Randnum.lsp;; Written by Paul Furman, 1996.;; Based on algorithm by Doug Cooper, 1982.

  • I have a short block randomizer I use for tree blocks.It slightly changes the size and then randomly rotates the blocks.To increase the effect, run it again.To use, first pick one of the blocks you intend to randomize,then choose "all" or "window" whatever part of the drawing you want.The lisp will choose only those blocks with the same name as the first selected.(defun c:bld( / @block @scale @i &block #blocks) (setq &block (car (entsel "choose block to be globally randomed:")) @block (cdr (assoc 2 (entget &block))) ) (princ "\nchoose blocks to be randomed") (setq #blocks (ssget (list (cons 0 "INSERT") (cons 2 @block)))) (setvar "cmdecho" 0) (setq @rot 32.6 @scl 1.1 ) (command "undo" "begin") (while #blocks (setq &block (ssname #blocks 0)) (ssdel &block #blocks) (setq $block (entget &block) ^i (trans (cdr (assoc 10 $block))0 1) @rot (+ 21.5 @rot) @scl (+ 0.05 @scl) @scl (if (< 1.2 @scl) 0.9 @scl) ) (command "ROTATE" &block "" ^i @rot) (command "SCALE" &block "" ^i @scl) ) (command "undo" "end") (setq #blocks nil) (setvar "cmdecho" 1))

  • Oh, and here's my sigline (add this to the lisp if you want to use it);; by Yaacov Lazar;; yaque.lazar@gmail.com

  • Hi Daniel and YaacovThx for your Scipts. If we are to use your scripts, we will off course name you in the lsp-file.Once again, thx, Best regards,Mads Boserup Lauritsen

This discussion has been closed.