/* This Cadl has a Dialog Box interface, so it will not work in Cadkey97.... The Cadl will generate points in a user specified helical dir__ion, which can be drawn onto the screen after picking a position in Cadkey, or the points can be saved to a Cadl file; which in turn can be executed through Solids98 or Fastsurf98 via "Spline from Copious Data in a File". The check marks in that utility should be set as follows: Show as Splines Ignore Integers Delta X,Y, or Z (Set to None) File's will be saved to the CDL path. User will be able to type in a file name. The ".CDL" extension will be added automatically. The point attributes e.g. color, level etc. will be equal to the current system settings. CADL file name: 'POINTGEN.CDX' ..... March, 1999 Gratitude: To GOD and my Family Written by Hans Winkler and Brian Ott; */ SLIST $$rad0[0][0], $$rad1[0][0] double b__rad, l__gth, p__itch, t__urns, t__aper, hel__ang int pts__rev, r__button, dir__ion oldcview = @cview set cview, 1 $n__ame = "" :START fileopen = 0 if (b__rad == 0) b__rad = 1 if (l__gth == 0) l__gth = 1 if (p__itch == 0) p__itch = 1 if (t__urns == 0) t__urns = 1 if (pts__rev == 0) pts__rev = 12 if (hel__ang == 0) hel__ang = 1 $$rad0[0] = "Length and Pitch" $$rad0[1] = "Length and Turns" $$rad0[2] = "Pitch and Turns" $$rad0[3] = "HelixAng and Turns" $$rad1[0] = "Counterclockwise" $$rad1[1] = "Clockwise" DG_RET_ON_SEL = 0x00000001 DG_CANCEL = 0x00000008 DG_DEFAULT = 0x00002000 DG_FROZEN = 0x00000002 dg_init_dialog 22, 50, 27,\ " <<< Point Generator for straight or tapered helical Spline >>>", 0, 0, 4, 0 db = @ERROR dg_add_radio db, 0, 1.65, 1.75, r__button, 4, $$rad0, 0, 0, DG_RET_ON_SEL dg_add_radio db, 1, 1.50, 29.00, dir__ion, 2, $$rad1, 0, 0, 0 dg_add_note db, 2, 9.50, 1.75, "Base Rad", 0, 0, 0 dg_add_note db, 3, 11.25, 1.75, "Length", 0, 0, 0 dg_add_note db, 4, 13.00, 1.75, "Pitch/Rev", 0, 0, 0 dg_add_note db, 5, 14.75, 1.75, "Turns", 0, 0, 0 dg_add_note db, 6, 16.50, 1.75, "Taper", 0, 0, 0 dg_add_text_double db, 7, 9.25, 11.75, 10, "%.14f", b__rad, 0, 0, 0 dg_add_text_double db, 8, 11.00, 11.75, 10, "%.14f", l__gth, 0, 0, 0 dg_add_text_double db, 9, 12.75, 11.75, 10, "%.14f", p__itch, 0, 0, 0 dg_add_text_double db, 10, 14.50, 11.75, 10, "%.14f", t__urns, 0, 0, 0 dg_add_text_double db, 11, 16.25, 11.75, 10, "%.14f", t__aper, 0, 0, 0 dg_add_box db, 12, 7.50, 26.75, 5.00, 22.00, "Output to File", 0, 0, 0 dg_add_button db, 13, 9.00, 31.00, 14, "Save to File", 0, 0, 0 dg_add_text_string db, 14, 11.00, 31.25, 8, "%s", $n__ame, 0, 0, 0 dg_add_note db, 15, 11.25, 40.00, ".CDL", 0, 0, 0 dg_add_button db, 16, 15.00, 33.00, 10, "Position", 0, 0, 0 dg_add_button db, 17, 19.25, 34.00, 8, "Close", 0, 0, DG_CANCEL dg_add_box db, 18, 0.50, 26.75, 3.50, 22.00, "Sweep direction", 0, 0, 0 dg_add_box db, 19, 0.50, 0.50, 6.00, 22.00, "Input Parameters", 0, 0, 0 dg_add_box db, 20, 7.50, 0.50, 13.50, 22.00, "Input Values", 0, 0, 0 dg_add_box db, 21, 13.50, 26.75, 3.25, 22.00, "Output to Cadkey", 0, 0, 0 dg_add_note db, 22, 20.00, 1.75, "Pts/Rev", 0, 0, 0 dg_add_text_int db, 23, 19.75, 11.75, 3, "%d", pts__rev, 0, 0, 0 dg_add_note db, 24, 18.25, 1.75, "Helix Ang", 0, 0, 0 dg_add_text_double db, 25, 18.00, 11.75, 10, "%.14f", hel__ang, 0, 0, 0 dg_add_box db, 26, 17.75, 26.75, 3.25, 22.00, "Close Program", 0, 0, 0 if (r__button == 0){ dg_set_flags db, 10, DG_FROZEN, 1 dg_set_flags db, 25, DG_FROZEN, 1 } if (r__button == 1){ dg_set_flags db, 9, DG_FROZEN, 1 dg_set_flags db, 25, DG_FROZEN, 1 } if (r__button == 2){ dg_set_flags db, 8, DG_FROZEN, 1 dg_set_flags db, 25, DG_FROZEN, 1 } if (r__button == 3){ dg_set_flags db, 8, DG_FROZEN, 1 dg_set_flags db, 9, DG_FROZEN, 1 } prompt "Please make a selection...." dg_draw_dialog db :DIALOG dg_run_dialog db /* Radio button for Length and Pitch pressed */ if (@error == 0) goto RADIO1 /* Save to File button pressed */ if (@error == 13) goto CHECKFILE /* Position in Cadkey button pressed */ if (@error == 16) goto CALCULATE /* Close button pressed */ if (@error == 17){ dg_erase_dialog db dg_free_dialog db goto EXIT } :CHECKFILE dg_get_text_string db, 14 sprint $n__ame, @strdat call strlen,$n__ame,q if (($n__ame[0] == 0)||($n__ame[0] == 32)){ pause "NO Filename or INVALID Filename...Press ESC or F10 to continiue..." prompt "Please make a selection...." goto DIALOG } sprint $open, "%s%s%s", @cdlpath, $n__ame, ".cdl" set devin, $open if (@error == 0){ close devin goto WARNING } :NEWFILE set devout, $open if (@error != 0) goto EXIT fileopen = 1 goto CALCULATE /*must add to end of program "close devout" */ :WARNING dg_child_dialog db, 5, 26, 0, 0, 3, " <<>>", 0, 0, 0 msg = @ERROR dg_add_note msg, 0, 0.5, 0.5, " OVERWRITE existing File?", 0, 0, 0 dg_add_button msg, 1, 3.0, 16.0, 5, "NO", 0, 0, DG_DEFAULT dg_add_button msg, 2, 3.0, 6.0, 5, "YES", 0, 0, 0 dg_draw_dialog msg dg_run_dialog msg if (@error == 1){ dg_erase_dialog msg dg_free_dialog msg goto DIALOG } if (@error == 2){ dg_erase_dialog msg dg_free_dialog msg goto NEWFILE } :RADIO1 dg_get_radio db, 0 if (@error == 0){ dg_set_flags db, 7, DG_FROZEN, 0 dg_set_flags db, 8, DG_FROZEN, 0 dg_set_flags db, 9, DG_FROZEN, 0 dg_set_flags db, 10, DG_FROZEN, 1 dg_set_flags db, 11, DG_FROZEN, 0 dg_set_flags db, 25, DG_FROZEN, 1 } if (@error == 1){ dg_set_flags db, 7, DG_FROZEN, 0 dg_set_flags db, 8, DG_FROZEN, 0 dg_set_flags db, 9, DG_FROZEN, 1 dg_set_flags db, 10, DG_FROZEN, 0 dg_set_flags db, 11, DG_FROZEN, 0 dg_set_flags db, 25, DG_FROZEN, 1 } if (@error == 2){ dg_set_flags db, 7, DG_FROZEN, 0 dg_set_flags db, 8, DG_FROZEN, 1 dg_set_flags db, 9, DG_FROZEN, 0 dg_set_flags db, 10, DG_FROZEN, 0 dg_set_flags db, 11, DG_FROZEN, 0 dg_set_flags db, 25, DG_FROZEN, 1 } if (@error == 3){ dg_set_flags db, 7, DG_FROZEN, 0 dg_set_flags db, 8, DG_FROZEN, 1 dg_set_flags db, 9, DG_FROZEN, 1 dg_set_flags db, 10, DG_FROZEN, 0 dg_set_flags db, 11, DG_FROZEN, 0 dg_set_flags db, 25, DG_FROZEN, 0 } goto DIALOG :CALCULATE /* Get Values */ dg_get_radio db, 1 /* dir__ion 0 means Counterclockwise */ if (@error == 0) dir__ion = 0 /* dir__ion 1 means Clockwise */ if (@error == 1) dir__ion = 1 dg_get_radio db, 0 r__button = @error if (r__button == 0){ dg_get_text_double db, 7 b__rad = @error dg_get_text_double db, 8 l__gth = @error dg_get_text_double db, 9 p__itch = @error if ((p__itch <= 0)||(l__gth <=0)){ pause "Pitch and Length must be greater than Zero...Press ESC or F10..." prompt "Please make a selection...." goto DIALOG } dg_get_text_double db, 11 t__aper = @error } if (r__button == 1){ dg_get_text_double db, 7 b__rad = @error dg_get_text_double db, 8 l__gth = @error dg_get_text_double db, 10 t__urns = @error if ((l__gth <= 0)||(t__urns <= 0)){ pause "Length and Turns must be greater than Zero...Press ESC or F10..." prompt "Please make a selection...." goto DIALOG } dg_get_text_double db, 11 t__aper = @error } if (r__button == 2){ dg_get_text_double db, 7 b__rad = @error dg_get_text_double db, 9 p__itch = @error dg_get_text_double db, 10 t__urns = @error if ((p__itch <= 0)||(t__urns <=0)){ pause "Pitch and Turns must be greater than Zero...Press ESC or F10..." prompt "Please make a selection...." goto DIALOG } dg_get_text_double db, 11 t__aper = @error } if (r__button == 3){ dg_get_text_double db, 7 b__rad = @error dg_get_text_double db, 10 t__urns = @error dg_get_text_double db, 11 t__aper = @error dg_get_text_double db, 25 hel__ang = @error if ((hel__ang <= 0)||(hel__ang >= 90)){ pause "Helix angle must be > than 0° and < than 90°...Press ESC or F10..." prompt "Please make a selection...." goto DIALOG } } dg_get_text_int db, 23 pts__rev = @error if ((pts__rev <= 0)||(pts__rev > 360)){ pause "Points/Revolution: Minimum 1, Maximum 360...Press ESC or F10..." prompt "Please make a selection...." goto DIALOG } oldptsrev = pts__rev pts__rev = 360/pts__rev dg_erase_dialog db dg_free_dialog db :GETPOSITION SPRINT $p__note, "Indicate the Location of the Base Radius or press for x=0, y=0, z=0...." GETPOS $p__note, 4 if ((@key == -3)||(@key == -2)) goto EXIT if (@key == -1){ x__pos = 0 y__pos = 0 z__pos = 0 goto NECT } x__pos = @xworld y__pos = @yworld z__pos = @zworld :NECT if (fileopen == 0) circle x__pos, y__pos, z__pos, b__rad,,,,3,,,,1 if (r__button == 0) goto L&P if (r__button == 1) goto L&T if (r__button == 2) goto P&T if (r__button == 3) goto HA&T :L&P /* Calculation for Length & Pitch */ startang = 0 z__zz = 0 :LOOP1 npnt=-(b__rad-(tan(t__aper)*z__zz)) if (dir__ion == 1){ x__d=(npnt*sin(-startang))+x__pos y__d=(npnt*cos(-startang))+y__pos goto CW1 } x__d=(npnt*sin(startang))+x__pos y__d=(npnt*cos(startang))+y__pos :CW1 z__zz=((p__itch/360)*startang) z__d = z__zz + z__pos if (fileopen == 1){ print "%s %.10f, %.10f, %.10f\n", "Point", x__d, y__d, z__d goto NOCAD1 } POINT x__d,y__d,z__d :NOCAD1 startang=startang+pts__rev if (z__d < (z__pos + l__gth)) goto LOOP1 pts__rev = oldptsrev if (fileopen == 1){ close devout goto START } goto EXIT /* Calculation for Length & Pitch */ :L&T /* Start Calculation for Length & Turns */ startang = 0 oldturns = t__urns t__urns = (t__urns * 360) z__zz = 0 :LOOP2 npnt=-(b__rad-(tan(t__aper)*z__zz)) if (dir__ion == 1){ x__d=(npnt*sin(-startang))+x__pos y__d=(npnt*cos(-startang))+y__pos goto CW2 } x__d=(npnt*sin(startang))+x__pos y__d=(npnt*cos(startang))+y__pos :CW2 z__zz=((l__gth/t__urns)*startang) z__d = z__zz + z__pos if (fileopen == 1){ print "%s %.10f, %.10f, %.10f\n", "Point", x__d, y__d, z__d goto NOCAD2 } POINT x__d,y__d,z__d :NOCAD2 startang=startang+pts__rev if (startang < (z__pos + t__urns)) goto LOOP2 t__urns = oldturns pts__rev = oldptsrev if (fileopen == 1){ close devout goto START } goto EXIT /* End Calculation for Length & Turns */ :P&T /* Start Calculation for Pitch & Turns */ startang = 0 oldturns = t__urns t__urns = t__urns * p__itch z__zz = 0 :LOOP3 npnt=-(b__rad-(tan(t__aper)*z__zz)) if (dir__ion == 1){ x__d=(npnt*sin(-startang))+x__pos y__d=(npnt*cos(-startang))+y__pos goto CW3 } x__d=(npnt*sin(startang))+x__pos y__d=(npnt*cos(startang))+y__pos :CW3 z__zz=((p__itch/360)*startang) z__d = z__zz + z__pos if (fileopen == 1){ print "%s %.10f, %.10f, %.10f\n", "Point", x__d, y__d, z__d goto NOCAD3 } POINT x__d,y__d,z__d :NOCAD3 startang=startang+pts__rev if (z__d < (z__pos + t__urns)) goto LOOP3 t__urns = oldturns pts__rev = oldptsrev if (fileopen == 1){ close devout goto START } goto EXIT /* End Calculation for Pitch & Turns */ :HA&T /* Start Calculation for Helix Angle & Turns */ startang = 0 oldturns = t__urns pitchhelix = ((b__rad*3.14159265358979*360)/180)*tan(hel__ang) t__urns = t__urns * pitchhelix z__zz = 0 :LOOP4 npnt=-(b__rad-(tan(t__aper)*z__zz)) if (dir__ion == 1){ x__d=(npnt*sin(-startang))+x__pos y__d=(npnt*cos(-startang))+y__pos goto CW4 } x__d=(npnt*sin(startang))+x__pos y__d=(npnt*cos(startang))+y__pos :CW4 z__zz=((pitchhelix/360)*startang) z__d = z__zz + z__pos if (fileopen == 1){ print "%s %.10f, %.10f, %.10f\n", "Point", x__d, y__d, z__d goto NOCAD4 } POINT x__d,y__d,z__d :NOCAD4 startang=startang+pts__rev if (z__d < z__pos + t__urns) goto LOOP4 t__urns = oldturns pts__rev = oldptsrev if (fileopen == 1){ close devout goto START } goto EXIT /* End Calculation for Helix Angle & Turns */ :EXIT set cview, oldcview clear $$rad0,$$rad1,fileopen,DG_RET_ON_SEL,DG_CANCEL,DG_DEFAULT,DG_FROZEN,\ db,$n__ame,q,$open,msg,x__pos,y__pos,z__pos,startang,z__d,npnt,x__d,y__d,\ oldturns,oldcview,$p__note,z__zz