0% found this document useful (0 votes)
29 views

28 - Adding External Elements

This document discusses how to insert external elements like commands, scripts, routines and objects into measurement routines in PC-DMIS. It covers inserting external commands, BASIC scripts, attaching external measurement routines and inserting external objects.

Uploaded by

sokaiya raman
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
29 views

28 - Adding External Elements

This document discusses how to insert external elements like commands, scripts, routines and objects into measurement routines in PC-DMIS. It covers inserting external commands, BASIC scripts, attaching external measurement routines and inserting external objects.

Uploaded by

sokaiya raman
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 20

Table of Contents

Adding External Elements ............................................................................................... 1

Adding External Elements: Introduction ....................................................................... 1

Inserting an External Command .................................................................................. 1

To insert an External Command............................................................................... 2

Display Check Box ................................................................................................... 2

Wait Check Box........................................................................................................ 3

... button ................................................................................................................... 3

Creating an External Command as a Menu Item or Toolbar Item ............................ 3

Example - Using the External Command to Display a File ....................................... 4

Inserting BASIC Scripts ............................................................................................... 5

To Insert a Basic Script as a Command ................................................................... 6

To Insert a Basic Script as a Menu or Toolbar Item ................................................. 7

Passing Variables To and From BASIC Scripts ....................................................... 7

Attaching an External Measurement Routine .............................................................. 9

Using a Pointer to Reference Data......................................................................... 11

Inserting External Objects.......................................................................................... 12

Create New ............................................................................................................ 12

Create from File ..................................................................................................... 14

Display As Icon ...................................................................................................... 15

Object Type List ..................................................................................................... 15

Marking External Objects for Execution ................................................................. 16

Displaying Files in a Different Way......................................................................... 18

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.

The main topics discussed in this chapter include:

• Inserting an External Command


• Inserting BASIC Scripts
• Attaching an External Measurement Routine
• Inserting External Objects

Inserting an External Command

External Command dialog box

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.

To insert an External Command


Select the Insert | External Command menu option. The External Command dialog
box appears.

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.

The Edit window command line for this option reads:

EXTERNALCOMMAND/DISPLAYSTATE ; path name

DISPLAYSTATE - This toggle field controls whether or not PC-DMIS pauses


execution and displays a message notifying you of an external execution. This
field switches between DISPLAY and NO DISPLAY.

path name - This string represents the path and file name of the executable or
batch file.

Display Check Box


If you select the Display check box in the External Command dialog box (Insert |
External Command), PC-DMIS displays a message that lets you know that routine
execution is paused in order to run the external command. PC-DMIS pauses execution
until you click OK on the message.

Note that this message only appears if you have turned it on inside the Warnings
Display Options dialog box.

2
Inserting an External Command

To get this message to appear:

1. Press F5 to access the Setup Options dialog box.


2. From the General tab, click the Warnings button. The Warnings Display
Options dialog box appears.
3. Select the OK Execution paused in order to spawn a process check box.
Select OK to continue execution.

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".

Wait Check Box


The Wait check box in the External Command dialog box (Insert | External
Command) is only available when the Display check box is not selected.

• 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.

Creating an External Command as a Menu Item or


Toolbar Item
PC-DMIS enables you to customize toolbars and menus to accept new menu items tied
to .EXE, .BAT, and .BAS files. For information on how to do this, see the "Customizing
the User Interface" topic in the "Navigating the User Interface" chapter.

3
Adding External Elements

Example - Using the External Command to Display a


File
This example shows how to create a batch file (an external program) that works with
the EXTERNALCOMMAND to open and display a file. For example, suppose you want to
display an image file, but you don't want to use the Insert | Report Command |
External Object menu option. You can use a command line (or DOS) prompt inside of
a batch file to do this.

The advantage or disadvantage (depending on your needs) to this approach is


that the image will not appear in the report at the end of measurement routine
execution.

Step 1: Create a batch file to display the image:

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.

2. Save the file and give it a .bat filename extension.

Step 2: Link the External Command dialog box to the batch file:

1. Select Insert | External Command. The External Command dialog box


appears.
2. Click the ... button. An Open dialog box appears.
3. Under Files of Type list at the bottom of the Open dialog box, change the type to
BAT Files (*.bat).
4. Navigate to and select your batch file.
5. Click the Open button. The Open dialog closes, and the External Command
dialog box now contains the path to the batch (.bat) file.

4
Inserting BASIC Scripts

Step 3: Control what happens, and insert the command:

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

Step 4: Execute the routine:

1. Mark the resulting command line in the Edit window.


2. Execute your measurement routine.

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.

Inserting BASIC Scripts


The Basic Language Extension to PC-DMIS provides a powerful extension to the
software’s functionality. Basic language scripts or applications may be written from
within PC-DMIS (or imported from elsewhere) and linked to a button on a user-definable
toolbar, allowing the execution of powerful macros. The version of Basic featured in
supported versions of PC-DMIS provides all of the features of a high-level language,
including custom dialogs (created using the built in Dialog Editor), ODBC support, and
OLE support.

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.

The Edit window command line for a sample script reads:

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.

To Insert a Basic Script as a Command


The Insert | Basic Script menu option displays the Insert Basic Script dialog box.

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

To Insert a Basic Script as a Menu or Toolbar Item


You can use PC-DMIS to customize toolbars and menus to accept new menu items tied
to .EXE, .BAT, and .BAS files. For information on how to do this, see the "Customizing
the User Interface" topic in the "Navigating the User Interface" chapter.

Passing Variables To and From BASIC Scripts


From PC-DMIS code, variables can only be passed to BASIC scripts and not from
BASIC scripts.

The only variable types that can be passed into BASIC scripts from PC-DMIS are:

• Integer
• String
• Double

Variables are passed as comma-separated values (known as arguments). These are


defined in the FUNCTION/ statement within the SCRIPT/FILENAME code block. The
FUNCTION/ statement specifies not only the arguments but also the subroutine within
the script that takes the passed values. By default, this line initially reads:

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.

Consider the examples below.

PC-DMIS variables only hold values during measurement routine execution; at


learn time, PC-DMIS variables always have a value of zero.

7
Adding External Elements

Example 1: Using the Function Line to Pass Variables


The following command executes a BASIC script named TEST.BAS. It also, upon
execution, passes the variables defined from the FUNCTION/ line into the TEST.BAS
script:

CS2=SCRIPT/FILENAME= D:\PROGRAM FILES\PCDMIS35\TEST.BAS


FUNCTION/ShowVars,SHOW=YES,ARG1=3,ARG2="Hello",ARG3=2.5,,
STARTSCRIPT/
ENDSCRIPT

Now here's the TEST.BAS script; on execution, it displays the passed in variables in
their respective message boxes:

Sub ShowVars(IntVar As Integer, StrVar As String, DoubleVar As


Double)
msgbox "The passed integer variable is " & IntVar
msgbox "The passed string variable is " & StrVar
msgbox "The passed double variable is " & DoubleVar
End Sub

Example 2: Using the GetVariableValue and SetVariableValue


Methods to Pass Variables
The following example first uses PC-DMIS code to receive an integer value from the
user and assigns it to the V1 variable.

C1=COMMENT/INPUT,Please type an integer value.


ASSIGN/V1=INT(C1.INPUT)
COMMENT/OPER,BEFORE SCRIPT: Variable is:
,V1

It then calls a BASIC script named TEST2.BAS.

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

This script takes V1 variable and, using the GetVariableValue and


SetVariableValue automation methods, increments the V1 by one and then sets the
new value for V1 in the measurement routine.

PC-DMIS then displays the changed variable in an operator comment.

COMMENT/OPER,AFTER SCRIPT:Variable is now


,V1

Attaching an External Measurement


Routine
The Insert | Attach Measurement Routine menu option opens the Attach External
Measurement Routine dialog box. You can use this dialog box to attach a
measurement routine to the current measurement routine. This does not mean that PC-
DMIS actually attaches and executes all the command in the specified measurement

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".

Attach External Measurement Routine dialog box

This dialog box contains these options:

External Measurement Routine file name


Use this box to type the path for the measurement routine you are going to attach.
If you prefer, you can use the Browse button (...), which also places the file name
path into the box.

Equate Routine Alignments


Use this area to share alignments between two measurement routines by
selecting them from the available lists. See "Equating an Alignment" in the
"Creating and Using Alignments" chapter for additional information.

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

Using a Pointer to Reference Data


When you access an attached measurement routine, you often want to use data from
that measurement routine. When you reference this data, you must reference the
pointer (or variable ) that contains the location of your measurement routine.

Suppose you're attaching TEST_A.prg to your current measurement routine.


Your attach command would look something like this:

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.

COMMENT/OPER,"The X value for F1 from the attached


measurement routine is:"
,CS1:F1.X

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.

Inserting External Objects

Insert Object dialog box

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.

Use external objects to import an instructional video, audio instructions, or written


instructions into your measurement routine.

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.

To create a new object and place it in the Edit window:

1. Select the Create New option.


2. Select the desired object type from the Object Type list. The object will appear in
a box, bounded by small rectangular points within your Edit window. Use your
mouse to drag the box to another location or resize the box using the small
rectangles.
3. Double-click within the object. You will see that the application that runs that
particular object opens in the Edit window.
4. Modify the object by using the tools specific to the inserted application.
5. When you are done, click on the portion of the Edit window that is outside of the
inserted object.

Suppose you want to include a new word document in the Edit window:

1. Select the Create New option.


2. Select a word document object from the Object Type list.
3. Drag the object box with the mouse to a desired location within the Edit window.
4. Resize the box to the desired size.
5. Type the information within the word document object.
6. Click outside of the object to return to normal PC-DMIS Edit window functions.
The word document will remain 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

Create from File

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.

To insert a previously-created object:

1. Select the Create from File option.


2. Type the directory path that contains the file you want to place as an object. Or,
use the Browse button to navigate to the correct directory.
3. Select the file to insert as an object.
4. Click the OK button. The object now appears in the Edit window. Use your
mouse to drag the box to another location or resize the box using the small
rectangles.

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.

Example of a word document object displayed as an icon

Object Type List

Sample Object Type list

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.

To choose an object type:

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.

Marking External Objects for Execution


By default, external objects print and do not execute when you execute a measurement
routine. However, with some objects, the desired action may be to execute and not
print. For example, when embedding a graphic, the desired action may be to print the
graphic to the report; while when embedding a sound or movie clip, the desired action
may be to execute the object to play the clip at execution time.

External objects have four modes of execution:

1. Print - Don’t execute


2. Don’t print - Don’t execute
3. Don’t Print - Execute
4. Print - Execute

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

Hash Lines - No Hashed Border


• Don't Print
• Don't Execute

Hash Lines - Hashed Border


• Don't Print
• Execute

No Hash Lines - Hashed Border


• Print
• Execute

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

Displaying Files in a Different Way


An alternate way to display files is to use the PC-DMIS EXTERNALCOMMAND Edit
window command. See "Example - Using the External Command to Display a File" for
information.

18

You might also like