TopSolid'Cam 7.19 Automation Guide
TopSolid'Cam 7.19 Automation Guide
1/10
Cam Automation Introduction ................................................................................................... 1
Consultation ........................................................................................................................... 3
Cam database structure ............................................................................................................. 3
How-to ........................................................................................................................................ 3
Elements ..................................................................................................................................... 3
Document ............................................................................................................................... 3
Operation ............................................................................................................................... 4
ElementExId........................................................................................................................ 4
Operation parameters........................................................................................................ 4
Tool path consulting ........................................................................................................... 6
Part ......................................................................................................................................... 7
WCS (World Coordinate System) ........................................................................................... 7
Tool ......................................................................................................................................... 8
Static Operation ..................................................................................................................... 9
Simulation/Verification ........................................................................................................ 10
2/10
Cam automation targets two differents goals. Consultation of Cam objects, and
creation/modification.
Consultation
Consultation allows to scan Cam objects inside Cam documents. It can export Cam data to
build other NC files, or a xls file for self made workshop documents.
How-to
All the code from this document is extracted from the Automation samples.
To be able to use Cam Automation, the application must reference first TopSolid Automation
dlls : TopSolid.Kernel.SX and TopSolid.Kernel.Automating. At least, for Cam purpose, reference
also TopSolid.Cam.NC.Kernel.Automating .
Elements
Document
Handled by TopSolidCamHost.Documents. The Cam document can be accessed like any Cad
document. With a Cam document, you can access to the machining operations, the parts, the
world coordinates frames, the mounted tools, and other Cam specific objects. To obtain a Cam
document, just open a file from the Pdm :
See TopSolid Automation documentation to know how to obtain this Pdm id.
3/10
Operation
Handled by TopSolidCamHost.Operations . An operation is identified by its ElementId.or
ElementExId (see later):
This is the code line to get all machining operations of the given document inDocId.
ElementExId
This is an ElementId able to handle any existing document object, but also a newly created
operations, not yet pushed in the document. All functions with ElementExId in argument can
handle not yet created operations. The other functions use ElementId.
An operation must exist to be modifiable, but it should be modified before its real creation.
The creation will insert the operation in the document, but also compute the tool path. To
avoid computing before the end of the modifications, the allocation of a Cam operation is
different from its creation.
For the allocation, (New function) give the destination document, the comment of this
operation, the part, the world coordinate system, the tool, and the kind of tool path.
…
TopSolidCamHost.StaticOperations.Create(ref this.OperationId);
After that allocation, it is possible to fill the operation with data, and then creates it.
Before an operation creation, do not gives ElementExId.ElementId to a function which needs
a simple ElementId. This id is empty, and the call will fail!
Operation parameters
Each Cam operation have a list of parameters. These parameters describes the complete set
of data necessary to build a tool path: it means geometry to machine, part, tool(s), values,
WCS etc… Each parameter is identified by a simple name, followed by categories. For instance,
the lead in distance have the same simple name than the lead out distance (… distance!).
Categories allows the Cam and users to know which parameter is manipulated.
‘LeadDistance@Lead|LeadIn’ for the first, ‘LeadDistance@Lead|LeadOut’ for the second.
Note the ‘@’ to separate the simple name from the categories. ‘|’ is placed between
categories.
Handled by TopSolidCamHost.Parameters .
4/10
From the ParameterId, you can consult its name, its localized name, its value in text or in
SmartObject (see TopSolid automation documentation). This is a part of CamAutomation
sample to illustrate:
5/10
Tool path consulting
In TopSolid’Cam, a tool path needs a lot of information. Movements’ first, of course, but also
cutting conditions, compensation type or tool orientation. There is also a lot of information
needed by the Post-Processor to output correctly the G code, like pecking parameters or
rotated planes for multi axis work.
The tool path is handled by TopSolidCamHost.ToolPath . Each tool path is a table where the
columns are the kind of stored data (X, Y, Z or feedrate), and each line is a movement or an
information for the Pp. The column list change according to the kind of tool path : drilling,
milling, turning, multi-axis… To consult a tool path from an operation, the first thing is to get
the list of columns :
Then loop on the function NextToolPathItem to get tool path line by line.
The result of this function is a dictionary of values. The key is the column name.
6/10
Part
Handled by TopSolidCamHost.Parts . The machined part is a solid giving the current stock
state. It has the information of which solid(s) has been used as finish part. There is also a
material, and some other linked information. A part is identified by its ElementId. This object
have a list of parameters identical to operation parameters. The source code to use to consult
its parameters is the almost same than for an operation. These parameters are extracted from
the object using the universal properties, already used for Workshop documents.
if (TopSolidCamHost.Operations.GetPart(op) != ElementId.Empty)
{
// Cam part Parameters
var partItem = new TreeViewItem
{
Header = "Part",
Tag = ""
};
opItem.Items.Add(partItem);
7/10
Tool
Handled by TopSolidCamHost.Tools. It contains some driven points, geometrical values, etc…
A tool is identified by its ElementId. This object have a list of parameters identical to operation
parameters. The source code to use to consult its parameters is the almost same than for an
operation. These parameters are extracted from the object using the universal properties,
already used for Workshop documents.
8/10
Static Operation
This is the minimum Cam operation. A static tool path is given by points. The name ‘static’
relies to the impossibility to modify something on the tool path inside TopSolidCam.
try
{
this.OperationId = TopSolidCamHost.StaticOperations.New(this.openedDocument,
new SmartText("Test op"), firstPart, this.WCSId, firstTool, MotionType.ThreeAxis);
TopSolidCamHost.StaticOperations.SetStartingCuttingConditions(this.OperationId,
new SmartReal(UnitType.Velocity, 0.125), new SmartReal(UnitType.AngularVelocity, 750));
First, according to Topsolid way of creation, Run ‘StartModification’. Enclose the full source in
a try/finally to be sure to exit from modification mode properly, in every case.
Then run ‘StaticOperation.New’ to allocate the operation. Essential data like operation
comment, tool, part and world coordinate system are in arguments. You must also specify the
kind of tool path cinematic: three, four radial, four axial, or five axis.
The ‘New’ function returns an ElementExId that you can use to give cutting conditions, and
add points to the tool path.
Finally, run ‘Create’ to push this new operation in the document and execute the tool path.
This function also updates the ElementExId, because it will change for a created operation.
9/10
Simulation/Verification
There are hosts to simulate (SimulationHost), and verify (VerifyHost) the tool path. These
functions need to be able to modify the document, so be sure to enter in modification mode
before calling these Open functions.
try
{
TopSolidHost.Documents.EnsureIsDirty(ref this.openedDocument);
TopSolidCamHost.Verify.OpenOne(this.OperationId.ElementId);
TopSolidCamHost.Verify.SetIncrement(10);
TopSolidCamHost.Verify.StartAnimation();
}
finally
{
TopSolidHost.Application.EndModification(true, true);
}
10/10