View Full Version : Reset to nominals
JamesMannes
10-04-2006, 01:14 PM
Here's one...
I got it from WILCOX
Matthew D. Hoedeman
10-04-2006, 01:17 PM
Can't you get the same effect by marking all, then having it show the path lines and saving? OR, do you mean something other than resetting all feature's actuals to the nominals (targets)?
JamesMannes
10-04-2006, 01:19 PM
Chees pick pick pick. Never went that route. Should have said I got it from Wilcox too. OK?
JamesMannes
10-04-2006, 01:29 PM
Oh don't take your ball and go home. I was just ribbin ya.
Matthew D. Hoedeman
10-04-2006, 01:36 PM
Is that what it does? Really?
V3.7 kind of developed a BUG using my method, you can show the path lines, save the program, close it, open it back up, and ALL the features will show that the actuals do match the nominals (target values) BUT NONE OF THE DIMENSIONS will update to show the new actuals! What you need to do at that point is re-enter the feature ID in the first dimension, then they will all update. Nice bug, eh?
WARNING, the show path lines method will make Pcdmis set all the actuals to the TARGET values. In most cases, these will match the nominals, but not always. For an example, the only feature(s) I have ever changed the TARGET values for is a small hole (say, 3mm) that was more than 0.5mm off location and the 2mm ball wouldn't go into the hole, that kind of thing. I do not know what your BS, er I mean, B&S solution would do in that case.
craiger_ny
10-04-2006, 03:02 PM
Have you ran that code James? Your variable declarations are commented.
Craig
See your application object declaration is commented (Dim App As PCDLRN.Application). Then you Set your reference (Set App). Does this instantiate dynamically? I don't believe it does but I have been wrong before.
Also I believe that PartProgram is a member of the PCDLRN.Application and should be instantiated as such. I am no expert at this so that is why I ask if this code runs.
Perhaps this code:
'
' Dim App As PCDLRN.Application
' Dim Cmd As PCDLRN.Command
' Dim FCmd As PCDLRN.FeatCmd
' Dim Part As PCDLRN.PartProgram
' Dim Cmds As PCDLRN.Commands
Dim Cmds As Object
Dim FCmd As Object
Dim Cmd As Object
Set App = CreateObject("PCDLRN.Application")
Set Part = App.ActivePartProgram
Set Cmds = Part.Commands
Should be:
'
Dim App As Object
Dim Part As Object
Dim Cmds As Object
Dim FCmd As Object
Dim Cmd As Object
Set App = CreateObject("PCDLRN.Application")
Set Part = App.ActivePartProgram
Set Cmds = Part.Commands
Perhaps the code you posted is making an attempt at early binding and that is why it looks as such but I believe you may still need to uncomment the first lines.
JamesMannes
10-04-2006, 03:40 PM
Craiger, Yes it runs. But, I will again say that this is a WILCOX .bas I can't take credit for it. I can understand some VB stuff but the class I took was quite a while ago and most of my app's don't require mucking around with a lot of VB.
craiger_ny
10-04-2006, 03:55 PM
I guess I'm a little lost. Does the instance of the application object not need to be declared? It looks as if it does not. the line "Dim App As PCDLRN.Application" is commented, I understand that this would early bind the variable if it were not commented. Then the variable is set to point to PCDMIS with "Set App = CreateObject("PCDLRN.Application")". However, there is no object declared, so is the object declared dynamically as well as pointed to PCDMIS with this line? I see the same thing is being done with part programs and commands. Understanding that the code does run, is it safe to do this by convention? Is it being done this way because the calling application is the same application being automated. Maybe I'll check a VB forum to see. Like I said I am not entirely on top of my game with this, just enough to be dangerous.
Craig
craiger_ny
10-05-2006, 09:47 AM
Click here for words on the architecture of this .bas (http://www.xtremevbtalk.com/showthread.php?t=271947)
keith
10-10-2006, 01:54 PM
So how do you run the basic programs? I'm familiar with VBA in Word and Excel, and with VB in Visual Studio, but those apps are not on the CMM computer.
Thanks,
Keith
:)
JamesMannes
10-12-2006, 09:32 PM
insert>basic script. Leave this in the program and at the end it will reset everything (make sure you put in a print command first), or insert this in the program and F9 it and hit the play button in the basic script edit window and it will run the script.
keith
10-13-2006, 08:02 AM
insert>basic script. Leave this in the program and at the end it will reset everything (make sure you put in a print command first), or insert this in the program and F9 it and hit the play button in the basic script edit window and it will run the script.
what does the print command do?
I created a variable called TimeToRun and set it by prompting the user. Then I insert a basic script which uses the getvariable to retrieve the value from the program. After calculations, I use setvariable to pass information from the basic program back to the part program. Unfortunately, these commands did not work. Will the print command do something magical? ;)
Keith
craiger_ny
10-13-2006, 08:08 AM
what does the print command do?
I created a variable called TimeToRun and set it by prompting the user. Then I insert a basic script which uses the getvariable to retrieve the value from the program. After calculations, I use setvariable to pass information from the basic program back to the part program. Unfortunately, these commands did not work. Will the print command do something magical? ;)
Keith
Not every version supports setting a variable value through automation. I went from V 3.2063 to V 3.7. I do know it is not in the basic language library for 3.2063 but it is in 3.7, what version it became a feature in I do not know. Perhaps someone with 3.25 or 3.5 could check their help file and let us know if the SetVariableValue method is supported or not. Or you could download the basic language reference (PCDBasic) (http://www.wilcoxassoc.com/Downloads/dl_documentation.htm) from Wilcox. That has been a helpful document for me.
Craig
keith
10-13-2006, 09:09 AM
Not every version supports setting a variable value through automation. I went from V 3.2063 to V 3.7. I do know it is not in the basic language library for 3.2063 but it is in 3.7, what version it became a feature in I do not know. Perhaps someone with 3.25 or 3.5 could check their help file and let us know if the SetVariableValue method is supported or not. Or you could download the basic language reference (PCDBasic) (http://www.wilcoxassoc.com/Downloads/dl_documentation.htm) from Wilcox. That has been a helpful document for me.
Craig
I'm running 3.7 mr2 (soon to be 4.1)
craiger_ny
10-13-2006, 09:22 AM
can you post your script and PCDMIS code. SetVariableValue should work in 3.7. It must be something else. I'm not sure what the print is for. I don't have any print commands going on.
Craig
keith
10-17-2006, 09:51 AM
can you post your script and PCDMIS code. SetVariableValue should work in 3.7. It must be something else. I'm not sure what the print is for. I don't have any print commands going on.
Craig
My program gives me this error:
---------------------------
PC-DMIS Basic Scripting Engine
---------------------------
Error on line: 8 - OLE Automation object does not have a default value
---------------------------
OK
---------------------------
My program is here:
PART NAME : WarmUp
REV NUMBER :
SER NUMBER :
STATS COUNT : 1
STARTUP =ALIGNMENT/START,RECALL:, LIST= YES
ALIGNMENT/END
MODE/MANUAL
PREHIT/ 1.27
RETRACT/ 1.27
CHECK/ 12.7,0.5
COMMENT/DOC,NO,Press F5 to ensure DISPLAY ABSOLUTE SPEEDS is checked
COMMENT/DOC,NO,Set MOVESPEED to 100 for calculating time accurately
MOVESPEED/ 100
TOUCHSPEED/ 1
SCANSPEED/ 1
MANRETRACT/20
LOADPROBE/CURRENT
TIP/T1A0B0, SHANKIJK=0, 0, 1, ANGLE=0
FORMAT/TEXT,OPTIONS, ,HEADINGS,SYMBOLS, ;NOM,MEAS,DEV,TOL,OUTTOL, ,
COMMENT/OPER,NO,Program first prompts for lower left, then upper right limits of a bounding box in which all movement will be contained.
COMMENT/OPER,NO,Move probe to lower left rear of warmup region
PNT1 =FEAT/POINT,RECT
THEO/-114.2102,246.0056,-322.6612,0,0,1
ACTL/150.7531,361.0903,-235.1847,0,0,1
READPOINT/
COMMENT/OPER,NO,Move probe to top right front of warmup region
PNT2 =FEAT/POINT,RECT
THEO/301.1047,13.9373,-179.6567,0,0,1
ACTL/268.4931,312.5765,-201.2698,0,0,1
READPOINT/
ASSIGN/Z_STEP = (PNT2.Z - PNT1.Z)/10
COMMENT/DOC,NO,PNT3 is a temporary variable to step in Z
PNT3 =FEAT/POINT,RECT
THEO/301.1049,13.9372,-179.6562,0,0,1
ACTL/268.4929,312.5768,-192.7895,0,0,1
READPOINT/
ALN0 =ALIGNMENT/START,RECALL:STARTUP, LIST= YES
ALIGNMENT/LEVEL,ZPLUS,PNT1
ALIGNMENT/ROTATE,XPLUS,TO,PNT1,ABOUT,ZPLUS
ALIGNMENT/TRANS,XAXIS,PNT1
ALIGNMENT/TRANS,YAXIS,PNT1
ALIGNMENT/TRANS,ZAXIS,PNT1
ALIGNMENT/END
COMMENT/DOC,NO,Obtain time needed for warm up
C1 =COMMENT/INPUT,NO,'Enter time (in minutes) to warm up'
ASSIGN/TIMETOMOVE = C1.INPUT*60
CS1 =SCRIPT/FILENAME= O:\50-MANUFACTURE\130-INSPECT\DMIS PROGRAMS\TIMER.BAS
FUNCTION/Main,SHOW=YES,,
STARTSCRIPT/
ENDSCRIPT/
COMMENT/DOC,NO,Switch to DCC Mode
MODE/DCC
ASSIGN/PNT3.Z = PNT2.Z-Z_STEP
WHILE/PNT3.Z > PNT1.Z
MOVE/POINT,NORMAL,PNT1.X,PNT2.Y,PNT3.Z
MOVE/POINT,NORMAL,PNT1.X,PNT1.Y,PNT2.Z
MOVE/POINT,NORMAL,PNT2.X,PNT1.Y,PNT3.Z
MOVE/POINT,NORMAL,PNT2.X,PNT2.Y,PNT2.Z
MOVE/POINT,NORMAL,PNT2.X,PNT2.Y,PNT3.Z
ASSIGN/PNT2.Z = PNT2.Z-Z_STEP
ASSIGN/PNT3.Z = PNT3.Z-Z_STEP
END_WHILE/
PROGRAM/END
This is the TIMER.BAS file:
Sub Main
Dim MyApp As Object
Set MyApp = CreateObject ("PCDLRN.Application")
Dim MyPartProgram As Object
Set MyPartProgram = MyApp.ActivePartProgram
Dim MyVar As Object
Set MyVar = MyPartProgram.GetVariableValue ("TIMETOMOVE")
MSGBOX "TIMETOMOVE = ", MYVAR
Dim I As Object
If Not MyVar Is Nothing Then
MyVar.LongValue = MyVar.LongValue + 1
MyPartProgram.SetVariableValue "TIMETOMOVE", MyVar
MsgBox "V1 is now: " & MyVar
Else
Msgbox "Could Not find variable"
End If
End Sub
craiger_ny
10-17-2006, 10:00 AM
According to the "line 8" error you are failing at the message box. I'll look at it and see if I can make a recommendation.
Craig
keith
10-17-2006, 10:25 AM
According to the "line 8" error you are failing at the message box. I'll look at it and see if I can make a recommendation.
Craig
Yes, after the error msgbox, my msgbox appears "TimeToMove = "
craiger_ny
10-17-2006, 10:30 AM
Yes, after the error msgbox, my msgbox appears "TimeToMove = "
That is because in quotes "TimeToMove = " is a string, message box data is a string in all cases and when you use variables of mixed type (integer, double, date) they are converted to strings. It is likely the comma and object that are screwing it up. You are asking the message box to display an object which it can not do. It needs a string. What is it you want the message box to display?
Craig
cmmguy
10-17-2006, 10:53 AM
Shouldnt the message box be something like this:
MYVAR = MSGBOX ("TIMETOMOVE = ")
Also, a msgbox only returns the key pressed not a type-in answer. Use inputbox instead for a type-in answer.
MsgBox returns a string (as craig said) and MYVAR needs to be dim'd as a string.
keith
10-17-2006, 11:12 AM
i added a comment to the part program to display the variable value (120) before calling the basic program. i then changed the basic program to display TIMETOMOVE.LONGVALUE but it is displaying "" before entering the loop, then it displays 1.
that tells me at least the loop is working and the basic program is displaying the value, but the GETVARIABLEVALUE isn't working. Any ideas?
craiger_ny
10-17-2006, 11:20 AM
Try this:
Set MyVar = MyPartProgram.GetVariableValue ("TIMETOMOVE")
MsgBox (MyVar.LongValue)
See what that returns.
TimeToMove is your PCDMIS variable, once you point to it with MyVar you need to reference MyVar when you want TimeToMove.
Craig
craiger_ny
10-17-2006, 12:01 PM
Here is how you may want the .bas
Sub Main
Dim MyApp As Object
Set MyApp = CreateObject ("PCDLRN.Application")
Dim MyPartProgram As Object
Set MyPartProgram = MyApp.ActivePartProgram
Dim MyVar As Object
Set MyVar = MyPartProgram.GetVariableValue ("TIMETOMOVE")
MSGBOX Myvar.LongValue
If Not MyVar Is Nothing Then
MyVar.LongValue = MyVar.LongValue + 1
MyPartProgram.SetVariableValue "TIMETOMOVE", MyVar
MsgBox "V1 is now: " & CStr(MyVar.LongValue)
Else
Msgbox "Could Not find variable"
End If
End Sub
I'm not sure if the CStr is needed but you could try it (I'd try it without it too, I'm thinking it is not neded). I also removed a declaration of I = Object, it was not being referenced after the declaration. Let me know how you make out.
Craig
keith
10-17-2006, 12:30 PM
the silly command just doesn't work...
just before calling the script, the TIMETOMOVE variable is equal to 120.
IN the script and just after using the GETVARIABLEVALUE command, the MyVar value is 0.
after resetting MyVar to 6, the MyVar value is the new value (6).
The SETVARIABLEVALUE command works because AFTER the script finishes, the TIMETOMOVE variable is equal to 6.
Thanks for your help. Must be a bug in the GETVARIABLEVALUE method.
Keith
craiger_ny
10-17-2006, 12:43 PM
GetVariableValue works perfectly for me and I, like you, am using 3.7. I'm going to run the most recent script I posted here and I'll let you know how it goes. Who knows perhaps the problem is using GetVariableValue on a variable that contains the syntax C1.INPUT * 60. I'll get back with you.
Craig
keith
10-17-2006, 12:46 PM
Thanks.
I did put c1.input in an INT() function, then multiply by 60. I'll try not multiplying at all.
keith
10-17-2006, 12:47 PM
HOLY COW!
I took out the *60 and it worked!!!
I changed that line to
ASSIGN/TIMETOMOVE = INT(C1.INPUT*60)
and it worked perfectly!
Thanks!
craiger_ny
10-17-2006, 01:19 PM
You can also pass variables directly to your sub from PCDMIS rather than getting it through automation. That would be another way of getting the data there and probably the safest since obviously it does not like some syntax.
Craig
keith
10-17-2006, 01:24 PM
The help file says:
The only supported variable types that can be passed into BASIC scripts from PC-DMIS are:
Integer
String
Double
I can get ONLY INTEGER to work, though... UNTIL I discovered that this form of BASIC requires that we specify the value of the MyVar object as LongValue, DoubleValue, or StringValue, etc. The variable type in the part program MUST match the variable usage in the BASIC program.
Thanks for your help...
vBulletin® v3.7.3, Copyright ©2000-2008, Jelsoft Enterprises Ltd.