VB Scripting for Averaging Radial Distances

Post Reply
JNorton
Regular User
Regular User
Posts: 19
Joined: Wed Jul 25, 2018 9:40 am

VB Scripting for Averaging Radial Distances

Post by JNorton » Wed Oct 24, 2018 2:42 pm

I am having problems getting CMM Manager to properly calculate the diameter of 8 measured points on the OD of a sector gear. My program measures each point separately and I construct the circle with those points. My problem is that the nominal value is good at 49.9275±.0025 but the actual ranges from 49.941-49.943. This diameter has been independently verified to be 49.9287. When I report each of the points as a radial distance from center they report within .0003 of the verified measurement.

My next thought was to add VB Script to the program to extract and average the actual's from all 8 points and report that average as a radial distance. My script passes the Syntax Check and I am trying to report the MyDist via the Set Variable option in the User Defined Dimension but nothing is actually reporting. I have "MyDist" typed in the "Actual" field.

Here's is my code:

act_r1 = GetReportInfo("GEAR_OD", "R",2)
act_r2 = GetReportInfo("GEAR_OD_Copy", "R",2)
act_r3 = GetReportInfo("GEAR_OD_Copy2", "R",2)
act_r4 = GetReportInfo("GEAR_OD_Copy3", "R",2)
act_r5 = GetReportInfo("GEAR_OD_Copy4", "R",2)
act_r6 = GetReportInfo("GEAR_OD_Copy5", "R",2)
act_r7 = GetReportInfo("GEAR_OD_Copy6", "R",2)
act_r8 = GetReportInfo("GEAR_OD_Copy7", "R",2)

MyDist = (avgerage = (act_r1 + act_r2 + act_r3 + act_r4 + act_r5 = act_r6 + act_r7 + act_r8)/8)

What am I doing wrong?

User avatar
CrashN8
Site Admin
Site Admin
Posts: 520
Joined: Thu Feb 09, 2017 4:07 pm

Re: VB Scripting for Averaging Radial Distances

Post by CrashN8 » Thu Oct 25, 2018 12:49 pm

Remove "(avgerage =" and ")"
Also change "=" to "+" between act_r5 and act_r6

Should look like this...

Code: Select all

act_r1 = GetReportInfo("GEAR_OD", "R",2)
act_r2 = GetReportInfo("GEAR_OD_Copy", "R",2)
act_r3 = GetReportInfo("GEAR_OD_Copy2", "R",2)
act_r4 = GetReportInfo("GEAR_OD_Copy3", "R",2)
act_r5 = GetReportInfo("GEAR_OD_Copy4", "R",2)
act_r6 = GetReportInfo("GEAR_OD_Copy5", "R",2)
act_r7 = GetReportInfo("GEAR_OD_Copy6", "R",2)
act_r8 = GetReportInfo("GEAR_OD_Copy7", "R",2)

MyDist = (act_r1 + act_r2 + act_r3 + act_r4 + act_r5 + act_r6 + act_r7 + act_r8)/8

JNorton
Regular User
Regular User
Posts: 19
Joined: Wed Jul 25, 2018 9:40 am

Re: VB Scripting for Averaging Radial Distances

Post by JNorton » Fri Oct 26, 2018 10:42 am

Thanks!

Murguel
Frequent User
Frequent User
Posts: 55
Joined: Mon Aug 13, 2018 9:59 am

Re: VB Scripting for Averaging Radial Distances

Post by Murguel » Fri Oct 26, 2018 6:18 pm

CrashN8 wrote:
Thu Oct 25, 2018 12:49 pm
Should look like this...

Code: Select all

act_r1 = GetReportInfo("GEAR_OD", "R",2)
act_r2 = GetReportInfo("GEAR_OD_Copy", "R",2)
...
Congratulation. I looked a bit to the code but did not recognize his mistake. Well done. And thanks for significantly forcing forward this forum. Much appreciated.

User avatar
CrashN8
Site Admin
Site Admin
Posts: 520
Joined: Thu Feb 09, 2017 4:07 pm

Re: VB Scripting for Averaging Radial Distances

Post by CrashN8 » Mon Oct 29, 2018 9:15 am

Murguel wrote:
Fri Oct 26, 2018 6:18 pm
Well done. And thanks for significantly forcing forward this forum. Much appreciated.
Ya... now I just have to find time for my actual job, too.

Post Reply