|
|
Example Inplot
Scripts
Cut and paste into Inplot Script Editor
(file: mark.scr)
(script to mark lines)
(select lines or)
(go to top of editor)
gutter,1
(show gutter)
while
(look for string G1)
iffind,G1,gosub100
wend
exit
:100
(maybe G15 so check)
(put G value in variable #5)
savevar,G,5
(if its not 1 then jump to :120)
if,[#5<>1],120
(set marker type 1 in gutter)
mark,1
:120
(return)
rsub
(file: renumber tools.scr)
(renumbers T,H,D addresses)
(check if lines selected)
(if not then do all)
#5=startsel
#6=endsel
#1=1 (startline)
#2=lastline
if,[#5<>#6],gosub800
if,[#6<>#2],gosub810
(initialize tool numbers)
#9=0 (this tool)
#10=1 (next tool)
(main loop to go through all lines)
:1
#1=#1+1
ifeof,999
select,#1
(skip if find these in line)
iffind,(,1
iffind,G15,1
(get T,H,D)
iffind,T,gosub100
iffind,H,gosub200
iffind,D,gosub300
jump,1
(end of main loop)
exit
:100
(renumber T)
iffind,M6,110
(if dont find M6)
(then it must be next tool)
changev,T*,0,#9+1
(save position for later)
marker,1
:111
rsub
:110
(with M6)
(change tool number)
changev,T*,0,#9+1
(increment)
#9=#9+1
jump,111
:200
(renumber H)
changev,H*,0*,#9
rsub
:300
(renumber D)
changev,D*,0,#9
rsub
:800
#1=#5
rsub
:810
#2=#6
rsub
:999
(set last one to T1)
return,1
changev,T*,0,1
exit
(file: shift-z.scr)
(script to move relevant z's)
#6=endsel
#1=startsel
#2=lastline
if,[#5<>#6],gosub800
if,[#6<>#2],gosub810
input,7,Amount to Shift Z
:1
forward
ifeof,999
select
(skip these lines)
iffind,(,1
iffind,G56,1
iffind,G03,1
iffind,G3,1
iffind,G02,1
iffind,G2,1
iffind,G71,1
iffind,M,300
:51
iffind,Z,gosub100
iffind,R,gosub200
jump,1
exit
:100
(fix Z)
savevar,Z,8
#8=#8+#7
changev,Z*,0,#8
rsub
:200
(fix R)
savevar,R,8
#8=#8+#7
changev,R*,0,#8
rsub
:300
(check M)
savevar,M,8
if,[#8=5],1
jump,51
:800
#1=#5
rsub
:810
#2=#6
rsub
:999
exit
(CHAIN EXAMPLE)
(FILE: CHAIN.SCR)
(example of chaining script files)
(first highlight a section)
( of text to change)
#1=startsel
#2=endsel
if,[#2>#1],1
(if,[#1=1],gosub100)
:1
CHAIN,block delete
renumber,1,2
chain,chain1
chain,chain3
exit
|
(FILE: CHAIN1.SCR)
#5=startsel
#6=endsel
if,[#5=#6],gosub100
replace,N,V
chain,chain2
exit
:100(select single line)
select.#1
rsub |
(FILE: CHAIN2.SCR)
#1=startsel
#2=endsel
#3=#1
(add M29 to every highlited line)
:1
if,[#3>#2],800
select,#3
iffind,(,20,1
add,M,29
:20
#3=#3+1
jump,1
exit
:800
select,#1,#2
exit |
(FILE: CHAIN3.SCR)
comment
:999
exit |
(file: insert_selected.scr)
(script to insert a string)
(after selected lines)
(skips comments)
#1=startsel
#2=endsel
if,[#2<=#1],300
#3=#1
select, #1
:100
forward
insert,G00
#2=[#2+1]
#3=lineno
if, [#3>#2] ,200
#3=[#3+1]
forward
jump, 100
:200
select, #1,#2
exit
:300
input,1,need to select lines of text
(file:blockskip.scr)
(script to put block skip)
(in front of selected lines)
(highlighted selection or)
(from cursor)
(skips comments)
while
(if already has / then jump to 1)
iffind,/, 1
(if comment line jump to 1)
iffind,(,1,1
(else put slash in front)
front /
:1
wend
exit
(file:remove block delete.scr)
(script to remove block deletes)
(in front of selected lines)
#1=startsel
#2=endsel
#3=#1
select,#1
:100
iffind,/, 300
forward
:300
delstr,/
forward
#3=lineno
if,[#3>#2] ,200
#3=[#3+1]
jump,100
:200
select,#1,#2
(file: setup sheet.scr)
home
#1=0
#4=0
#5=0
#6=0
(3 D numbers per tool)
#30=0
#31=0
#32=0
:5
#1=#1+1
ifeof,6
select,#1
iffind,( PN,320,1
jump,5
:6
home
printbegin
printfont,Courier New
printsize,12
printmarg,0
println
println
println,===============================================================================
print,
P/N:
println,&[9]
print,'
Company Name'
print,','
print,'
OP: '
println,[#24]
println,
File: REV 1
print,'
C N C S E T U P S H E E T
Date: '
printdate
println
println,===============================================================================
println, Tool | Tool | Cutter | Tooling and Process Description
println, Number | Offset | Comp. |
println,===============================================================================
#1=1
#3=0
#80=10 (line counter for form feed)
#81=60 (lines per page)
&[8]=' '
(loop through editor)
:1
#1=#1+1
ifeof,999
select,#1
iffind,G15,1
iffind,M15,1
iffind,( SET,400,1
iffind,(--,450,1
iffind,M6,480
iffind,(,460,1
iffind,G56,500
iffind,G41,540
iffind,G42,540
iffind,M1,600
iffind,M0,550
iffind,M30,600
:2
jump,1
:320
(get part number + op num)
&=$
&pos,P,25
&trim,1,#25+1
&savevar,P,24
&pos,P,25
&trim,#25-1,100
&[9]=&
jump,6
:400
#3=#3+1;
&[#3]=$
(&[#3]remove,N)
&[#3]pos,(,23
&[#3]trim,1,#23
&[#3]pos,),23,1
&[#3]trim,#23,100
jump,2
:450
&[0]=$
(&[0]remove,N)
(&[0]trim,1,1)
&pos,(,23
&trim,1,#23
&pos,),23
&trim,#23,100
print,&[8]
print,&[0]
println
#80=#80+1
if,[#80>#81],gosub777
jump,2
:460
&[0]=$
&pos,(,20
&trim,1,#20
&pos,(,20
&pos,' ',21
if,[#21=1],20
&pos,),23
&trim,#23,100
print,&[8]
print,&[0]
println
#80=#80+1
if,[#80>#81],gosub777
:20
jump,2
:467
&trim,1,#23
rsub
:480
savevar,T,4
jump,2
:500
savevar,H,5
jump,2
:540
savevar,D,6
if,[#6=#30],541
if,[#6=#31],541
if,[#6=#32],541
if,[#30=0],542
if,[#31=0],543
if,[#32=0],544
:541
jump,2
:542
#30=#6
jump,541
:543
#31=#6
jump,541
:544
#32=#6
jump,541
:550
savevar,M,35
if,[#35=1],600
if,[#35=0],600
jump,2
:600
if,[#4=0],632
print,T[#4]
:610
print,' '
if,[#5=0],620
print,H[#5]
print,' '
:620
if,[#30=0],630
print,D[#30]
if,[#31=0],630
print,' '
print,D[#31]
if,[#32=0],630
print,' '
print,D[#32]
:630
#82=[#4+#5+#30+#31+#32]
if,[#82=0],632
println
println,................................................................................
#80=#80+2
if,[#80>#81],gosub777
:632
#4=0
#5=0
#6=0
#30=0
#31=0
#32=0
jump,2
:777
#80=1
printff
println
println
rsub
:999
#8=0
:877
if,[#8>7],888
#8=#8+1
print,&[8]
println,&[#8]
jump,877
:888
printend
(file: shift program.scr)
(shifts X,Y,Z while skiping some)
#5=startsel
#6=endsel
#1=1 (startline)
#2=lastline
if,[#5<>#6],#1=#5
if,[#6<>#2],#2=#6
#3=1 (shift X)
#4=1 (shift Y)
#5=1 (shift Z)
:1
#1=#1+1
ifeof,999
select,#1
(skip these lines)
iffind,(,1
iffind,G0 Z0,1
iffind,X-10. Y20.,1
iffind,G56,1
iffind,G15,1
(shift values)
if,[#3>0],gosub100
if,[#4>0],gosub101
if,[#5>0],gosub102
jump,1
exit
:100
iffind,X,110
rsub
:101
iffind,Y,120
rsub
:102
iffind,Z,130
rsub
:110
offset,X,#3
jump,101
:120
offset,X,#3
jump,102
:130
offset,X,#3
jump,103
:190
(file: renumber.scr)
(script to renumber lines)
input,1,start number:
#3=#1
input,2,increment:
while
savevar,N,5
if,[#5=0],gosub200
gosub,100
wend
exit
:100
#3=#3+#2
changev,N*,0,#3
aspace
rsub
:200
front,N
select
rsub
(file: maho.scr)
(pre-processor script)
(to change plotting)
#20=-1.0
&='G17'
savevar,X,1
savevar,Y,2
savevar,Z,3
savevar,I,4
savevar,J,5
savevar,K,6
savevar,G,7
savevar,F,8
savevar,R,9
iffind,G,gosub100
iffind,X,gosub200
iffind,Y,gosub300
iffind,Z,gosub400
iffind,I,gosub500
iffind,J,gosub600
iffind,K,gosub700
iffind,F,gosub800
iffind,R,gosub900
status,&
plot,&
exit
:100
&rear,G
&rear,[#7]
rsub
:200
#1=[#1*#20]
&rear,X
&rear,[#1]
rsub
:300
&rear,Z
&rear,[#2]
rsub
:400
&rear,Y
&rear,[#3]
rsub
:500
#4=[#4*#20]
&rear,I
&rear,[#4]
rsub
:600
&rear,K
&rear,[#6]
rsub
:700
&rear,J
&rear,[#5]
rsub
:800
&rear,F
&rear,[#8]
rsub
:900
&rear,R
&rear,[#9]
rsub
|
|
|