VB Script in program loop

Post Reply
truline1
Regular User
Regular User
Posts: 23
Joined: Thu Apr 04, 2013 1:26 pm
Location: Chesterland, Ohio
Contact:

VB Script in program loop

Post by truline1 » Wed Mar 04, 2020 11:59 am

I am running a program loop that checks up to 16 parts at a time. On the CMM report, the part in station 1 reports as "POINT d2_3", the part in station 2 reports as "POINT d2_3..1", station 3 reports as "POINT d2_3..2" and so on all the way to the part in station 16 ("POINT d2_3..15). I would like to know if there is a way to use VB script to have the CMM report print station 1 as "POINT d2_3..1", station 2 as "POINT d2_3..2" and so on all the way to station 16 that reports as "POINT d2_3..16" so that the number after the feature name corresponds to the station the part was checked in.

Also, I need to know if there is a way to have the number after the feature continue counting up in sequential order? In other words, after I run the first 16 parts and reload a new 16 parts, is it possible to have the second batch of 16 parts start reporting from 17? ie: station 1 (second run) = "POINT d2_3..17", station 2 (second run) = "POINT d2_3..18" and so on up to "POINT d2_3..32".
That would then continue counting up sequentially for as many parts as we need to run?

I need to inspect over 1000 parts (multiple features on 1 part), then use the CMM readings to find the average dimension of a feature. Our IT guy is writing a program in our system to auto populate the CMM readings in a spreadsheet to try and avoid having to manually enter every dimension thousands and thousands of times. And he feels that having the number after the feature name continue to count up sequentially without repeating would allow his program to work. So if I run 4 batches of 16, the numbers would range from 1-64 and not 4 readings for ..1, 4 readings for ..2, 4 readings for ..3 and so on up to 4 readings of ..15

Any help or suggestions you could offer would be greatly appreciated as we are trying to be as efficient as possible with our time.

Thanks in advance for your help!
Brad Deliere
Truline Industries
www.trulineind.com

truline1
Regular User
Regular User
Posts: 23
Joined: Thu Apr 04, 2013 1:26 pm
Location: Chesterland, Ohio
Contact:

Re: VB Script in program loop

Post by truline1 » Wed Mar 04, 2020 12:54 pm

Or if what I asked in the original post is not possible, do you know how I could pause the program after the 16th part has run, enter text to remove and reload 16 more parts, then have the program start again from station 1 without aborting the program? So the next run of parts would start from 17 and go to 32 before another pause, reload, and rerun, then start at 33-48....
Brad Deliere
Truline Industries
www.trulineind.com

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

Re: VB Script in program loop

Post by CrashN8 » Wed Mar 04, 2020 4:28 pm

EDIT - Please note my comments below about using DDE for report output. I think this is the real solution to above question.

Here is the short answer... Use for loop for any number of nested loops in your program and then use the index (i) from loop(s) to assign variable feature names. Like this...

Code: Select all

for i = 1 to 5  'main loop
  for k = 1 to 4  'sub loop
    FeatName = "Point_" & i & "_sub_" & k
Then include portion of CMM-Manager program that will be looped here - inside the For Loop. In my example I just use constructed features. Note the Feature Name starts with '@' - this is a reference to String variable in the script. I am assigning a unique name in each iteration of the loop.
variable_name.jpg

Code: Select all

  next
next
After running my sample program I have 20 uniquely named features in the database. See attached program.

variable_name_features.jpg
You do not have the required permissions to view the files attached to this post.

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

Re: VB Script in program loop

Post by CrashN8 » Wed Mar 04, 2020 4:30 pm

If you need to save the index number of your loop from one program execution to the next just write the (i) index value to a text file. You could give the user an option to reset index at the beginning of each program execution. Search Forum for hints on writing text file or values to Windows Registry.

truline1
Regular User
Regular User
Posts: 23
Joined: Thu Apr 04, 2013 1:26 pm
Location: Chesterland, Ohio
Contact:

Re: VB Script in program loop

Post by truline1 » Thu Mar 05, 2020 3:57 pm

CrashN8,

Im not sure where in the program I need to add the following:
"for i = 1 to 5 'main loop
for k = 1 to 4 'sub loop
FeatName = "Point_" & i & "_sub_" & k".
I tried placing it in the "Begin of:loop1" line and it didn't work. I tried placing in the "IF loop1_INDEX=1 THEN" line and I got another syntax error.
Ive been searching the Forum for hints on writing text but I cannot find anything that has worked thus far.

Is there something I can add to the loop that doesnt end the program after the 16th part is inspected, but instead prompts the operator to unload the 16 that were just inspected and reload 16 new parts so that the number after the feature name continues counting up from where it left off.
Brad Deliere
Truline Industries
www.trulineind.com

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

Re: VB Script in program loop

Post by CrashN8 » Fri Mar 06, 2020 11:26 am

truline1 wrote:
Wed Mar 04, 2020 11:59 am
I need to inspect over 1000 parts (multiple features on 1 part), then use the CMM readings to find the average dimension of a feature. Our IT guy is writing a program in our system to auto populate the CMM readings in a spreadsheet to try and avoid having to manually enter every dimension thousands and thousands of times. And he feels that having the number after the feature name continue to count up sequentially without repeating would allow his program to work. So if I run 4 batches of 16, the numbers would range from 1-64 and not 4 readings for ..1, 4 readings for ..2, 4 readings for ..3 and so on up to 4 readings of ..15
Let me start from the beginning. I think I've missed a key component to your request. You can skip the extra work your IT guy is doing and just export the report data straight from CMM-Manager into your existing Excel document using DDE. See the DDE post on forum here - viewtopic.php?p=4688

Now you only need to create meaningful Feature Names in your CMM-Manager program to identify
parts from Station 1, Station 2, etc. and let the built in DDE function automatically write report data to subsequent cell (row) each time the program is executed. If time allows, I will post an example here later today.

truline1
Regular User
Regular User
Posts: 23
Joined: Thu Apr 04, 2013 1:26 pm
Location: Chesterland, Ohio
Contact:

Re: VB Script in program loop

Post by truline1 » Fri Mar 06, 2020 11:40 am

Awesome, thank you CrashN8. I will give this a shot.

Also, what is the oldest version of CMM manager that will support this specific request? We are running 3.3 SP1 currently, but our CMM Manager dealer will be out to our shop in a week or so to look into upgrading. Am I wasting time trying to make this happen in 3.3?
Brad Deliere
Truline Industries
www.trulineind.com

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

Re: VB Script in program loop

Post by CrashN8 » Fri Mar 06, 2020 12:42 pm

DDE has existed in CMM-Manager since nearly the beginning. You should be fine.

truline1
Regular User
Regular User
Posts: 23
Joined: Thu Apr 04, 2013 1:26 pm
Location: Chesterland, Ohio
Contact:

Re: VB Script in program loop

Post by truline1 » Fri Mar 06, 2020 12:46 pm

Great, thanks again!
Brad Deliere
Truline Industries
www.trulineind.com

Post Reply