TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: Zahex on May 12, 2005, 07:23:47 PM

Title: 3D experts wanted
Post by: Zahex on May 12, 2005, 07:23:47 PM
I'm working on a 3D routine and need some help

Thanks
Title: 3D experts wanted
Post by: Kerry on May 12, 2005, 07:31:56 PM
Wow, really !!
Title: 3D experts wanted
Post by: Kerry on May 12, 2005, 07:32:30 PM
sorry,    da debil made me do it
Title: 3D experts wanted
Post by: Zahex on May 12, 2005, 07:38:30 PM
can you help???
Title: 3D experts wanted
Post by: Kerry on May 12, 2005, 07:39:25 PM
with what ?? What's your difficulty ?
Title: 3D experts wanted
Post by: Zahex on May 12, 2005, 07:48:10 PM
it's hard to explain but basicly i want to draw a spiral through a solid.
i have a routine that defines the solid,it asks for:
1.base radius
2.top radius
3.height
4.number of polygon sides
5.insertion point

and i have  a spiral routine also,that draws spirals.
but now i first want to draw the solid and then the spiral but according to the spiral,kinda like the spiral is revolving arround the solid.

Do u understand?
should i post the routines?

Thanks
Title: 3D experts wanted
Post by: Kerry on May 12, 2005, 07:53:19 PM
Posting would be most excellent.

I have a bit to do today, so may be able to look at it tonight, If no-one else raises their hand. Chances are you will have a response before I get to look at it.

Good luck

kwb
Title: 3D experts wanted
Post by: Zahex on May 12, 2005, 07:56:12 PM
solid:

Code: [Select]

(defun c:1 ()
  (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)
)




spiral:

Code: [Select]



(defun C:2()
(setq
segs (getreal "Number of segments: ")
spin -1
ri (getreal "Base radius: ")
rf (getreal "Top radius: ")
rt (getreal "Extrusion radius: "));setq   ;for the extrusion path
(setq h (getreal "Elevation: "))
(setq ns (getint "Number of spirals: "))
(setq
tu (getreal "Turns: ")
old (getvar "osmode")
fi1 (/ (* 2 PI) segs)
i 0
points (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)
(setq
fi (* 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) ;for the extrusion path
(setvar "osmode" old)
(command "ucs" "p")


(command "array" (entlast) "" "p" s ns 360 "y")
(command "view" "swiso")
(command "_zoom" "e")
(command "shademode" "g")
); defun



even so,it would be great if you could help.

Thanks
Title: 3D experts wanted
Post by: Kerry on May 12, 2005, 08:26:03 PM
You may have to explain a little better what you are trying to do.  

The prompts don't mean a lot to me.
Quote

One-element array, nothing to do.
; error: Function cancelled
Title: 3D experts wanted
Post by: Kerry on May 12, 2005, 08:29:25 PM
This is what I get :

(http://www.theswamp.org/screens/kerry/spiral.png)
Title: 3D experts wanted
Post by: CAB on May 12, 2005, 10:36:34 PM
Kerry,
Check this out, i combined the lisp but have no idea about the 3d stuff.
http://www.theswamp.org/phpBB2/viewtopic.php?p=62392#62392

this is what it produces:
Code: [Select]
Command: zahex
._undo Enter the number of operations to undo or
[Auto/Control/BEgin/End/Mark/Back] <1>: _begin
Command:
 larger radius: 120

 smaller radius: 60

 height: 200

 number of polygon sides: 6

 insertion point: Number of spirals: 4
Extrusion radius: 25
Turns: 6


._undo Enter the number of operations to undo or
[Auto/Control/BEgin/End/Mark/Back] <1>: _end

(http://www.theswamp.org/screens/cab/Zahex.png)
Title: 3D experts wanted
Post by: MP on May 12, 2005, 11:03:20 PM
mmmm, jello.
Title: 3D experts wanted
Post by: CAB on May 12, 2005, 11:22:27 PM
:shock:  :)  :)
It's past your bed time young man. 8)
Title: 3D experts wanted
Post by: MP on May 12, 2005, 11:38:04 PM
But DaaAD!
Title: Hey CAB
Post by: Zahex on May 14, 2005, 06:08:11 PM
Hey CAB are you in here??

i've one question about the code you posted...

Thanks
Title: 3D experts wanted
Post by: CAB on May 14, 2005, 06:13:49 PM
Just passing through, headed out to early dinner.
I'll catch up tonight.
Title: for later
Post by: Zahex on May 14, 2005, 06:30:06 PM
Hey CAB:

Nice dinner?
Well,i saw you're picture and that was exactly what i wanted to do but the code you posted in another subject of mine doesn't do what appeared in the picture.In your code(c:zahex)the spiral appears in tne solid interior other thanface to face with the solid faces.
Why does that happen?
Other than that it's perfect...

Thank you

PS-i wrote this post in case i don't meet you here later
Title: forgot this...
Post by: Zahex on May 14, 2005, 07:36:14 PM
forgot this...

example:

command prompt:"keep the (s)olid or create s(t)ructure?:" if the user choses (t) how do i define that the solid is erased so that the structure is drawn?(knowing that i have 2 defuns one for each:(defun solid) and (defun structure))

Thanks
Title: Re: for later
Post by: CAB on May 15, 2005, 07:53:30 AM
Quote from: Zahex
Hey CAB:

Nice dinner?
Well,i saw you're picture and that was exactly what i wanted to do but the code you posted in another subject of mine doesn't do what appeared in the picture.In your code(c:zahex)the spiral appears in tne solid interior other thanface to face with the solid faces.
Why does that happen?
Other than that it's perfect...

Thank you

PS-i wrote this post in case i don't meet you here later

Yes, thanks.

I suspect that if the picture is what you are after and you entered the responses as I did in the code above.
That is like this:
 larger radius: 120
 smaller radius: 60
 height: 200
 number of polygon sides: 6
 insertion point: Number of spirals: 4
Extrusion radius: 25
Turns: 6

The problem is most likely a system variable in your environment that is not the same as in my environment.
Upload your drawing with the attempted results using the entries above to the link at the top of this page.
In other words click on 'Lilly Pond'  above using your user name & password to upload your drawing.
Title: Re: forgot this...
Post by: CAB on May 15, 2005, 07:56:35 AM
Quote from: Zahex
forgot this...

example:

command prompt:"keep the (s)olid or create s(t)ructure?:" if the user choses (t) how do i define that the solid is erased so that the structure is drawn?(knowing that i have 2 defuns one for each:(defun solid) and (defun structure))

Thanks

Sorry the question is unclear to me.

If you want to delete an entity you already have the name of use (entdel <entName>)
Title: 3D experts wanted
Post by: Zahex on May 15, 2005, 01:32:17 PM
The program you did only works with the values you defined in your previous code?
What i mean is,it only works with these values?:
Quote

That is like this:
larger radius: 120
smaller radius: 60
height: 200
number of polygon sides: 6
insertion point: Number of spirals: 4
Extrusion radius: 25
Turns: 6


i would want it to work for all values..

thanks