1.1. Concept
The STEP-NC DLL is a library of functions for intelligent machining. The value of the STEP-NC DLL is that it integrates Geometric Dimension and Tolerance (GD&T) information as defined by CAD systems, with cutting tool path and machining process information as defined CAM systems. It does this using a new standard formally known as ISO 10303-238 but also called AP-238 or STEP-NC. Because the data is integrated, machining applications can compare the quality of a machining process against its design requirements and use this information to make parts more intelligently, quickly and accurately. Because the data is defined by an ISO standard the parts described by the data can be machined and measured on a wide variety of machiness under a wide variety of conditions.
The functions in the STEP-NC DLL can be called from many different programming languages. Some typical example applications include:
- Data Assembly The application creates a STEP-NC program from CAD geometries files, and CAM tool paths.
- Conventional Machining The application converts the machine neutral STEP-NC program into M and G codes for a specific CNC control.
- Conventional Measurement The application converts the machine netural measurement operations into DMIS operations for execution on a CMM.
- Intelligent Machining and Measurement The application optimizes the machining process (feeds and speeds), and adjusts toolpaths using feedback from sensors and measurement devices.
The STEP-NC DLL is divided into objects that provide groupings of similar functionality. Each object consists of a series of related functions and is described in the following sections. The main objects are APT, Finder, Tolerance, Process, Feature, Eraser, Query and Nurbs. At this time only APT and Finder are documented. Tolerance will be documented shortly.
1.2. Introductory Examples
The syntax of a STEP-NC DLL application depends on the programming language. In all the languages a prelude is necessary to connect programming objects to one or more of the DLL objects. The examples below assume all the objects in the STEP-NC DLL have been connected to one programming object called Step. This is uncommon because most programming languages require each DLL object to be connected to a different programming object.
First we give two simple examples of how to make toolpaths. The script below creates and saves a STEP-NC AP-238 file with one RAPID tool movement and a single cutting tool.
Step->PartNo (test part);
Step->DefineTool (0.25, 5.0, 1.0, 2.0, 3.0, 4.0, 5.0);
Step->LoadTool (1);
Step->Rapid ();
Step->GoToXYZ ("point001", 1.0, 12.0, 0.0);
Step->GoToXYZ ("point002", 1.0, 14.0, 0.0);
Step->SaveAsModules (test);
The next script sets the feed and spindle speed before machining a line and an arc.
Step->PartNo (test part);
Step->DefineTool (0.25, 5.0, 1.0, 2.0, 3.0, 4.0, 5.0);
Step->LoadTool (1);
Step->SpindleSpeed (2000);
Step->Feedrate (100);
Step->CoolantOn();
Step->GoToXYZ ("point001", 1.0, 12.0, 0.0);
Step->GoToXYZ ("point002", 1.0, 14.0, 0.0);
Step->Arc ("arc001", 3., 12., 0., 1., 12., 0., 2., false);
Step->SaveAsPart21 (test2);
The third script reads a STEP-NC program and partially decodes its main workplan. A STEP-NC program is divided into workingsteps that contain toolpaths. The working steps are grouped into workplans. A workplan known as the Main Workplan defines the root of the program. In addition to workingsteps, a workplan may contain other workplans, NC functions, Selectives and probing workingsteps. Workingsteps perform machining operations. NC functions perform operations that do not require tool movements. A selective is similar to a workplan except only one of the executables is to be executed at run time. A probing workingstep is a special type of workingstep that contains probing operations.
Step->Open238(test4);
int wp_id = Step->GetMainWorkplan ();
int count = Step->GetNestedExecutableCount (wp_id);
for (i = 0; i < count; i++) {
int exe_id = Step->GetNestedExecutableNext (wp_id, i);
if (Step->IsWorkingstep (exe_id))
printf (Item at %d is a Workingstep\n, i);
continue;
}
if (Step->IsWorkplan (exe_id))
printf (Item %d is a nested workplan\n, i);
continue;
}
if (Step->IsNcFunction (exe_id))
printf (Item %d is an NC function\n, i);
continue;
}
if (Step->IsSelective (exe_id))
printf (Item %d is a Selective\n, i);
continue;
}
if (Step->IsProbingWorkingstep (exe_id))
printf (Item %d is a probing workinstep\n, i);
continue;
}
}
Further examples of how to decode the data, including examples of how to decode tool path data, are given in the Finder object documentation.
The fourth script reads three CAD geometry files and places them in the coordinate system of the CAM data. The program is assumed to know the required coordinates and uses the three placement functions to set those coordinates. The workpiece geometry describes the final part being made by the STEP-NC program. The rawpiece geometry defines the stock, and the fixture geometry describes the fixtures. Putting the geometries into a STEP-NC file allows an on-machine simulator to check the validity of a STEP-NC program, optimize the speeds and feeds, and compute tool path displacements for tools that are smaller or large than the ones assumed by the path.
Step->PartNo ("fish_head");
Step->ReadCatiaAPTclfile ("fishhead.clfile");
Step->Workpiece ("Fish_Final.stp");
Step->WorkpiecePlacement (0, 0, 0, 0, 0, 1, 0, -1, 0);
Step->Rawpiece ("Fish_Stock.stp");
Step->RawpiecePlacement (0, 0, 0, 0, 0, 1, 0, -1, 0);
Step->Fixture ("Fish_Fixture.stp");
Step->FixturePlacement (10, 20, 0, 0, 0, 1, 0, -1, 0);
Step->SaveAsModules (Fish_machining.238);
The placements given in the above script rotate the parts around the Z axis to make the X axis programmed in the geometry align with the negative Y axis of the toolpaths. In addition for the fixture the geometry origin is moved to (10, 20, 0) after the rotation has been completed.
The geometry used for the workpiece, rawpiece and fixture can come from any STEP file. It may be defined as a single part or as an assembly. The former is more common for the workpiece and rawpiece and the latter is more common for the fixture because it may consist of multiple clamps or bolts. The most common source for the data is a STEP AP-203 or AP-214 (CAD geometry) file. However, the DLL does not care provided the STEP file has geometry is harmonized with AP-203.
There is special value if the file is defined by AP-224 or AP-203 Edition 2 because these files include features and tolerances. If the file contains features then these can be used to validate, optimize and regenerate the machining process. In the DLL features are programmed using the Feature and Finder objects. If the file contains tolerances then these can be used to measure, correct and optimize the tool paths, and feeds and speeds. In the DLL tolerances are processed using the Tolerance object.
The definition of Geometric Tolerances and Dimensions is critical for intelligent machining because with this information the control can determine the quality of the machining process and make adjustments as necessary. Consequently the STEP-NC DLL has functions that allow for the direct definition of tolerances when the required information is not otherwise available in a STEP file. Our last script illustrates this property of the DLL.
The script reads the same part geometry as the previous script. It then establishes the A, B and C datums for the data by picking faces in the geometry. Two of the faces are found using functions and one of them is found using a face name which is presumed to have been set by a CAD system. A third way is to ask the user to pick the face in the STEP-NC Explorer but this method is more complex.
After the datums have been defined a probing operation is applied to the hole and two tolerance constraints are defined for the hole. The first constraint requires the perpendicularity of the hole to not deviate within a tolerance of 0.25 millimeters The second constraint requires the diameter of the hole to be 37.44 millimeters with an upper limit of 0.05 (37.94) millimeters and a lower limit of 0.1 (37.34) millimeters.
Step->PartNo ("fish_head");
Step->Workpiece ("Fish_Final.stp");
int wp_id = Step->GetMainWorkplan();
int top_id = Step->GetFaceTop ();
Step->PutDatumA (top_id);
int hole_id = Step->GetFaceUsingName (Hole1);
Step->PutMaxDatumB (hole_id);
int back_id = Step->GetFaceBack ();
Step->PutDatumC (back_id);
fea_id = tol->PlanCylinderProbing (wp_id, 0, "",
hole_id, 2, 5);
tol->AddTolerancePerpendicularity (fea_id, 0.25, 1);
tol->AddToleranceDiameterSizeValueUpperLower (fea_id,
37.44, 0.05, 0.1);
1.3. Connecting to the DLL
The STEP-NC DLL is a COM or Common Object Model DLL. Therefore, it can be accessed from many different types of programming languages.
Two actions are required to access the STEP-NC DLL from your application program. First you must bring the DLL into your programming environment. Second you must write code to connect to the DLL at run time. Both of these actions are common to all Microsoft COM DLLs so there is a wealth of documentation on how to perform them. The descriptions given here are summaries of what has worked for the author.
Unfortunately the first action to bring the STEP-NC DLL seems to vary wildly between versions of the Microsoft software.
In Microsoft Visual C++ 6.0 you have to open a project and use the keystrokes CTRL W to bring up a dialog box similar to the one shown below. If the keystrokes do not work then you probably have the wrong type of project.You need one that supports MFC. A console application with this property is the simplest.
On this box the menu item Add Class /From a Type Library will bring up the dialog box shown below. You can then use this dialog box to search for the STEP-NC DLL. For most users this will be a file called stepnc.dll in the directory C:\Program Files\STEP Tools\STEP-NC Explorer and DLL
After you have completed this dialog you should have header and implementation files called stepnc.h and stepnc.cpp in your project.
On Microsoft Visual C++ 7.0 (aka .Net) the procedure is slightly different. On the main menu you need to select Project/Add Class. You then need to select the icon showing MFC Class From TypeLib as shown below and pick Open.
These actions will bring up another dialog box as shown below. If you pick the File radio button under Add class from and then pick the button on the right of the location box you will be given a dialog box that will allow you to navigate to the stepnc.dll file as before.
In both versions of C++ you should select all of the objects in the DLL for inclusion in your program. In Version 6 you will get one header file stepnc.h. In Version 7 you will get one header file per object, for example, APT.h, Finder.h, Feauture.h etc.
Fortunately, the second action is the same for all environments. You need to write a program that connects your code to the objects at run time. This code should be put at the start of the program and once it is debugged you can forget about it. The following code illustrates how to connect your code to the APT object. After this code has run the instance variable apt can call all the methods defined for the ATPSTEPMaker object.
apt = new IAPT;
CoInitialize(NULL);
apt->CreateDispatch("STEPNC.APT");
if (apt->m_lpDispatch == NULL) {
fprintf (stderr, "APT dll failed\n");
exit(1);
}
The code for connecting to the other types of objects is almost identical except for changes to the type and object names. These names are listed below. For each instance there should be code to test that the connection has been made and to print an error message otherwise.
apt = new IAPT;
apt->CreateDispatch("STEPNC.APT");
wkp = new IFeature;
wkp->CreateDispatch("STEPNC.FEATURE");
find = new IFinder;
find->CreateDispatch("STEPNC.FINDER");
poo = new IProcess;
poo->CreateDispatch("STEPNC.PROCESS");
rub = new IEraser;
rub->CreateDispatch("STEPNC.ERASER");
tol = new ITolerance;
tol->CreateDispatch("STEPNC.TOLERANCE");