### Author Topic: 2 fusion codes  (Read 2602 times)

0 Members and 1 Guest are viewing this topic.

#### Zahex

• Guest ##### 2 fusion codes
« on: May 12, 2005, 08:44:22 AM »
i have 2 routines
1-draws a solid with top and base radius,number of polygon sides,height and insertion point
you can see how the first one works here:
Code: [Select]
`(defun c:2 ()  (defun Radians->Degrees (rads)  (* rads (/ 180.0 pi)))  (setq radius (getdist "\n top radius: "))  (setq baseradius (getdist "\n base radius: "))  (setq height (getdist "\n height: "))  (setq angRad (atan (- radius baseradius) height))  (setq angDeg (Radians->Degrees angRad))  (setq sides (getint "\n number of polygon sides: "))  (setq centerpt (getpoint "\n insertion point: "))  (setq osnaps (getvar "osmode"))  (setvar "osmode" 0)  (command "polygon"   sides   centerpt   "C"   (polar centerpt 0 radius)  )  (command "extrude" (entlast) "" height angDeg)  (setvar "osmode" osnaps))`

now what i would like to do is to ask the user,after the solid is defined,if he wants to continue(c) or to exit(x) if he choses to continue a spiral is drawn accordind to the questions previously answered in the solid routine,at this point there are only 2 questions to ask:
1-number of turns
2-extrusion path

here's the spiral routine:

Code: [Select]
`(defun C:spiral()(command "erase" "all" "")(command "osnap" "off")(command "ortho" "off")(command "ucsicon" "off")(setqsegs (getreal "Number of segments: ")spin -1ri (getreal "Base radius: ")rf (getreal "Top radius: ")rt (getreal "Extrusion radius: "));setq(setq h (getreal "Elevation: "))(setq ns (getint "Number of spirals: "))(setqtu (getreal "Turns: ")old (getvar "osmode")fi1 (/ (* 2 PI) segs)i 0points (fix (* tu segs))h1 (/ h points)r1 (/ (- rf ri) points)s (getpoint "Center of base: ")end (list (car s) (cadr s) (+ h (caddr s))));setq(setvar "osmode" 0 )(command "line" s end "")(command "chprop" "l" "" "c" 1 "")(command "3dpoly")(setq i 0)(repeat (1+ points)(setqfi (* i fi1)h (* i h1)r (+ ri (* i r1))x (* r (cos fi))y (* spin r (sin fi)));setq(command (list (+ (car s) x) (+ (cadr s) y) (+ (caddr s) h)))(setq i (1+ i)));repeat(command "")(setvar "osmode" old)(setq spiral (entlast))(command "ucs" "n" "za" (polar s 0 ri)(list(+(car s) (* ri (cos fi1)))(+(cadr s) (* spin ri (sin fi1)))h1))(command "circle" "0,0,0" rt)(command "extrude" (entlast) "" "p" spiral)(setvar "osmode" old) (command "ucs" "p")(command "array" (entlast) "" "p" s ns 360 "y")(command "view" "swiso")(command "_zoom" "e")(command "shademode" "g")); defun `

thanks

#### Zahex

• Guest ##### CAB
« Reply #1 on: May 12, 2005, 08:53:21 AM »
Maaybe CAB could give me a hand over here...

Tahnks ##### 2 fusion codes
« Reply #2 on: May 12, 2005, 10:21:09 AM »
What var in the 2 routine does this var come from?
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970

#### Zahex

• Guest ##### 2 fusion codes
« Reply #3 on: May 12, 2005, 10:36:58 AM »
Don't know if i understood what you asked...
The extrusion radius is what gives the spiral tridimension,i extruded the circle trough the path that defines the spiral... ##### 2 fusion codes
« Reply #4 on: May 12, 2005, 10:42:20 AM »
What var in the 2 routine defines the Extrusion radius?

You said only two prompts remain
1-number of turns
2-extrusion path

And what are you calling this routine with, command I mean?
Not 3 I hope I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970

#### Zahex

• Guest ##### 2 fusion codes
« Reply #5 on: May 12, 2005, 10:48:53 AM »
None,the var of the extrusion radius only appears when the spiral is drawn.The 2 routine only defines the solid,just the solid.The two prompts you talked about are part of the second part of questions,after the user defined the solid.

What i would like to know is how to merge these two routines so it first draws a solid and then draws the spiral arround it. ##### 2 fusion codes
« Reply #6 on: May 12, 2005, 10:52:51 AM »
OK, this is what I have so far.
Code: [Select]
`(defun c:Zahex (/ usercmd useros ri height angDeg sides cenpt rf dtr rtd END FI FI1            H H1 I NS POINTS R R1 RT SPIN SPIRAL TU X Y           )  (defun dtr (a) (* pi (/ a 180.0)))  (defun rtd (a) (* 180.0 (/ a pi)))  (command "._undo" "_begin")  (setq usercmd (getvar "CMDECHO"))  (setvar "CMDECHO" 0)  (setq useros (getvar "osmode"))  (command "._ortho" "off")  (command "._ucsicon" "off")  (if (and        (setq ri (getdist "\n larger radius: "))        (setq rf (getdist "\n smaller radius: "))        (setq height (getdist "\n height: "))        (setq angDeg (- 90.0 (rtd (atan height (- ri rf)))))        (setq sides (getint "\n number of polygon sides: "))        (setq cenpt (getpoint "\n insertion point: "))        (setq ns (getint "Number of spirals: "))        (setq rt (getdist "Extrusion radius: "))        (setq tu (getreal "Turns: "))      )    (progn      (setvar "osmode" 0)      (command "._polygon" sides cenpt "_C" ri)      (command "._extrude" (entlast) "" height angDeg)      ;;  Satrt spiral       (setq spin   -1            fi1    (/ (* 2 PI) sides)            i      0            points (fix (* tu sides))            h1     (/ height points)            r1     (/ (- rf ri) points)            end    (list (car cenpt) (cadr cenpt) (+ height (caddr cenpt)))      ) ;setq       (setvar "osmode" 0)      (command "._line" cenpt end "")      (command "._chprop" "_l" "" "_c" 1 "")      (command "._3dpoly")      (setq i 0)      (repeat (1+ points)        (setq fi (* i fi1)              h  (* i h1)              r  (+ ri (* i r1))              x  (* r (cos fi))              y  (* spin r (sin fi))        ) ;setq         (command (list (+ (car cenpt) x) (+ (cadr cenpt) y) (+ (caddr cenpt) h))        )        (setq i (1+ i))      ) ;repeat       (command "")      (setq spiral (entlast))      (command "._ucs" "_n" "_za"               (polar cenpt 0 ri)               (list                 (+ (car cenpt) (* ri (cos fi1)))                 (+ (cadr cenpt) (* spin ri (sin fi1)))                 h1               )      )      (command "._circle" "0,0,0" rt)      (command "._extrude" (entlast) "" "_p" spiral)      (command "._ucs" "_p")      (command "._array" (entlast) "" "_p" cenpt ns 360 "_y")      (command "._view" "_swiso")      (command "._zoom" "_e")      (command "._shademode" "_g")    )  )  (setvar "osmode" useros)  (setvar "CMDECHO" usercmd)  (command "._undo" "_end")  (princ))(prompt "\nRoutine Zahex Loaded, Enter Zahex to run.")(princ)`

Gotta go do some work....
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970

#### daron

• Guest ##### 2 fusion codes
« Reply #7 on: May 12, 2005, 10:54:40 AM »
Sometimes, it's easier to not merge two routines, just start over. How about some pseudo-code on what you need to accomplish and how you would go about doing this, step x step. Then maybe it'll become clearer to everyone. Sorry for not offering up anything more valuable.

#### Zahex

• Guest ##### 2 fusion codes
« Reply #8 on: May 12, 2005, 11:07:25 AM »
Ok Daron,i'll explain it step by step and then maybe you can give me a hand.

1-create a solid(i already have a routine that does that)
2-after the solid is drawn i want to appear this question in the command prompt:"would you like to (c)ontinue or (e)xit?" if the user 's answer is e that's it(only the solid) if he choses to continue(c) two questions would be made a)"number of spiral turns" b)"extrusion radius"
the spiral would appear tangent to the solid withe the same number of segments as the base polygon number of sides.

I'm sorry,do you understand it better,now?

What CAB did is almost what i want only in his routine,the spiral is inside the solid and i want it tangent to the solid.the solid is what gives shape to the spiral

Tahnks

#### Zahex

• Guest ##### 2 fusion codes
« Reply #9 on: May 12, 2005, 11:41:05 AM »
if you run the spiral routine,after it's done(the spiral)you can understand that in the spital' s interior there's a void with a form...what i would like to do is to make that void solid and create the routine backwords...

#### Zahex

• Guest ##### Oh God,this is hard to explain
« Reply #10 on: May 12, 2005, 11:51:02 AM »
Here it goes:

1-the user defines the solid