home *** CD-ROM | disk | FTP | other *** search
- /* CMD: Test Script
- * Skeleton for Modeler ARexx scripts
- */
-
- ax.1='X'
- ax.2='Y'
- ax.3='Z'
- lax="X"
- address "LWModelerARexx.port"
- call addlib "LWModelerARexx.port", 0
- SIGNAL ON ERROR
- SIGNAL ON SYNTAX
- NUMERIC DIGITS 4
- call addlib "rexxsupport.library", 0, -30, 0
- call addlib "rexxmathlib.library", 0, -30, 0
- sysnam = 'Text Thing'
- version = '0.01ß'
-
- N=pointcount()
- call req_begin sysnam
-
- id_srf = req_addcontrol("Surfaces",'R')
- id_fnt = req_addcontrol("Faces",'F',1)
- id_txt = req_addcontrol("@Hey ", 'T',"Points: "N" So far")
- id_ind = req_addcontrol("Text Type", "CH",'Block Fillet Chisel Cut')
- /* id_lay = req_addcontrol("Layer", 'CH','1 2 3 4 5 6 7 8')
- id_num = req_addcontrol("Segments", 'N')
- id_ind = req_addcontrol("Axis", "CH",'X Y Z')
- id_cnt = req_addcontrol("Center", 'V', 0)
-
- call req_setval id_cnt 0,N,0
- */
-
- if (~req_post()) then do
- call req_end
- exit
- end
- surf=req_getval(id_srf)
- 'surface "'surf'"'
- call req_end
-
- /* fullfile=getfilename("-- Load Macro --","REXX:lwm" ) */
- /* call rxcmd_add fullfile, fullfile */
-
- call center
- typ=req_getval(id_ind)
- if typ=1 then
- 'EXTRUDE e0.1 n1 axis=Z'
- if typ=2 then
- Call BevelExtrudeText
- if typ=3 then do
- COPY
- 'BEVEL i0.035 s-0.15'
- PASTE
- end
- if typ=4 then do
- FLIP
- 'surface "CutText"'
- COPY
- FLIP
- 'BEVEL i-0.035 s0.25'
- PASTE
- 'MOVE O[0,0,'0.25*0.5']'
- end
- exit
-
- empty=emptylayers()
- if empty~="" then do
- slablayer=word(empty,1)
- end
- else do /* Need 1 layer to transform in */
- call notify(1,'!'sysnam,'@Sorry, No Scratch Layer Available')
- exit
- end
-
- w=3
- h=2
- bx=2*w
- by=2*h
- bz=h
- marg=h/10
- txlayer=curlayer()
- 'setlayer 'slablayer
- 'surface "back"'
- 'makebox L0 H['bx','by','0'] nsegments=1'
- 'bevel i'marg' s'marg
- call center
- say 'drill w'txlayer' operation=SLICE axis=Z'
- 'drill w3 operation=SLICE axis=Z'
- 'boolean with'txlayer' operation=SUBTRACT' /* Remove Slab poly */
- 'boolean with'txlayer' operation=ADD' /* Add in Text Poly */
- 'EXTRUDE e'h' n1 axis=Z'
- 'PASTE'
-
- 'setlayer 'txtlayer
-
- SYNTAX:
- ERROR:
- say 'Sorry, Error #'RC' on line 'SIGL' has been detected.'
- say errortext(rc)
- say sourceline(SIGL)
- t=notify(1,'!Total Bummer Dude!','!An error has been detected.','@'ErrorText(rc),'Line 'SIGL)
- call end_all
- exit
-
-
- PointCount: PROCEDURE
- n=XFRM_BEGIN()
- call END_ALL
- return n
-
- MakeTube: PROCEDURE
- arg cen, len, rad, ax,t
- parse var cen cx','cy','cz
- axlet=translate(ax,'XYZ','123')
- 'SURFACE "TubeType_'t'"'
- tb.1='B'cx' T'cx+len
- tb.2='B'cy' T'cy+len
- tb.3='B'cz' T'cz+len
- select
- when t=1 then do
- sides=random(3,16,time('s')) /* Rand Tube */
- mrad=max(randu(),0.5)*rad
- r.1=rad','rad','mrad
- r.2=rad','rad','mrad
- r.3=rad','mrad','rad
- "MAKEDISC c["cen"] r[" r.ax '] axis='axlet' nsides='sides' 'tb.ax' NSEGMENTS=1'
- end
- when t=2 then do
- sides=12 /* Tri-Tube */
- cn.1='c['cx','cy+rad*.5','cz'] r'0.5*rad' axis='axlet
- cn.2='c['cx+rad*.5','cy','cz'] r'0.5*rad' axis='axlet
- cn.3='c['cx','cy+rad*.5','cz'] r'0.5*rad' axis='axlet
- CUT
- 'MAKEDISC 'cn.ax' nsides='sides' 'tb.ax' NSEGMENTS=1'
- 'ROTATE c['cx','cy','cz'] axis='axlet' angle=120'
- 'MAKEDISC 'cn.ax' nsides='sides' 'tb.ax' NSEGMENTS=1'
- 'ROTATE c['cx','cy','cz'] axis='axlet' angle=120'
- 'MAKEDISC 'cn.ax' nsides='sides' 'tb.ax' NSEGMENTS=1'
- PASTE
- end
- when t=3 then do
- r=0.707*rad
- corn.1='L['cx','cy+r','cz+r'] H['cx+len','cy-r','cz-r'] n1'
- corn.2='L['cx+r','cy','cz+r'] H['cx-r','cy+len','cz-r'] n1'
- corn.3='L['cx+r','cy+r','cz'] H['cx-r','cy-r','cz+len'] n1'
- "MAKEBOX "corn.ax
- if random(0,1,time('s')) then 'ROTATE c['cen'] axis='axlet' angle=45'
- end
- when t=4 then do /* Accordion tube */
- if ax="1" then do
- y1=cy+rad
- y2=cy+rad*(0.5*randu() + 0.25)
- segs=random(2,5,time('s'))
- dx=len/(2*segs)
- x=cx
- p=0
- CUT
- call add_begin
- do i=1 to segs
- vec= x y1 cz
- call add_point vec
- p=p+1
- x=x+dx
- call add_point x y2 cz
- p=p+1
- x=x+dx
- call add_polygon p-1 p
- call add_point x y1 cz
- p=p+1
- call add_polygon p-1 p
- end
- call add_end
- 'LATHE c['cx','cy','cz'] s0 e360 axis='axlet' n'random(3,16)
- PASTE
- end
- if ax="2" then do
- x1=cx+rad
- x2=cx+rad*(0.5*randu() + 0.25)
- segs=random(2,5,time('s'))
- dy=len/(2*segs)
- y=cy
- p=0
- CUT
- call add_begin
- do i=1 to segs
- call add_point x1 y cz
- p=p+1
- y=y+dy
- call add_point x2 y cz
- p=p+1
- y=y+dy
- call add_polygon p-1 p
- call add_point x1 y cz
- y=y+dy
- p=p+1
- call add_polygon p-1 p
- end
- call add_end
- 'LATHE c['cx','cy','cz'] s0 e360 axis='axlet' n'random(3,16)
- PASTE
- end
- if ax="3" then do
- y1=cy+rad
- y2=cy+rad*(0.5*randu() + 0.25)
- segs=random(2,5,time('s'))
- dz=len/(2*segs)
- z=cz
- p=0
- CUT
- call add_begin
- do i=1 to segs
- call add_point cx y1 z
- p=p+1
- z=z+dz
- call add_point cx y2 z
- p=p+1
- z=z+dz
- call add_polygon p-1 p
- call add_point cx y1 z
- z=z+dz
- p=p+1
- call add_polygon p-1 p
- end
- call add_end
- 'LATHE c['cx','cy','cz'] s0 e360 axis='axlet' n'random(3,16)
- PASTE
- end
- end
- end
- return t
-
-
- Transform:
- arg mov, rot, scl, cnt
- parse var rot rx','ry','rz
- 'SCALE C['cnt'] F['scl']'
- if rx~=0 then 'ROTATE C['cnt'] Axis=X ang'rx /* Interpret rotations as sequential operations */
- if ry~=0 then 'ROTATE C['cnt'] Axis=Y ang'ry
- if rz~=0 then 'ROTATE C['cnt'] Axis=Z ang'rz
- 'MOVE O['mov']'
- return
-
- SolidText: Procedure
- call Center
- 'BEVEL i0 s0.02'
- 'COPY'
- 'UNDO'
- FLIP
- 'PASTE'
- return
-
- BevelExtrudeText: Procedure /* Have flat text polygons ready! */
- 'BEVEL i0.015 s0.015'
- 'COPY'
- 'UNDO'
- 'EXTRUDE e0.1 n1 axis=Z'
- 'PASTE'
- return .015
-
- BevelChiselText: Procedure /* Have flat text polygons ready! */
- 'BEVEL i0.045 s-0.15'
- return
-
- /* TextSlab: */
- Center: Procedure
- box=boundingbox() /* Should check out empty list ... */
- parse var box n x1 x2 y1 y2 z1 z2
- cx=-(x2+x1)/2
- cy=-(y2+y1)/2
- cz=-(z2+z1)/2
- 'MOVE O=['cx','cy','cz']'
- return box
-
- CenterAx: Procedure
- arg A
- box=boundingbox() /* Should check out empty list ... */
- parse var box n x1 x2 y1 y2 z1 z2
- cx=-(x2+x1)/2
- cy=-(y2+y1)/2
- cz=-(z2+z1)/2
- say A cx cy cz
- if ~pos(upper(A),'X') then cx=0
- if ~pos(upper(A),'Y') then cy=0
- if ~pos(upper(A),'Z') then cz=0
- say cx cy cz
- 'MOVE O=['cx','cy','cz']'
- return box
-