PDA

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

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...

&#40;defun C&#58;twister&#40;&#41;

&#40;setq r &#40;getreal "\n define the square&#58;radius of circumscribed circle? <15> "&#41;&#41;
&#40;if &#40;= r nil&#41; &#40;setq r 15&#41;&#41;
&#40;setq l &#40;getreal "\n length of twisted area? <150>"&#41;&#41;
&#40;if &#40;= l nil&#41; &#40;setq l 150&#41;&#41;
&#40;setq f &#40;getreal "\n rotation angle? <90> "&#41;&#41;
&#40;if &#40;= f nil&#41; &#40;setq f 90&#41;&#41;
&#40;setq segs &#40;getint "\n segments? <100> "&#41;&#41;
&#40;if &#40;= segs nil&#41; &#40;setq segs 100&#41;&#41;
&#40;setq oldsnap &#40;getvar "osmode"&#41;&#41;
&#40;setq lu &#40;getreal "lenght of untwisted area? <50>"&#41;&#41;
&#40;if &#40;= lu nil&#41; &#40;setq lu 50&#41;&#41;
&#40;setvar "cmdecho" 0&#41;

&#40;setq f1 &#40;/ &#40;* PI f&#41; segs -180.0&#41;
l1 &#40;/ l segs&#41;
i 1
a &#40;list &#40;- r&#41; 0 0&#41;
b &#40;list 0 r 0&#41;
c &#40;list r 0 0&#41;
d &#40;list 0 &#40;- r&#41; 0&#41;
rs &#40;* 10 &#40;max r l1&#41;&#41;&#41;
&#40;repeat segs
&#40;setq
m &#40;* r &#40;cos &#40;* i f1&#41;&#41;&#41;
n &#40;* r &#40;sin &#40;* i f1&#41;&#41;&#41;
a1 &#40;list &#40;- m&#41; n &#40;* i l1&#41;&#41;
b1 &#40;list n m &#40;* i l1&#41;&#41;
c1 &#40;list m &#40;- n&#41; &#40;* i l1&#41;&#41;
d1 &#40;list &#40;- n&#41; &#40;- m&#41; &#40;* i l1&#41;&#41;
i &#40;1+ i&#41;&#41;
&#40;command "_.sphere" b rs&#41;
&#40;command "_.zoom" "e"&#41;
&#40;command "_.slice" "l" "" a b b1 c&#41;
&#40;command "_.slice" "l" "" a a1 b1 c&#41;
&#40;command "_.slice" "l" "" b c c1 d&#41;
&#40;command "_.slice" "l" "" b b1 c1 d&#41;
&#40;command "_.slice" "l" "" a a1 d c&#41;
&#40;command "_.slice" "l" "" d d1 a1 c&#41;
&#40;command "_.slice" "l" "" d d1 c a&#41;
&#40;command "_.slice" "l" "" c c1 d1 a&#41;
&#40;command "_.slice" "l" "" a b c c1&#41;
&#40;command "_.slice" "l" "" a1 b1 c1 a&#41;
&#40;setq a a1 b b1 c c1 d d1&#41;&#41;
&#40;command "_.union" "all" ""&#41;
&#40;command "_.zoom" "e"&#41;
&#40;setvar "osmode" oldsnap&#41;
&#40;setq a " thank you!"&#41;
&#41;
I have no possibility to test the routine under AutoCAD R14, but with 2000 it is OK!

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
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:

20th Jan 2003, 10:35 am
Well, it also works for me now. Expect a minor bug fix from Fuccaro soon.

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.
I am so sorry for your inconvenience. I post here the whole (corrected) program again.

&#40;defun C&#58;twister&#40;&#41;

&#40;setq r &#40;getreal "\n define the square&#58;radius of circumscribed circle? <15> "&#41;&#41;
&#40;if &#40;= r nil&#41; &#40;setq r 15&#41;&#41;
&#40;setq l &#40;getreal "\n length of twisted area? <150>"&#41;&#41;
&#40;if &#40;= l nil&#41; &#40;setq l 150&#41;&#41;
&#40;setq f &#40;getreal "\n rotation angle? <90> "&#41;&#41;
&#40;if &#40;= f nil&#41; &#40;setq f 90&#41;&#41;
&#40;setq segs &#40;getint "\n segments? <100> "&#41;&#41;
&#40;if &#40;= segs nil&#41; &#40;setq segs 100&#41;&#41;
&#40;setq oldsnap &#40;getvar "osmode"&#41;&#41;
&#40;setvar "cmdecho" 0&#41;
&#40;setvar "osmode" 0&#41;

&#40;setq f1 &#40;/ &#40;* PI f&#41; segs -180.0&#41;
l1 &#40;/ l segs&#41;
i 1
a &#40;list &#40;- r&#41; 0 0&#41;
b &#40;list 0 r 0&#41;
c &#40;list r 0 0&#41;
d &#40;list 0 &#40;- r&#41; 0&#41;
rs &#40;* 10 &#40;max r l1&#41;&#41;&#41;
&#40;repeat segs
&#40;setq m &#40;* r &#40;cos &#40;* i f1&#41;&#41;&#41;
n &#40;* r &#40;sin &#40;* i f1&#41;&#41;&#41;
a1 &#40;list &#40;- m&#41; n &#40;* i l1&#41;&#41;
b1 &#40;list n m &#40;* i l1&#41;&#41;
c1 &#40;list m &#40;- n&#41; &#40;* i l1&#41;&#41;
d1 &#40;list &#40;- n&#41; &#40;- m&#41; &#40;* i l1&#41;&#41;
i &#40;1+ i&#41;&#41;
&#40;command "_.sphere" b rs&#41;
&#40;command "_.zoom" "e"&#41;
&#40;command "_.slice" "l" "" a b b1 c&#41;
&#40;command "_.slice" "l" "" a a1 b1 c&#41;
&#40;command "_.slice" "l" "" b c c1 d&#41;
&#40;command "_.slice" "l" "" b b1 c1 d&#41;
&#40;command "_.slice" "l" "" a a1 d c&#41;
&#40;command "_.slice" "l" "" d d1 a1 c&#41;
&#40;command "_.slice" "l" "" d d1 c a&#41;
&#40;command "_.slice" "l" "" c c1 d1 a&#41;
&#40;command "_.slice" "l" "" a b c c1&#41;
&#40;command "_.slice" "l" "" a1 b1 c1 a&#41;
&#40;setq a a1 b b1 c c1 d d1&#41;&#41;
&#40;command "_.union" "all" ""&#41;
&#40;command "_.zoom" "e"&#41;
&#40;setvar "osmode" oldsnap&#41;
&#40;setq a " thank you!"&#41;
&#41;

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)

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?

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