28 - Adding External Elements
28 - Adding External Elements
i
Adding External Elements
Adding External Elements: Introduction
This chapter discusses the various external elements that you can insert into your
measurement routines. These include external applications, BASIC scripts,
measurement routines, and other objects that further enhance your measurement
routine's capability.
Use the Insert | External Command menu option to insert a command into the Edit
window that, when marked and executed, runs an external executable or batch file from
the measurement routine.
• Normal DOS commands can be executed if they are put into a batch file.
• The command must be marked in the Edit window for PC-DMIS to execute the
external command.
• A valid path and file name must be used.
1
Adding External Elements
• PC-DMIS halts the execution of the routine and displays a message when it
encounters an EXTERNALCOMMAND/DISPLAY command during execution.
Click OK to continue measurement routine execution.
1. Specify an external command in the dialog box. To do this, either type the
complete path for the file into the available box, or use the ... button to find the
file.
2. Select the Display check box if you want PC-DMIS to display a message
informing you that routine execution is paused when running an external
command. Execution remains paused until you click OK on the message. See
"Display Check Box" topic for more information.
3. Click OK. The command gets inserted into the Edit window.
path name - This string represents the path and file name of the executable or
batch file.
Note that this message only appears if you have turned it on inside the Warnings
Display Options dialog box.
2
Inserting an External Command
If you do not select the Display check box, PC-DMIS runs the specified external
command without displaying any sort of message. PC-DMIS continues execution while
the executable or batch file runs simultaneously. When not checked, the Wait check
box becomes enabled. For more information, see "Wait Check Box".
• When the Wait check box is selected, the execution of the measurement routine
is paused until the external command finishes its operation.
• When the Wait check box is not selected, the measurement routine continues
execution even if the external command hasn't finished its operation.
... button
The ... button in the External Command dialog box (Insert | External Command)
displays an Open dialog box. You can select the file name for the external command.
Once you open the file, PC-DMIS inserts the full path into the External Command
dialog box.
3
Adding External Elements
1. Open a text editor, such as Notepad. On the first line, enter this command:
start <PATHWAY>
where <PATHWAY> is the complete path to the picture (for example, start
d:\temp\mypart.gif).
This command tells Windows to open the image file using its default image
viewer application.
Step 2: Link the External Command dialog box to the batch file:
4
Inserting BASIC Scripts
1. Choose either to display or not display a message that pauses the execution of
the measurement routine. See "Display Check Box" for more information.
• Select the Display check box from the External Command dialog box to
display a message.
• Clear the Display check box from the External Command dialog box to
not display a message. When not checked, the Wait option becomes
enabled. See "Wait Check Box" topic for more information.
2. Ensure that the Link check box is cleared.
3. Click OK. The EXTERNALCOMMAND gets inserted into the Edit window.
EXTERNALCOMMAND/DISPLAY ; E:\BATCH\TEST.BAT
PC-DMIS will run the specified batch program, displaying the picture and, depending on
what you selected in the External Command dialog box, will either pause or continue
the measurement routine while you view the picture.
The ability to create and use basic scripts comes as a standard feature in PC-
DMIS CAD and PC-DMIS CAD++. It is not available in PC-DMIS Pro.
5
Adding External Elements
SCRIPT/FILENAME = C:\PCDMISW\sample.bas
FUNCTION/Main,SHOW=YES,,
ENDSCRIPT/
The FILENAME= field lets you specify the pathway to the BASIC file (.bas filename
extension) that you want to insert and execute with the measurement routine.
The FUNCTION/Main field runs the "Main" subroutine. You can change this to specify a
different subroutine or function in the BASIC file to run.
The SHOW= field lets you determine whether or not commands automatically generated
by your Basic Script appear in your measurement routine after execution.
• When you set SHOW=NO, generated commands will not appear in Summary
mode, Command mode, or DMIS mode (commands still appear in the inspection
report, however). Also, PC-DMIS will not save any generated commands with the
measurement routine.
• When you set SHOW=YES, then generated commands appear in the
measurement routine and PC-DMIS will save generated commands with the
measurement routine. The default is SHOW=YES for measurement routine
compatibility from previous versions.
The PC-DMIS Basic Language Reference Manual completely describes this add-on
package. If you did not receive a copy of the documentation with your Basic Language
package, contact your PC-DMIS software support representative.
You can use this dialog box to add a basic script object to the measurement routine.
Basic script objects contain the name of the basic script that should be executed when
the basic script object is executed. Execution of the measurement routine does not
continue until the basic script has executed. If the basic script creates any objects while
executing, those objects will be inserted into the measurement routine and executed.
Objects inserted by Basic Scripts are highlighted in a different color than other objects
to indicate that the basic script created them. For more information on basic scripts, see
the PC-DMIS BASIC documentation.
6
Inserting BASIC Scripts
The only variable types that can be passed into BASIC scripts from PC-DMIS are:
• Integer
• String
• Double
FUNCTION/Main,SHOW=YES,,
This means that the subroutine named "Main" takes the arguments. SHOW=YES shows
or hides the closing ENDSCRIPT/ statement for the command block.
Notice the two commas following SHOW=YES above. These indicate a field where you
may define your first argument. Type the value in the field and press the Tab key on
your keyboard. PC-DMIS automatically adds "ARG1=" before the first value to indicate
that it's the first argument. An additional comma is also added to allow for additional
arguments. Any additional arguments will have "ARG2=" and "ARG3=" and so on added
as prefixes once values are defined therein.
7
Adding External Elements
Now here's the TEST.BAS script; on execution, it displays the passed in variables in
their respective message boxes:
CS1=SCRIPT/FILENAME=D:\PROGRAM FILES\PCDMIS35\TEST2.BAS
FUNCTION/Main,SHOW=YES,,
STARTSCRIPT/
ENDSCRIPT/
8
Attaching an External Measurement Routine
Here is TEST2.BAS:
Sub Main
Dim App As Object
Set App=CreateObject("PCDLRN.Application")
Dim Part As Object
Set Part=App.ActivePartProgram
Dim Var As Object
Set Var=Part.GetVariableValue("V1")
Dim I As Object
If Not Var Is Nothing Then
Var.LongValue=Var.LongValue+1
Part.SetVariableValue "V1",Var
MsgBox"V1 is now: "&Var.LongValue
Else
Msgbox"Could Not find variable"
End If
End Sub
9
Adding External Elements
routine. Instead, it attaches a pointer to the measurement routine, which enables you to
access its dimensional and feature data. See "Using a Pointer to Reference Data".
The Attach Measurement Routine menu option is especially useful when working in
multiple arm mode. With this option, you can attach a measurement routine from the
Arm2 system onto the Arm1 measurement routine. Attaching the measurement routine
allows the sharing of data so that both arms can run off the same alignment, pass
feature data from one measurement routine to another for calculations, and generally
work in a cooperative manner. (See the "Using Multiple Arm Mode" chapter for more
information on multiple arm mode.)
10
Attaching an External Measurement Routine
CS1=ATTACH/C:\PCDMISW\TEST_A.PRG, Machine=
EQUATE/LOCAL ALIGNMENT = A1, ATTACHED ALIGNMENT = A1
Notice the pointer, CS1. This pointer is used to extract data from the attached
measurement routine.
Now, suppose you wanted to display the measured X value for feature F1 from
TEST_A.prg inside your current measurement routine. You would use a statement like
this.
The code, CS1:F1.X, essentially tells PC-DMIS to look at TEST_A.prg, find feature F1,
and display the X value. This is the way pointers are referenced inside PC-DMIS.
PC-DMIS also lists features from an attached measurement routine in the Construction
or Dimension dialog box. PC-DMIS will display the attached measurement routine’s ID
pointer within the Feature List box. A plus sign (+) appears to the left of the pointer.
Clicking this plus sign expands or collapses a view of all the features in the attached
measurement routine. After you expand the view to show all the features of the attached
measurement routine, you can select any of those features to use in the construction or
dimension process.
11
Adding External Elements
You cannot select the attached routine’s pointer. You can only select the
expanded IDs associated with the pointer.
The Insert | Report Command | External Object menu option enables you to enter
various types of objects from other applications on your system into the Edit window.
Types of objects that can be inserted depend on the applications installed on the
computer system. Examples of objects that can be inserted include graphics, sound
clips, movie clips, midi clips, documents, worksheets, and database tables.
Be sure to place the Edit window in command mode when working with
external objects.
Create New
The Create New option (Insert | Report Command | External Object) enables you to
create a new file of a particular object type at a specified location in the Edit window.
12
Inserting External Objects
The object types are chosen from the Object Type list. Objects can only be placed just
after or just before a feature in the measurement routine.
Suppose you want to include a new word document in the Edit window:
Example of a word document created in the Edit window. Notice how the Edit
window's menus and toolbars are replaced with the menus and toolbars of the
application that corresponds to the object you are creating.
13
Adding External Elements
The Create from File option (Insert | Report Command | External Object) enables
you to insert a previously-created file as an object into the Edit window.
If you want to insert a previously-written word document into the Edit window
that includes a set of instructions about operating the CMM, select the Create from File
option, navigate to the directory that contains the document, and click the OK button.
The document appears within the object box in the Edit window. Use the mouse to
move the object box to where you want it in the Edit window and resize it.
Link
When you select the Create from File option (Insert | Report Command | External
Object), you have the opportunity to "link" your object to the Edit window. When you link
your object back to its original file, any changes made to the original file are also be
updated within the Edit window.
14
Inserting External Objects
Display As Icon
The Display As Icon check box (Insert | Report Command | External Object)
enables you to display the imbedded object as an icon instead of displaying the
information outright. Once you double-click on the icon within the Edit window, it will
then activate.
Suppose you place a word document in the Edit window and select the
Display As Icon check box. The word document appears as an icon. However, if you
double-click on the icon, the imbedded application opens and displays the information
contained in the word document.
15
Adding External Elements
The Object Type list (Insert | Report Command | External Object) contains the object
types available on your computer system. These vary from computer to computer
depending on what application programs you have installed on your hard drive.
1. Use the scroll bar or UP ARROW and DOWN ARROW keys to find the object.
2. Select the object.
3. Click the OK button.
To switch between the different modes, press F3 while the insertion point is on the
same line as the external object in the Edit window. PC-DMIS will use hash lines and
borders to indicate the objects current mode of execution. See the examples below.
• Hash lines - diagonal lines that cross the graphic. When there are hash lines the
object will not print to the report.
• Hashed borders - diagonal lines that cross the border around the graphic. When
a hashed border outlines the object, the object will execute.
Example Behavior
No Hash Lines - No Hashed Border
• Print
• Don't Execute
16
Inserting External Objects
The execute action is always the same action that occurs when an external
object is double-clicked. For media clips, this default action is usually play. For most
other objects, the default action is edit.
Play - Sound clips will play sound. Movie clips will play their movie, etc.
Edit - Objects that have a default action of edit will usually not be objects that would
need to be executed. However, some application objects also have the ability to run
custom basic scripts upon being activated. A Microsoft Word document or Excel
spreadsheet are examples of this type of external object. With these types of objects
and the PC-DMIS automation commands, it is possible to change the object using data
from the measurement routine. For example, an Excel graph could be inserted inside a
measurement routine that has a basic script that, when activated, would pull data out of
the measurement routine using the PC-DMIS automation commands and adjust the
graph accordingly before it was printed on the inspection report.
17
Adding External Elements
18