home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
AmigActive 13
/
AACD13.ISO
/
AACD
/
Information
/
WebSites
/
Imagine
/
arexx
/
screwt.lzx
/
ScrewThread.irx
Wrap
Text File
|
1998-10-01
|
9KB
|
414 lines
/*
Imagine5.0 Arexx Screwthread Creator v3
"What use it is, I'll never know !!"
:-)
1996 Rob Darke - Freely distributable
robda@parallel.demon.co.uk or iml@parallel.demon.co.uk
Omigod - it's got bigger ...
Please give me some feedback on this script :-)
*/
ADDRESS 'Imagine.1'
DISPLAYREXXPTR ON
NL = '0A'x
IF ~EXISTS('LIBS:rexxreqtools.library') THEN DO
NOTIFY 'Please install the rexxreqtools.library in your LIBS: directory'
NOTIFY 'It is available from /pub/aminet/util/rexx/RexxReqTools.lha'
CALL desist
END
CALL ADDLIB('rexxreqtools.library',0,-30,0)
IF ~EXISTS('LIBS:rexxmathlib.library') THEN DO
CALL rtezrequest('Please install the rexxmathlib.library into your LIBS: directory' || NL || NL ||,
'The library is available from pub/aminet/util/rexx/RexxMathLib1.3.lha','Great, thanks!','Go get RexxMathLib.library','rt_reqpos = reqpos_centerscr')
CALL desist
END
CALL ADDLIB('rexxmathlib.library',0,-30,0)
CALL rtezrequest('ScrewThread Creator - 1996 Rob Darke','Wow!','Screw Threadz','rt_reqpos = reqpos_centerscr')
radius.3 = rtgetlong(20,'Enter outer thread radius','Screw Threadsize',,'rt_reqpos = reqpos_centerscr')
if ~rtresult then CALL desist
radius.2 = rtgetlong(15,'Enter inner thread radius','Screw Threadsize',,'rt_reqpos = reqpos_centerscr')
if ~rtresult then CALL desist
distance = rtgetlong(100,'Enter length of threadded portion of screw','Thread Length',,'rt_reqpos = reqpos_centerscr')
if ~rtresult then CALL desist
blanklength = rtgetlong(0,'Enter length of blank portion of screw','Blank Length',,'rt_reqpos = reqpos_centerscr')
if ~rtresult then CALL desist
p_pgap = rtgetlong(5,'Enter outer thread peak-to-peak gap','Thread spacing',,'rt_reqpos = reqpos_centerscr')
if ~rtresult then CALL desist
no_rot = (distance / p_pgap)
pp_rot = 0
points = 0
do while (pp_rot = 0)
pp_rot = rtgetlong(8,'Enter number of points per revolution','Detail Coarseness',,'rt_reqpos = reqpos_centerscr')
if ~rtresult then CALL desist
points = (pp_rot * no_rot)
if points > 16383 then do
ret = rtezrequest(pp_rot' points per rotation would make too many points' || NL ||,
' in the final object. Try something smaller.','_OK|_Abort','Smaller, please','rt_reqpos = reqpos_centerscr')
if ~ret then CALL desist
pp_rot = 0
end
end
ret = rtezrequest('Please select logarithmic or linear scaling','_Logarithmic|_Abort|_Linear','Choose scaling','rt_reqpos = reqpos_centerscr')
if ret = 2 then CALL desist
if ret = 1 then type = 'logarithmic'
else type = 'linear'
ret = rtezrequest('Would you like a simple countersunk head' || NL ||,
' on the top of your screw ?','_Yes|_No|_Abort','Select Screwhead','rt_reqpos = reqpos_centerscr')
if ret = 2 then head = 'None'
if ret = 1 then head = 'Countersunk'
if ret = 0 then CALL desist
headdepth = '--'
headradius = '--'
if (head ~= 'None') then do
headdepth = rtgetlong(15,'Enter head depth','Screwhead depth',,'rt_reqpos = reqpos_centerscr')
if ~rtresult then CALL desist
headradius = rtgetlong(30,'Enter head radius','Screwhead radius',,'rt_reqpos = reqpos_centerscr')
if ~rtresult then CALL desist
end
axisname = ''
do while (axisname = '')
axisname = rtgetstring('SCREWTHREAD','Enter name for screw object','Object name',,'rt_reqpos = reqpos_centerscr')
end
if ~rtresult then CALL desist
ret = rtezrequest('I am going to make a 'type' screw' || NL ||,
'with the following parameters ...' || NL || NL ||,
' Outer thread = 'radius.3' iu' || NL ||,
' Inner thread = 'radius.2' iu' || NL ||,
' Outer thread peak-peak = 'p_pgap' iu' || NL ||,
' Screw length = 'distance' iu' || NL ||,
' Points per revolution = 'pp_rot' points' || NL ||,
' Head = 'head || NL ||,
' Head depth = 'headdepth || NL ||,
' Head radius = 'headradius || NL ||,
' Object name = 'axisname,' _Ok |_Abort','Check details','rt_reqpos = reqpos_centerscr')
if ~ret then CALL desist
ret = rtezrequest('It is imperative that you don`t click anywhere whilst I`m' || NL ||,
' doing this, or else things will go very pear-shaped !!!','_Fair Enough|_Abort','Warning','rt_reqpos = reqpos_centerscr')
if ~ret then CALL desist
/* Let's do it ... */
singleangle = (360 / pp_rot)
singlestep = (p_pgap / pp_rot)
stepin = (radius.3 / points)
offset = (p_pgap / 2)
pi = 3.141592654
po = (pi * 2)
eachstep = (0.9 / points)
raddiff = (radius.3 - radius.2)
diffgrad = (raddiff / (pp_rot - 1))
DETAILEDITOR
ZOOM 1
CENTERAT 0 0 0
MULTIPICKOFF
OBJECTMODE
do i = 1 to 5
ADDAXIS
PICK
ATTRIB.OBJECTNAME = axisname'.'i
SETATTRIBUTES OBJECTNAME
end
OBJECTMODE
PICK axisname'.3'
ADDPOINTMODE
k = 1
startradius = radius.3
do j = 0 to (points-1)
se = ((((singleangle*j) / 360)*po)-pi)
x = (radius.3 * sin(se))
y = (radius.3 * cos(se))
z = (-(j * singlestep))
ADDPOINT x y z
if j > (pp_rot - 1) then do
if type = 'linear' then do
radius.3 = radius.3 - stepin
end
else do
logscale = (log10(k*10))
radius.3 = (startradius * logscale)
k = (k - eachstep)
end
end
end
OBJECTMODE
PICK axisname'.1'
ADDPOINTMODE
k = 1
radius.3 = startradius
do j = 0 to ((points-1)+(pp_rot))
se = ((((singleangle*j) / 360)*po)-pi)
x = (radius.3 * sin(se))
y = (radius.3 * cos(se))
z = (-(j * singlestep))
if j > (pp_rot-1) then do
ADDPOINT x y z
if type = 'linear' then do
radius.3 = radius.3 - stepin
end
else do
logscale = (log10(k*10))
radius.3 = (startradius * logscale)
k = (k - eachstep)
if k < 0.1 then k = 0.1
end
end
end
OBJECTMODE
PICK axisname'.2'
ADDPOINTMODE
k = 1
radius.3 = startradius
radius.2 = radius.3
do j = 0 to (points-1)
se = ((((singleangle*j) / 360)*po)-pi)
if radius.2 > 0 then do
x = (radius.2 * sin(se))
y = (radius.2 * cos(se))
end
else do
x = 0
y = 0
end
z = (-((j * singlestep) + offset))
ADDPOINT x y z
if j < pp_rot then do
radius.3 = (radius.3 - diffgrad)
radius.2 = radius.3
end
else do
if type = 'linear' then do
radius.3 = (radius.3 - stepin)
radius.2 = (radius.3 - raddiff)
end
else do
logscale = (log10(k*10))
radius.3 = (startradius * logscale)
radius.2 = (radius.3 - raddiff)
k = (k - eachstep)
end
end
end
OBJECTMODE
PICK axisname'.4'
ADDPOINTMODE
radius.3 = startradius
z = blanklength
do j = 0 to pp_rot
se = ((((singleangle*j) / 360)*po)-pi)
x = (radius.3 * sin(se))
y = (radius.3 * cos(se))
ADDPOINT x y z
end
OBJECTMODE
PICK axisname'.5'
ADDPOINTMODE
radius.3 = startradius
do j = 0 to pp_rot
se = ((((singleangle*j) / 360)*po)-pi)
x = (radius.3 * sin(se))
y = (radius.3 * cos(se))
z = (-(j * singlestep))
ADDPOINT x y z
end
do i = 1 to 3
OBJECTMODE
PICK axisname'.'i
ADDEDGEMODE
do j = 2 to points
ADDEDGE (j-1) j
end
end
do i = 4 to 5
OBJECTMODE
PICK axisname'.'i
ADDEDGEMODE
do j = 1 to pp_rot
ADDEDGE j (j+1)
end
end
OBJECTMODE
UNPICK ALL
PICK axisname'.2'
SAVEOBJECT 't:tempobj1.iob'
LOADOBJECT 't:tempobj1.iob'
ADDRESS COMMAND 'delete t:tempobj1.iob >nil:'
if (head = 'Countersunk') then do
PICK axisname'.4'
SAVEOBJECT 't:tempobj2.iob'
LOADOBJECT 't:tempobj2.iob'
ADDRESS COMMAND 'delete t:tempobj2.iob >nil:'
UNPICK ALL
ADDAXIS
PICK
ATTRIB.OBJECTNAME = axisname'.9'
SETATTRIBUTES OBJECTNAME
ADDAXIS
PICK
ATTRIB.OBJECTNAME = axisname'.8'
SETATTRIBUTES OBJECTNAME
ADDPOINTMODE
z = (blanklength + headdepth)
do j = 0 to pp_rot
se = ((((singleangle*j) / 360)*po)-pi)
x = (headradius * sin(se))
y = (headradius * cos(se))
ADDPOINT x y z
end
ADDEDGEMODE
do j = 1 to pp_rot
ADDEDGE j (j+1)
end
OBJECTMODE
PICK axisname'.9'
ADDPOINTMODE
do j = 0 to pp_rot
ADDPOINT 0 0 z
end
ADDEDGEMODE
do j = 1 to pp_rot
ADDEDGE j (j+1)
end
OBJECTMODE
UNPICK ALL
MULTIPICKON
PICK axisname'.9'
PICK axisname'.8'
PICK axisname'.7'
MULTIPICKOFF
SKIN
end
UNPICK ALL
MULTIPICKON
PICK axisname'.3'
PICK axisname'.2'
MULTIPICKOFF
SKIN
UNPICK ALL
MULTIPICKON
PICK axisname'.6'
PICK axisname'.1'
MULTIPICKOFF
SKIN
UNPICK ALL
MULTIPICKON
PICK axisname'.4'
PICK axisname'.5'
MULTIPICKOFF
SKIN
UNPICK ALL
MULTIPICKON
PICK axisname'.4'
PICK axisname'.3'
PICK axisname'.6'
if (head = 'Countersunk') then PICK axisname'.9'
MULTIPICKOFF
MERGE
ATTRIB.OBJECTNAME = axisname
SETATTRIBUTES OBJECTNAME
DISPLAYREDRAW
DISPLAYREXXPTR OFF
CALL rtezrequest('Job done. Your screwthread awaits ...','Thanks Rob!','Screw Threadz','rt_reqpos = reqpos_centerscr')
exit
desist: procedure
DISPLAYREXXPTR OFF
exit
end