Control Movement of Pattern of Holes Using VB Script
The following is an excerpt from The CMM Manager Handbook
Scenario
The shop is targeting a test piece, and they will only use 1 part. This may require moving a pattern of holes around, the holes relationship will be the same, but the first diameter of each pattern will move in X or Y or both axes.
The drawing.
By moving diameter 1 up in Y and maybe over in X the part will be able to be used over and over until the desired dimensional results are achieved.
Here is the program order.
Complete an alignment in this case we used a 3-2-1 Alignment.
After Diameter 1 & 5 are measured the alignment origin is set to the subsequent diameter to maintain the hole spacing. The diameter spacing is 2.500 in X.
Then open VB Script dialog box and add VB Script just above the diameter measurements.
Var1 and Var2 control the X and Y of the Top Front Holes. You will be required to enter a value.
Var3 and Var4 control the X and Y of the Back Top Holes. You will be required to enter a value.
var1 = InputBox("Enter Offset in X in Direction For Front Top Holes -/+")
Var2 = InputBox("Enter Offset in Y in Direction For Front Top Holes -/+")
var3 = InputBox("Enter Offset in X in Direction For Back Top Holes -/+")
Var4 = InputBox("Enter Offset in Y in Direction For Back Top Holes -/+")
If Var1 the known offset of the diameter location offset is 0.00 then the OffsetX variable is the print callout of 1.00
If var1 = 0 then
OffsetX = 1.0
End If
If Var1 greater than 0.00 then the OffsetX variable is the print callout of 1.00 + the input of Var1 (The known offset positive value)
If Var1 > 0 then
OffsetX = 1.0 + Var1
End If
If Var1 less than 0.00 then the OffsetX variable is the print callout of 1.00 + the input of Var1 (The known offset negative value)
If Var1 < 0 then
OffsetX = 1.0 +(Var1*1)
End If
If Var2 the known offset of the diameter location offset is 0.00 then the OffsetY variable is the print callout of 1.00
If Var2 = 0 then
OffsetY = 1.0
End If
If Var2 greater than 0.00 then the OffsetY variable is the print callout of 1.00 + the input of Var2 (The known offset positive value)
If Var2 > 0 then
OffsetY = 1.0 + Var2
End If
If Var2 less than 0.00 then the OffsetY variable is the print callout of 1.00 + the input of Var2 (The known offset negative value)
If Var2 < 0 then
OffsetY = 1.0 +(Var2*1)
End If
If Var3 the known offset of the diameter location offset is 0.00 then the OffsetX variable is the print callout of 1.00
If var3 = 0 then
OffsetX3 = 1.0
End If
If Var3 greater than 0.00 then the OffsetX variable is the print callout of 1.00 + the input of Var3 (The known offset positive value)
If Var3 > 0 then
OffsetX3 = 1.0 + Var3
End If
If Var3 less than 0.00 then the OffsetX variable is the print callout of 1.00 + the input of Var3 (The known offset negative value)
If Var3 < 0 then
OffsetY3 = 1.0 +(Var3*1)
End If
If Var4 the known offset of the diameter location offset is 0.00 then the OffsetY variable is the print callout of 19.00
If Var4 = 0 then
OffsetY4 = 19.0
End If
If Var4 greater than 0.00 then the OffsetY variable is the print callout of 19.00 + the input of Var4 (The known offset positive value)
If Var4 > 0 then
OffsetY4 = 19.0 + Var4
End If
If Var4 less than 0.00 then the OffsetY variable is the print callout of 19.00 + the input of Var4 (The known offset negative value)
If Var4 < 0 then
OffsetY4 = 19.0 +(Var4*1)
End If