End a program or display a message if Dim is Out of Toler

Post Reply
User avatar
US_Helpdesk
Moderator
Moderator
Posts: 1092
Joined: Wed Feb 23, 2011 7:26 pm

End a program or display a message if Dim is Out of Toler

Post by US_Helpdesk » Tue Mar 26, 2013 5:36 pm

You can retrieve report data into VB using the “GetReportInfo()” function.

double GetReportInfo( CString sReportName, CString sReportType, int nIndex )

Return Value
The value at the specified cell of the report if the function is successful. The return value
is 0.0 if there is no specified cell in the report.
Parameters
sReportName
Specifies the name of the report item to be retrieved.
sReportType
Specifies the type of the report item to be retrieved. It is usually the text in the first
column of the report item.
nIndex
Specifies which value of the report item to be retrieved. Defined as follows:
Nom – 1; Act – 2; Dev – 3; LoTol – 4; UpTol – 5; OutTol – 6.

i.e. the following VB Script could find out if ANY of the following dimension is Out Of Tolerance.

Code: Select all

oot_x = GetReportInfo( "CIRCLE3", "X", 6 )
oot_y = GetReportInfo( "CIRCLE3", "Y", 6 )
oot_z = GetReportInfo( "CIRCLE3", "Z", 6 )
oot_d = GetReportInfo( "CIRCLE3", "DIA", 6 )
oot_c = GetReportInfo( "CIRCLE3", "CIR", 6 )
dim.jpg
Now you can perform some action based on these results… Add all of the OOT variables

Code: Select all

IsOut = oot_x + oot_y + oot_z + oot_d + oot_c
i.e. display a MsgBox
msgbox.jpg

Code: Select all

If IsOut <> 0 Then
   MsgBox("Dimension 8 Cirlce3 is OOT!!!")
End If
Or… Jump to the End of the program.

Code: Select all

If IsOut <> 0 Then
   MsgBox("Dimension 8 Cirlce3 is OOT!!!")
  GoTo MyEnd
End If

Be sure to put a VB Script at the last step of the program

Code: Select all

MyEnd:
You do not have the required permissions to view the files attached to this post.
I've migrated to a new user account, see my other posts here

Martin
Regular User
Regular User
Posts: 20
Joined: Sat May 02, 2015 10:25 am

Re: End a program or display a message if Dim is Out of Tole

Post by Martin » Mon Jul 06, 2015 9:10 pm

Hello,

Should we dim OOT_X AS Integer before we use GetReportInfo function? I tried this function but system say there is declaration error.

Thanks

Tabor
Super User
Super User
Posts: 176
Joined: Thu Dec 20, 2012 3:43 pm

Re: End a program or display a message if Dim is Out of Tole

Post by Tabor » Tue Jul 07, 2015 11:58 am

I've created scripts both with and without declarations and never had a problem. It never hurts to declare your variables though.
Tabor

Martin
Regular User
Regular User
Posts: 20
Joined: Sat May 02, 2015 10:25 am

Re: End a program or display a message if Dim is Out of Tole

Post by Martin » Mon Jul 13, 2015 9:26 pm

First thank you very much for your answer.

Furthermore, usually there are two features if we calculate the distance between point 1 and point 2, where report show feature point 1 (the first line), feature point 2 (the second line). In this case what will be assigned to CString sReportName (i.e. circle 3 position in your example)? point 1, point 2 or something else?

Thanks,

User avatar
US_Helpdesk
Moderator
Moderator
Posts: 1092
Joined: Wed Feb 23, 2011 7:26 pm

Re: End a program or display a message if Dim is Out of Tole

Post by US_Helpdesk » Mon Jul 27, 2015 10:22 am

The Report-Name String is displayed in the Report Database. Just use the exact text string you see displayed in the report database.
I've migrated to a new user account, see my other posts here

Martin
Regular User
Regular User
Posts: 20
Joined: Sat May 02, 2015 10:25 am

Re: End a program or display a message if Dim is Out of Tole

Post by Martin » Mon Aug 10, 2015 7:43 pm

Thanks for all the helpful input.

I do not have any problem to retrieve data in the case which has only one single feature (such as circle 3). However, I still could not retrieve data in another situation where two features are displayed ( for example distance is reported between point1 and point2 in ZA direction). I tried three options as below.

1. GetReportInfo("point1", "ZA", "6")
2. GetReportInfo("point2", "ZA", "6")
3. GetReportInfo("point1, point2", "ZA", "6")

All the results show they are not invalid.

User avatar
US_Helpdesk
Moderator
Moderator
Posts: 1092
Joined: Wed Feb 23, 2011 7:26 pm

Re: End a program or display a message if Dim is Out of Tole

Post by US_Helpdesk » Tue Aug 11, 2015 10:04 am

Correct syntax is:
GetReportInfo("DIST BT POINT1 and POINT2", "ZA", 1-6)

Where the index of 1-6 could be a single integer value between 1 to 6 depending on whether you want nominal, actual, upper / lower tolerance, deviation, etc. of the report output.

You need to retrieve the name of the report item by viewing the report database and copying the name exactly. You last line of script did not work because you do not have a report output named "point1, point2"

I think you need to refer to the PDF file here:
C:\Program Files (x86)\Nikon\CMM-Manager 3.4 SP1\Help\CMM-Manager VB Script Functions.PDF
I've migrated to a new user account, see my other posts here

Martin
Regular User
Regular User
Posts: 20
Joined: Sat May 02, 2015 10:25 am

Re: End a program or display a message if Dim is Out of Tole

Post by Martin » Mon Aug 17, 2015 7:40 pm

It really works, thanks.

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

Re: End a program or display a message if Dim is Out of Toler

Post by Murguel » Mon Sep 24, 2018 6:53 am

Hi,

very good example. Thank you. It works - actually - perfect. However. I still have an issue when I re-measure the feature within a loop.

I made a

do until result_ok = true

[measure]
[create report]
[check out of tolerance] ---- MY PROBLEM ---

loop

---- MY PROBLEM ----

Every time the feature was measured as "NOK", the report is re-created with a suffix as Feature1..1, Feature 1..2, Feature1..3 etc.

But in my VB Script I am checking the out of tolerance by using the Feature-Name without Suffix. OK, I could add a counter and check always the Feature WITH suffix.... but then I still would have many additional reports/features visible in my report.

What would be the most elegant solution?

Post Reply