View Full Version : TWISTING 3D OBJECTS WITH AUTOCADR14
dangermouse
16th Jan 2003, 10:16 pm
HI
ok heres the problem people,i can draw a rectangle ,then extrude it to 250mm then view it in 3d form using 3d dynamic .but can i twist the object (say 90 degrees cw) along a lenghth of 150mm leaving 50mm of un-twisted material at each end .
thanks very much . DANGERMOUSE.
E-MAIL -dangmouse1@talk21.com
CADTutor
16th Jan 2003, 11:10 pm
NO
:(
I think you must be mistaking AutoCAD for a real 3D application :lol:
fuccaro
17th Jan 2003, 03:49 pm
Here is a simple Lisp routine to twist a square. To draw the untwisted areas –this will be your pleasure!
For help to use the lisp routine you may check the Autolisp section.
When you start this routine, the drawing must be clean of any other 3D objects! (sorry, this was the simplest way for me to write)
I am sure you have a speedy computer...
(defun C:twister()
(setq r (getreal "\n define the square:radius of circumscribed circle? <15> "))
(if (= r nil) (setq r 15))
(setq l (getreal "\n length of twisted area? <150>"))
(if (= l nil) (setq l 150))
(setq f (getreal "\n rotation angle? <90> "))
(if (= f nil) (setq f 90))
(setq segs (getint "\n segments? <100> "))
(if (= segs nil) (setq segs 100))
(setq oldsnap (getvar "osmode"))
(setq lu (getreal "lenght of untwisted area? <50>"))
(if (= lu nil) (setq lu 50))
(setvar "cmdecho" 0)
(setq f1 (/ (* PI f) segs -180.0)
l1 (/ l segs)
i 1
a (list (- r) 0 0)
b (list 0 r 0)
c (list r 0 0)
d (list 0 (- r) 0)
rs (* 10 (max r l1)))
(repeat segs
(setq
m (* r (cos (* i f1)))
n (* r (sin (* i f1)))
a1 (list (- m) n (* i l1))
b1 (list n m (* i l1))
c1 (list m (- n) (* i l1))
d1 (list (- n) (- m) (* i l1))
i (1+ i))
(command "_.sphere" b rs)
(command "_.zoom" "e")
(command "_.slice" "l" "" a b b1 c)
(command "_.slice" "l" "" a a1 b1 c)
(command "_.slice" "l" "" b c c1 d)
(command "_.slice" "l" "" b b1 c1 d)
(command "_.slice" "l" "" a a1 d c)
(command "_.slice" "l" "" d d1 a1 c)
(command "_.slice" "l" "" d d1 c a)
(command "_.slice" "l" "" c c1 d1 a)
(command "_.slice" "l" "" a b c c1)
(command "_.slice" "l" "" a1 b1 c1 a)
(setq a a1 b b1 c c1 d d1))
(princ "\n PLEASE WAIT!")
(command "_.union" "all" "")
(command "_.zoom" "e")
(setvar "osmode" oldsnap)
(setq a " thank you!")
)
I have no possibility to test the routine under AutoCAD R14, but with 2000 it is OK!
CADTutor
17th Jan 2003, 06:49 pm
Fuccaro - trust you to come up with a twister lisp. Problem is, I couldn't get it to work but I think it's because I didn't quite understand how it works. Could you add a quick step-by-step for us?
Mr T
17th Jan 2003, 08:13 pm
Fuccaro, :shock: :D :shock: :D
You must get into producing more and creating plugins, for cash !
Do you write these for customers ? if not why not ? :?: :?:
You are
- Monsieur '3D LISP'
Nick :lol:
fuccaro
18th Jan 2003, 06:53 am
CadTUTOR
I don't knov, what the problem is? Dangermouse just sent me a private message, he says that is worked just fine (right, Dangermouse?). I don’t will tell YOU phrases like “copy-paste the program lines in your Notepad.....”. So the problem is ...”Out there”.
I think the routine passed the test on Mr T’s computer too.
Mr T
I wrote this routine specially for Dangermouse, I worked on about 1 hour. It is not really finished; the elegance is missing from. In my opinion, all lisp routines in the World should be for free. But if you wish, feel free to send me 0.1USD (sorry, I forgot my address). Thanks for your appreciation.
dangermouse
18th Jan 2003, 10:45 pm
YES INDEED THE PRG WORKS PERFECTLY WELL ON MY AUTOCAD R14 :lol:
CADTutor
20th Jan 2003, 10:35 am
Well, it also works for me now. Expect a minor bug fix from Fuccaro soon.
http://www.cadimage.net/cadtutor/twister.gif
fuccaro
20th Jan 2003, 01:47 pm
The routine I sent earlier is functionally, if OSNAP is off.
There are two bugs to fix:
1. The OSNAP must be turned off and restored automatically at the end of the program.
2. Is useless to prompt the user about the untwisted length, as long as the routine draws just the twisted part.
Please don’t cut my head! When I write a routine, I use to save the different intermediary versions. At first I wrote the program to draw the solid as Dangermouse asked, with two untwisted ends. Than I deleted program lines, are keep just those to generate the twisted area, trying to make the routine with a bit of generality.
From a mistake, I sent an earlier version but the finished one.
I was asked what the “segments” prompt means?
The edges are curves, but they are approximated by line segments. At this prompt is expected you enter the number of segments to approximate the curve along of the twisted area.
Thank You CADTutor for the feed back and for the help.
Mr T, I am glad I wrote this program for free –now you can not ask the 0.1 USD back!
I am so sorry for your inconvenience. I post here the whole (corrected) program again.
(defun C:twister()
(setq r (getreal "\n define the square:radius of circumscribed circle? <15> "))
(if (= r nil) (setq r 15))
(setq l (getreal "\n length of twisted area? <150>"))
(if (= l nil) (setq l 150))
(setq f (getreal "\n rotation angle? <90> "))
(if (= f nil) (setq f 90))
(setq segs (getint "\n segments? <100> "))
(if (= segs nil) (setq segs 100))
(setq oldsnap (getvar "osmode"))
(setvar "cmdecho" 0)
(setvar "osmode" 0)
(setq f1 (/ (* PI f) segs -180.0)
l1 (/ l segs)
i 1
a (list (- r) 0 0)
b (list 0 r 0)
c (list r 0 0)
d (list 0 (- r) 0)
rs (* 10 (max r l1)))
(repeat segs
(setq m (* r (cos (* i f1)))
n (* r (sin (* i f1)))
a1 (list (- m) n (* i l1))
b1 (list n m (* i l1))
c1 (list m (- n) (* i l1))
d1 (list (- n) (- m) (* i l1))
i (1+ i))
(command "_.sphere" b rs)
(command "_.zoom" "e")
(command "_.slice" "l" "" a b b1 c)
(command "_.slice" "l" "" a a1 b1 c)
(command "_.slice" "l" "" b c c1 d)
(command "_.slice" "l" "" b b1 c1 d)
(command "_.slice" "l" "" a a1 d c)
(command "_.slice" "l" "" d d1 a1 c)
(command "_.slice" "l" "" d d1 c a)
(command "_.slice" "l" "" c c1 d1 a)
(command "_.slice" "l" "" a b c c1)
(command "_.slice" "l" "" a1 b1 c1 a)
(setq a a1 b b1 c c1 d d1))
(princ "\n PLEASE WAIT!")
(command "_.union" "all" "")
(command "_.zoom" "e")
(setvar "osmode" oldsnap)
(setq a " thank you!")
)
CADTutor
20th Jan 2003, 03:07 pm
Hey, fuccaro - don't apologise. This is a great service and I'm sure everyone round here really appreciates your efforts :!:
fuccaro
22nd Jan 2003, 09:45 pm
Here is an other way to do the job.
Draw a helix with the center in (0,0,0). Multiply it using the ARRAY command
Polar array
center point: 0,0
number of items:2
angle to fill 90
Rotate YES
Draw a line from the first point of one helix to the first point of the other helix. And an other line between the endpoints. Set the SURFTAB1 and SURFTAB2 to higher values (20?). Use the EDGESURF command to draw a surface. When AutoCAD prompts you, pick the first helix, a line, the second helix and finally the second line. Probably you have a twisted surface on your screen. Use the ARRAY again to multiply this surface;
Polar array
center point: 0,0
number of items:4
angle to fill 360
Rotate YES
You have a surface, not a solid, but depending on your needs, it could be enough.
http://www.cadimage.net/fuccaro/twist.jpg(if the image is not here, you may visit my web site http://fuccaro.netfirms.com)
CADTutor
22nd Jan 2003, 10:06 pm
Now that is a really nice technique and the result is stunning - very smooth. 8) Of course, what fuccaro didn't mention is that you'll need to use his excellent LISP routine to draw the helix.
Mr T
23rd Jan 2003, 12:24 am
No lisps, just 2D knowledge. :lol: :lol:
RULESURF.
Nick
http://www.eezylearn.pwp.blueyonder.co.uk/images/rulesurf.jpg
fuccaro
23rd Jan 2003, 06:45 am
Yes!
Mr T, you are the solid-surface modeling master. It is nice to combine different modeling methods and obtain the best result!
Of course, what fuccaro didn't mention is that you'll need to use his excellent LISP routine
Thei are a lot of lisp routines ower the Net (and in other places). I am sure it will work with other helix routines too. But after Mr T wrote showing us The Way, who care any more about helix routine?
gcp310
23rd Jan 2003, 07:03 am
Well, i was pretty impressed with the lisp myself,even if you can do that with rulesurf,or whatever.
Nice routine, I have seen some pretty good routines, but yours was surely
entertaining to watch.
G
fuccaro
23rd Jan 2003, 11:42 am
For those of you who asked –and for those of you who did not, but you want to know- I will explain using just few words how the twister routine works.
The first part is dedicated to enter the date, the only unusually things are the lines like
(if (= ... nil) (setq ...]
I used this for preset the implicit value, in the same manner als AutoCAD works.
The solid is divided in SEG litle pieces. Every piece is draw separately by generating a huge, oversized sphere, than slicing it as is needed. The points defining the slice plane are calculated with a formula. The new point is resulted from the previous by a rotation around Oz and a translation “up” along the same axis. After a piece is generated, the new generated points are used to calculate an other set of point, and so on. After all the pieces are finished, is called the AutoCAD command
(command "_.union" "all" "")
Now all the solids contained in the current drawing are forming a single one. This is the reason why the drawing may not contain other 3d objects. Maybe in a future version I will correct this.
Is it my explanation clear enough?
Thank you G for your comments
Mr T
23rd Jan 2003, 11:08 pm
Yes!, Mr T, you are the solid-surface modeling master. It is nice to combine different modeling methods and obtain the best result! .Of course, what fuccaro didn't mention is that you'll need to use his excellent LISP routine
Actually it is just a rulesurf and two polygons. I was trying to show users, mainly non-experts (not you) how a surface between 2D objects, can create very varied effects, in less than 15 secs.
Please keep up the cool lisps.
Personally I can't teach with them coz the kids have to learn and create objects from first principles rather than use tools such as lisp.
Cheers
Nick
Powered by vBulletin™ Version 4.1.2 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.