REM | ORTHO.CDL REM | by Thomas P Groff Jan 15,1999 REM | Task: Create orthagonally a string of lines dynamically in 2 or 3 REM | dimensions. REM | Features: REM | 1. Key in a Line length. REM | 2. Pick a line length via the cursor position. REM | 3. Capture a line length from an existing line. REM | 4. Add and Subtract captured line lengths for a new line length. REM | 5. Capture the actual distance between two points. REM | 6. Dynamically draw a line in any of the six orthographic REM | directions by simply pointing with the cursor. REM | optionally keyin an angle other than orthographic. REM | 7. User Select a new line endpoint. REM | 8. Draw a line endpoint to endpoint. (As per Cadkey) REM | 9. Draw a line parallel thru a point. (Ortho only.) REM | Limitations: REM | 1. VIEW MUST BE SET ON OR VERY NEAR VIEW 7 (ISO VIEW) REM | AND CPLANE MUST BE SET TO VIEW 1 (TOP VIEW) REM | FOR THE DYNAMIC Z DEPTH SELECTION TO WORK. set cview, 1 opt = 1 length = 2 :L0 GETPOS "Select line start point",opt on (@key+3) goto ESC,ESC,L0,,,,,,,,, opt = @key a = @xcview b = @ycview c = @zcview set depth, c :L1 getflt "Enter line length => ",length,length,\ "Cursor","GetLen","AddSub","GetDist","ToPos","Pt-Pt","ThruPt","Undo" on (@key+3) goto ESC,L0,L1,L2,\ GETCURSOR,GETCLONE,ADDSUB,GETMEASURE,GETPOSIT,PT_PT,THRUPT,UNDOLINE :UNDOLINE a = r b = s c = t delent lstr_id goto L1 :ADDSUB totallen = 0 :ADDSUB1 sprint $TOTALLEN,"Select an Option (Total = %f)",totallen getmenu $TOTALLEN,"Add","Sub","Clear","Done" on (@key+3) goto ESC,L1,ADDSUB1,ESC,ADDLEN,SUBLEN,ADDSUB,ADDSUBDONE :ADDLEN sprint $TOTALLEN,"Select Line to add (Total = %f)",totallen set mask, 2 getent $TOTALLEN,ent set mask on (@key+3) goto ESC,ADDSUB1,ADDLEN,,,,,,,,,,,,,,,, addtotal = hypot(abs(@fltdat[0]-@fltdat[3]),abs(@fltdat[1]-@fltdat[4])) addtotal = hypot(addtotal,abs(@fltdat[2]-@fltdat[5])) totallen = totallen + addtotal goto ADDSUB1 :SUBLEN sprint $TOTALLEN,"Select Line to subtract (Total = %f)",totallen set mask,2 getent $TOTALLEN,ent set mask on (@key+3) goto ESC,ADDSUB1,SUBLEN,,,,,,,,,,,,,,,, subtotal = hypot(abs(@fltdat[0]-@fltdat[3]),abs(@fltdat[1]-@fltdat[4])) subtotal = hypot(subtotal,abs(@fltdat[2]-@fltdat[5])) totallen = totallen - subtotal goto ADDSUB1 :ADDSUBDONE length = totallen goto L2 :THRUPT set mask,2 getent "Select Base line",ent set mask on (@key+3) goto L0,L1,THRUPT,,,,,,,,,,,,,,,,,,,,, wx1 = @fltdat[0] wy1 = @fltdat[1] wz1 = @fltdat[2] wx2 = @fltdat[3] wy2 = @fltdat[4] wz2 = @fltdat[5] :THRUPOS getpos "Select Position for Parallel line",3 on (@key+3) goto ESC,THRUPT,,,,,,,,,,,,,,,,,,,, wx = @xworld wy = @yworld wz = @zworld if ((abs(wz1-wz2)<.000000000001)&&(abs(wy1-wy2)<.000000000001)) goto XLINE if ((abs(wz1-wz2)<.000000000001)&&(abs(wx1-wx2)<.000000000001)) goto YLINE if ((abs(wx1-wx2)<.000000000001)&&(abs(wy1-wy2)<.000000000001)) goto ZLINE goto THRUPT :XLINE line wx1,wy,wz,wx2,wy,wz goto THRUPOS :YLINE line wx,wy1,wz,wx,wy2,wz goto THRUPOS :ZLINE line wx,wy,wz1,wx,wy,wz2 goto THRUPOS :PT_PT getpos "Select 1st endpoint",3 on (@key+3) goto ESC,L1,PT_PT,,,,,,,,,,,,,,,,, mx1 = @xcview my1 = @ycview mz1 = @zcview :PT_PT2 getpos "Select 2nd endpoint",3 on (@key+3) goto ESC,PT_PT,PT_PT2,,,,,,,,,,,,,,, mx2 = @xcview my2 = @ycview mz2 = @zcview line mx1,my1,mz1,mx2,my2,mz2 length = hypot(abs(mx1-mx2),abs(my1-my2)) length = hypot(length,abs(mz1-mz2)) goto PT_PT :LINEUP x = a y = b z = c + length goto CREATE :LINEDOWN x = a y = b z = c - length goto CREATE :GETPOSIT getpos "Select line endpoint",3 on (@key+3) goto ESC,L1,GETPOSIT,,,,,,,,,,,,,,,,, x = @xcview y = @ycview z = @zcview length = hypot(abs(x-a),abs(y-b)) length = hypot(length,abs(z-c)) goto CREATE :GETMEASURE getpos "Select FIRST position",3 on (@key+3) goto ESC,L1,GETMEASURE,,,,,,,,,,,,,,,,, mx1 = @xcview my1 = @ycview mz1 = @zcview :GETMEASURE2 getpos "Select SECOND position",3 on (@key+3) goto ESC,GETMEASURE,GETMEASURE2,,,,,,,,,,,,,,,, mx2 = @xcview my2 = @ycview mz2 = @zcview length = hypot(abs(mx1-mx2),abs(my1-my2)) length = hypot(length,abs(mz1-mz2)) goto L2 :GETCURSOR length = 0 goto L2 :GETCLONE set mask,2 getent "Select line to get length from",ent set mask on (@key+3) goto ESC,L1,GETCLONE,,,,,,,,,,,,,,,, length = hypot(abs(@fltdat[0]-@fltdat[3]),abs(@fltdat[1]-@fltdat[4])) length = hypot(length,abs(@fltdat[2]-@fltdat[5])) goto L2 :L2 array cv[9] getview @cview, cv call xfmvw, cv, a,b,c, wa,wb,wc opt = 3 getcur "Select line direction (or press for angle)",3,1,wa,wb,wc on (@key+3) goto ESC,L1,GETANG,,,,,,,,,,,,,,, x = @xcview y = @ycview z = @zcview set depth, z call atan3, (y - b),(x - a),r ang = r/.017453293 if (length == 0) goto CURSORLEN :M0 x = a y = b z = c if (@view < 7) goto SKIP3D if (@view == 8) goto SKIP3D if (@cview!=1) goto SKIP3D if ((ang > 120)&&(ang<150)) goto LINEUP if ((ang > 300)&&(ang<330)) goto LINEDOWN :SKIP3D if (ang < 45) x = x + length if ((ang >= 45)&&(ang < 135)) y = y + length if ((ang >= 135)&&(ang < 225)) x = x - length if ((ang >= 225)&&(ang < 315)) y = y - length if (ang >= 315) x = x + length goto CREATE :CURSORLEN if (ang < 45) length = abs(x-a) if ((ang >= 45)&&(ang < 135)) length = abs(y-b) if ((ang >= 135)&&(ang < 225)) length = abs(x-a) if ((ang >= 225)&&(ang < 315)) length = abs(y-b) if (ang >= 315) length = abs(x-a) goto M0 :GETANG if (length == 0) goto L2 getflt "Enter polar angle => ",45,angle on (@key+3) goto ESC,L1,,,,,,,,,,,,, angle = -(angle - 90) x = a+(sin(angle)*length) y = b+(cos(angle)*length) z = @zcview :CREATE vline a,b,c, x,y,z lstr_id = @lastid r = a s = b t = c a = x b = y c = z set depth, z goto L1 :ESC clear