Want to report only one true position out of multiples

Post Reply
Frequent User
Frequent User
Posts: 34
Joined: Wed May 17, 2017 11:11 pm

Want to report only one true position out of multiples

Post by andycmm » Fri Apr 27, 2018 10:55 am

Hi guys,

Our prints have a call out for all diametrical features .010 -M- A B on our cylindrical parts. Currently, I am just reporting the true position of all the features separately, but what I would like to do is for VB script to just report the worst one. The parts are generally well within tolerance. It seems like all I should have to do is getreportinfo all those features from my previous True position reports and then find the highest one. I feel like the solution would be pretty simple.

Also, is there a way I can do this while disabling the individual true position reports? This is for 3.6 SP 1.

User avatar
Ryan Christopher
Posts: 248
Joined: Mon Jun 06, 2011 3:00 pm
Location: Sumner Washington

Re: Want to report only one true position out of multiples

Post by Ryan Christopher » Fri Apr 27, 2018 12:54 pm

You will need to adjust the two settings ( "T", 3 ) in the GetReportInfo line of the code. Off the top of my head I don't know what should be there:
Instead of:
p(i) = GetReportInfo(NamePrefix & i & NameSuffix, "T", 3)
It might be:
p(i) = GetReportInfo(NamePrefix & i & NameSuffix, "POS", 3)


''''''declaration of variables: paste this block only once in your cmm-m program
Dim i
Dim p(1 to 200)
Dim out
Dim StartPt
Dim EndPtA
Dim EndPtB
Dim NamePrefix
Dim NameSuffix

''''''instantiate the variables below for each block of points
StartPt = 1
EndPtA = 189
NamePrefix = "CIRCLE"
NameSuffix = ""

''''''extraction of T deviation value from cmm-m
for i = StartPt to EndPtA
p(i) = GetReportInfo(NamePrefix & i & NameSuffix, "T", 3)
next i

'''''calculation of largest T deviation
EndPtB = EndPtA - 1
for i = StartPt to EndPtB
if abs(p(i)) > abs(p(i+1)) then
p(i+1) = abs(p(i))
p(i+1) = abs(p(i+1))
end if
next i

'''''assignment of largest T deviation to a variable
out = p(i)

The program should look like this:
1. Report the position of all the holes.
2. Insert the VB.
3. Use a User Defined Dimension to report the variable "out"
4. Create a new report (MyReport1).
5. Delete from the new report all the individual outputs leaving only the user defined one. (the largest deviation.
** the default report won't be saved or printed, it will only exist as a child of the program. The report people will see is the new one MyReport1.
Ryan Tackes
Applications Manager, VMS Inc.

Getting Started
Getting Started
Posts: 3
Joined: Fri Apr 27, 2018 4:27 pm

Re: Want to report only one true position out of multiples

Post by kylemjones1989 » Tue May 08, 2018 11:26 am

I just figured out how to do this. Here is the code below. You'll have to input the names of the diametrical features you wish to compare. You will also have to input whether the diametrical features are outer or inner features (1s or 0s). I explain this in the code but please let me know if you have any questions. Hope this works. Best, Kyle

'Report maximum out of position diametrical feature with bonus of feature accounted for
'Will not report correctly if a circle's size is out of tolerance
'Keep both user defined arrays in same order
'Written by Kyle Jones 5/1/18 (KJones@agmcontainer.com)

'User defined array of circle names. Start with reference circle ("datum_B" is reference circle in example below)
'User defined array of inners or outers where 0 = inner and 1 = outer (".70_D_1" is an inner and the rest are outers in example below)
'limit = positional tolerance limit as reported in feature control frame of drawing
arr = Array("datum_B", "Dim_B","Dim_C",".70_D_1","1.63_dia","1.20_dia")
num_arr = Array(1,1,1,0,1,1)
limit = .01

'Reference circle x and y coordinates
ref_circle = arr(0)
ref_circle_x = GetFeaturePropertyAct(ref_circle, 1)
ref_circle_y = GetFeaturePropertyAct(ref_circle, 2)

'Loop through array to find circle with highest tolerance relative to limit + bonus
length_array = UBound(arr)-1
Dim arr_deviations()
REDIM arr_deviations(length_array)
For i=0 to length_array Step 1
cur_circle = arr(i+1)
cur_circle_x = GetFeaturePropertyAct(cur_circle, 1)
cur_circle_y = GetFeaturePropertyAct(cur_circle, 2)
If num_arr(i+1) = 0 Then
bonus = GetReportInfo(cur_circle, "DIA", 2) - (GetReportInfo(cur_circle, "DIA", 1) + GetReportInfo(cur_circle, "DIA", 4))
bonus = (GetReportInfo(cur_circle, "DIA", 1) + GetReportInfo(cur_circle, "DIA", 5)) - GetReportInfo(cur_circle, "DIA", 2)
End If
bonus_plus_limit = (limit + bonus)
position_dev_cur_circle = (2 * Sqr((cur_circle_x-ref_circle_x)^2 + (cur_circle_y-ref_circle_y)^2))
position_dev_including_bonus_cur_circle = position_dev_cur_circle - bonus_plus_limit
arr_deviations(i) = position_dev_including_bonus_cur_circle

'Find circle with worst deviation from true position including bonus
max_val = arr_deviations(0)
For m=0 to length_array Step 1
If arr_deviations(m) >= max_val Then
max_val = arr_deviations(m)
circle_name = arr(m+1)
value = num_arr(m+1)
End If

'Determine Outputs for user
worst_circle_x = GetFeaturePropertyAct(circle_name, 1)
worst_circle_y = GetFeaturePropertyAct(circle_name, 2)
position_dev_worst_circle = 2 * Sqr((ref_circle_x-worst_circle_x)^2 + (ref_circle_y-worst_circle_y)^2)
If value = 0 Then
bonus_worst_circle = GetReportInfo(circle_name, "DIA", 2) - (GetReportInfo(circle_name, "DIA", 1) + GetReportInfo(circle_name, "DIA", 4))
bonus_worst_circle = (GetReportInfo(circle_name, "DIA", 1) + GetReportInfo(circle_name, "DIA", 5)) - GetReportInfo(circle_name, "DIA", 2)
End If
bonus_plus_limit_worst_circle = limit + bonus_worst_circle
nominal_val = 0
low_tol = 0


Post Reply