Author Topic: random extrude  (Read 5001 times)

0 Members and 1 Guest are viewing this topic.

dussla

  • Bull Frog
  • Posts: 297
random extrude
« on: February 11, 2008, 10:09:12 AM »
hello friend again
i thought   idea  all at once , so i am writing help message  again

 :cry: :cry: :cry: :cry: :cry:

my idea is  random extrude

there are many closed polyline , i would like to extrude condition below

wanted   routine
1. select  closed polylines ( rectangles   , circle , ... closed polyline....)
2. write wanteded  number for extude height range  (ex :  100~ 1000   )
3. step   ( ex: 50)
4 ,result  :   random extruded polylines heights ( ex: 150 , 200 , 350 , 450   .................950  )1000 )
like image below


there is no random function in lisp ~
dear  friends  , is that possible ?


« Last Edit: February 13, 2008, 07:17:10 AM by dussla »

Didge

  • Bull Frog
  • Posts: 211
Re: random extrude
« Reply #1 on: February 11, 2008, 11:01:21 AM »
Here's a pseudo-random snippet that may help.

Code: [Select]
;****************************************************************************************
; RAND  Function to return a random number between 1 and the supplied integer.          *
; ====                                                                                  *
;       (rand 49) will return a pseudo-random number somewhere between 0-49 inclusive.  *
;****************************************************************************************
(defun RAND (fact / 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)
  )
  (fix (* random (1+ fact)))
)
Think Slow......

KewlToyZ

  • Guest
Re: random extrude
« Reply #2 on: February 12, 2008, 10:09:49 PM »
I think people here need more information from you as well.
Are you looking for choices in specific polygon designations to apply heights on?
Are you looking for some sort of DCL interface to accomplish your goals on the client side?

dussla

  • Bull Frog
  • Posts: 297
Re: random extrude
« Reply #3 on: February 13, 2008, 07:18:38 AM »
dear friends ~
i don't need dcl interface
only simple  code ~  that's all  only
 :-) :-) :-) :-)


DEVITG

  • Bull Frog
  • Posts: 481
Re: random extrude
« Reply #4 on: February 13, 2008, 12:11:31 PM »
hello friend again
i thought   idea  all at once , so i am writing help message  again

 :cry: :cry: :cry: :cry: :cry:

my idea is  random extrude

there are many closed polyline , i would like to extrude condition below

wanted   routine
1. select  closed polylines ( rectangles   , circle , ... closed polyline....)
2. write wanteded  number for extude height range  (ex :  100~ 1000   )
3. step   ( ex: 50)
4 ,result  :   random extruded polylines heights ( ex: 150 , 200 , 350 , 450   .................950  )1000 )
like image below
there is no random function in lisp ~
dear  friends  , is that possible ?


Could you upload a sample DWG , the  150 , 200 , 350 , 450   .................950  )1000    will be fixed and used  randomly??

What is the idea , to build a city wit random height buildings??

 

Location @ Córdoba Argentina Using ACAD 2019  at Window 10

dussla

  • Bull Frog
  • Posts: 297
Re: random extrude
« Reply #5 on: February 13, 2008, 08:50:00 PM »
DEVITG  ~ yes   your reply is correct anwser~~
can you see my attatched file ~

gile

  • Gator
  • Posts: 2515
  • Marseille, France
Re: random extrude
« Reply #6 on: February 14, 2008, 04:24:30 AM »
Hi,

Something like this:

Code: [Select]
(defun rng (/ modulus multiplier increment random)
  (if (not seed)
    (setq seed (getvar "DATE"))
  )
  (setq modulus    4294967296.0
multiplier 1664525
increment  1
seed    (rem (+ (* multiplier seed) increment) modulus)
random    (/ seed modulus)
  )
)

(defun c:random-extrude (/ ss reg)
  (vl-load-com)
  (or *acdoc*
      (setq *acdoc* (vla-get-ActiveDocument (vlax-get-acad-object)))
  )
  (setq sp (vla-get-ModelSpace *acdoc*))
  (if (ssget '((0 . "CIRCLE,LWPOLYLINE")))
    (progn
      (vla-StartUndoMark *acdoc*)
      (vlax-for obj (vla-get-ActiveSelectionSet *acdoc*)
(setq reg (vl-catch-all-apply
    'vlax-invoke
    (list sp 'addRegion(list obj)))
)
(or (vl-catch-all-error-p reg)
    (and
      (vla-addExtrudedSolid
sp
(car reg)
(* 50 (fix (+ 2 (* 18 (rng)))))
0.0
      )
      (vla-delete (car reg))
    )
)
      )
      (vla-EndUndoMark *acdoc*)
    )
  )
  (princ)
)
« Last Edit: February 14, 2008, 05:48:02 AM by gile »
Speaking English as a French Frog

DEVITG

  • Bull Frog
  • Posts: 481
Re: random extrude , with lost RNG defun
« Reply #7 on: February 14, 2008, 04:52:09 AM »
Hi , could you upload the RNG ??
Location @ Córdoba Argentina Using ACAD 2019  at Window 10

gile

  • Gator
  • Posts: 2515
  • Marseille, France
Re: random extrude
« Reply #8 on: February 14, 2008, 05:51:51 AM »
Ooopss !!!

I forgoted to join it, the upper code is now updated.
Speaking English as a French Frog

dussla

  • Bull Frog
  • Posts: 297
Re: random extrude
« Reply #9 on: February 14, 2008, 09:48:31 AM »
gile , thank you  good code
but 
i need    range  and   step options  for my wanted heights

2. write wanteded  number for extude height range  (ex between  :  100~ 1000   )   ex: ( 3000 ~ 6000) 
3. step   ( ex: 50)  (ex: 100) .....

is that possible ?
« Last Edit: February 14, 2008, 09:51:34 AM by dussla »

gile

  • Gator
  • Posts: 2515
  • Marseille, France
Re: random extrude
« Reply #10 on: February 14, 2008, 10:18:09 AM »
EDIT corrected the random height calculus

EDIT 2: have to use round instead of fix

Code: [Select]
(defun rng (/ modulus multiplier increment random)
  (if (not seed)
    (setq seed (getvar "DATE"))
  )
  (setq modulus    4294967296.0
multiplier 1664525
increment  1
seed    (rem (+ (* multiplier seed) increment) modulus)
random    (/ seed modulus)
  )
)

(defun round (num prec)
  (* prec
     (fix ((if (minusp num)
     -
     +
   )
    (/ num prec)
    0.5
  )
     )
  )
)

(defun c:random-extrude (/ minht maxht step ss reg)
  (vl-load-com)
  (or *acdoc*
      (setq *acdoc* (vla-get-ActiveDocument (vlax-get-acad-object)))
  )
  (setq sp (vla-get-ModelSpace *acdoc*))
  (initget 7)
  (setq minht (getdist "\nSpecify the minimum height: "))
  (while
    (not
      (and (setq maxht (getdist "\nSpecify the maximum height: "))
   (< minht maxht)
      )
    )
     (princ
       (strcat "\nThe value must be greater than " (rtos minht))
     )
  )
  (while
    (not
      (and (setq step (getdist "\nSpecify the step: "))
   (< step (- maxht minht))
      )
    )
     (princ
       (strcat "\nThe value must be lower than " (rtos minht))
     )
  )
  (if (ssget '((0 . "CIRCLE,LWPOLYLINE")))
    (progn
      (vla-StartUndoMark *acdoc*)
      (vlax-for obj (vla-get-ActiveSelectionSet *acdoc*)
(setq reg (vl-catch-all-apply
    'vlax-invoke
    (list sp 'addRegion(list obj)))
)
(or (vl-catch-all-error-p reg)
    (and
      (vla-addExtrudedSolid
sp
(car reg)
                 (+ minht (* step (round (* (/ (- maxht minht ) step) (rng)) 1)))
0.0
      )
      (vla-delete (car reg))
    )
)
      )
      (vla-EndUndoMark *acdoc*)
    )
  )
  (princ)
)
« Last Edit: February 14, 2008, 01:34:59 PM by gile »
Speaking English as a French Frog

dussla

  • Bull Frog
  • Posts: 297
Re: random extrude
« Reply #11 on: February 14, 2008, 09:53:09 PM »
gile  , you are very very nice man
i think that is some difficult , you done it
always thank you , thank you very much , thank you very much ~ ^-^ ^-^ ^-^ ^-^ ^-^

and other firends ~~ thank you  also ~