DATAKIT API  V2025.1
How To Use Step Writer APIs for step writing of part or assembly

Table Of Contents:


Key Notions in STEP

The Notion of Product

A STEP file describes a PRODUCT. A Product can be 3D Part containing shells, wire frames, points .. or an Assembly. An Assembly contains a list of instances of other PRODUCTS which are its components : an instance is the association of a Product and a relative position of it in the containing assembly. These contained products can be themselves 3D parts or assemblies. So, a Product can be alone, or used in one or several instances, in one or several assemblies : it is written only once in the STEP file, then it can be used as many times as needed.

STEP allows a Product to be both a 3D Part or an Assembly. In practice an Assembly has no 3D directly attached, in such case an empty part is required to be written.

Geometry is described by Bodies (class Dtk_Body). A 3D Part can contain one or several Bodies, or none if it is empty.

Each PRODUCT is required to be designated by a UNIQUE PRODUCT NAME, it is the key for identification in assemblies. Product Names define the nomenclature of the product set being written.

The difference between a simple Part and an Assembly is that for an Assembly, the 3D Part can be empty (but it is required) and its components are written and instances are added before writing the 3D Part.

Entity and References : Node , Entity ID

Some entities are self-sufficient : for instance a Body (as described by a Dtk_Body) contains all the required data and information to write it (topology, geometry, graphical attributes like colors ..).

Some other entities combine an inner description and references to other entities. For instance a FDT (described by a Dtk_Fdt) brings its own description (graphical and semantic) which is completed by references to entities (like faces of a body), detained by another written entity (here, a Dtk_Body). Samely, a View (as Dtk_ModelDisplay) has its own data (camera ..) but its complete definition also includes a list of entities to be viewed (a list of Dtk_Fdt) which are written separately.

The combination of an Entity, the references which go with it (from this entity to others), and an Identifier to allow references to it defines a NODE. So

  • A Node associates an Entity and references which go from it (for instance, a FDT links to geometrical elements like Faces in a Body)
  • A Node associates this Entity to an identifier, which allows other Nodes to have reference on it (for instance, a FDT listed in a View)
  • The Identifier of a Node is a positive integer value, unique in the scope of a Product.

If an Entity is not written in the scope of a Node, it cannot have references to other entities, nor be referenced as a whole (with its Node ID) from another Node. An Entity can be directly referenced with its Entity ID if it is defined (in its Dtk_Info).

References from a Node can be :

  • to another Node taken as a whole (like a FDT in a View) : using the Identifier associated to this Node
  • to an entity within another one (like a Face in a Body) : using an Identifier, recorded in the Dtk_Info the entity to be referenced, an integer value unique in the scope of the Product (domains of Node IDs and of Entity IDs are distinct)

By default, a Reference applies in the same Product. In the case of an assembly, it is possible to define a Reference to an entity of another Product, by defining an Instance Path.

This topic is especially developped in Writing FDT and Views in STEP.

The STEP writing step-by-step.

This documentation explains how to write data to STEP : sequence of calls, settings, for the different possible cases.

An important topic is external references : basically, a STEP model, single part or assembly, can be written in one file. STEP also allows to write products in different files, then the assembly using these external files. External references are considered as a whole (for an assembly to the components it contains as instances), or to elements, as "External Element References" (for a FDT defined at assembly level, which has links to geometric items inside sub-components of the assembly).

So, to keep the explanations clears, they distinguish

Additional informations are given in annexes :

In the examples below, some parts of code are repeated (explained the first time, then reused in other examples). Repeated codes are noted in italic.


The STEP writing : initialisation, settings

A complete STEP writing session starts by initalising it : opening a file, specifying a version of STEP. Then (just after), setting the writing modes if needed (otherwise, defaults will apply).

Then the content is written.

Finally, the STEP writing session is closed.

Here below an example.

Firstly, create Document and start STEP writing : give file name and identification of sending software (here below " sample ") Also, a version of STEP can be specified.

stepw_InitFile( L"C:\\temp\\RootProduct.step", " sample ");

Here above, no version of STEP is specified : a default is determined, it is 2 (for AP214) in general, 4 (for AP242 Edition 1) when writing of FDT is specified. Some types of data require a given version of STEP, otherwise they are not written. Some types of data are better fit for a given version of STEP, even if others can also apply for them. The following examples precise the required or recommended values for each type of data.

Here below, a version of STEP is specified.

// Here, STEP AP214 is selected
int step_version = 2;
stepw_InitFile( L"C:\\temp\\RootProduct.step", " sample ", step_version);
Values of step_version can be
- 0 : default, as when not given, it is then computed from the settings
- 1 : AP203 (first edition). This version is limited to geometry-topology and assemblies : no color, no FDT ..
- 2 : AP214. This version also supports colors - also FDT but few STEP AP214 readers support FDT on reading
- 3 : AP203E2 (Edition 2). This version also supports FDT, it is set by default when FDT mode is set.
- 4 : AP242 (Edition 1). This version is the most complete. Among others, it supports a wider set of definitions for FDT, enhanced capabilities for external references, a really efficient tessellation ..  Now ISO (IS) from year 2014.
- 5 : AP242E3 (Edition 3). Continued enhancements on AP242, especially on FDT. Now ISO (IS) from year 2023.
( before 2023, value 5 was for AP242E2 (Edition 2) introduced in 2020 and replaced by Edition 3 in 2023)

Then (just after stepw_InitFile) set modes for STEP writing

stepw_SetModeItemName(1); // for instance : to activate writing of item names within a body
stepw_SetModeFdt(1); // for instance : to activate writing of FDT as semantic + graphic

Then write the Product Detailed hereafter : cases of Single Part and of Assembly

// see the complete example for details
WriteAsm(); // for an Assembly
.. or
WritePart(); // for a Part

Finally, close the STEP writing

Available modes for writing STEP files

Mode functions are to be called before starting the writing (call to stepw_InitFile). Some can be called just after this call.

Some apply on products, they be called at any time and apply to the products which follow.

For each mode, a dedicated paragraph explains it (effect, values allowed).

The Annex A : Available modes for writing STEP files lists the available modes with values, effect, and condition of call.

Writing STEP compressed files

STEP files are written according to STEP Part21 specifications. It is also possible to write STEP files as compressed, with extension stpZ , according to Recommended Practices for STEP File Compression (V1.0) from CAX-IF (the compression algorithm is pkzip).

The compressed writing is commanded by setting the compression mode, it is modal : it applies to all STEP writings which follow the call (including external references if any).

Remark : file names given as external references SHALL NOT have extrension stpZ, this is managed by the writer.

The function is stepw_SetModeCompress , it has to be called before stepw_InitFile.

Firstly, activate the compress mode

stepw_SetModeCompress (1); // 1 to activate compression mode, 0 to deactivate

Then start the STEP writing itself (repeated)

// In that example, AP242 (Edition 1) is selected
int step_version = 4;
stepw_InitFile( L"C:\\temp\\RootProduct.step", " sample ", step_version);

Specifying content of Header

The starting function stepw_InitFile allows to specify the field Origin of the header (in second argument). If this argument is given empty, the previously given one applies, if none has been given it is empty.

It is also possible to specify other fields of the STEP header : this specification is modal (applies to all files written afterwards).

If these fields are not specified, defaults apply.

5 fields of the Step Header can be edited : Description, Author, Organization, Originating System, Authorization. This is done by calling the function stepw_SetHeaderData, with a string :

Firstly, set the values for the header

// Setting header fields for all following writings of STEP files (main files or as external references)
// Called before stepw_InitFile
int num ..;
// num can be :
// 0 : Description
// 1 : Author
// 2 : Organization
// 3 : Originating System
// 4 : Authorization
stepw_SetHeaderData (num, "value");

Then start writing the file(s). Each writing session can define its Origin field, here "sample" If the argument Origin is empty, the previously defined one applies. stepw_InitFile( L"C:\\temp\\RootProduct.step", " sample "); or with a Dtk_string :

Dtk_string header_value ("value");
stepw_SetHeaderData (num, header_value);

Specifying Context of Products

Each product is defined with a context. This context defines Units of Length and of Angle, and geometrical uncertainty. Defaults are : Length = Millimeter , Angle = Radian , uncertainty = 0.005.

This context can be changed. Setting is modal : it applies to all products defined afterwards. For each product, its context is defined at the time of calling stepw_InitProduct.

Units can be choosen among a defined list of values, they are not arbitrary. For Length : MM CM M KM INCH FOOT . For Angle : Radian Degree.

For Unit, there are 2 possibilities :

  • stepw_SetContextUnit : declaration of Units (length and angle), data (geometries, properties) are assumed to be in these units.
  • stepw_SetConversionLengthUnit : conversion to Unit (length; angle remains in radian), data (geometries, properties) are asummed to be in MM and converted to the selected length unit

Each call to stepw_SetContextUnit/stepw_SetConversionLengthUnit or stepw_SetContextTolerance defines a new context for the following calls to stepw_InitProduct.

// Setting Units (declaration only)
int UnitLength = ...;
// Values allowed
// 0 : the default value : MM
// 1 : MM (as 0)
// 2 : CM
// 3 : M (meter)
// 4 : KM
// 5 : INCH
// 6 : FOOT
int UnitAngle = ...;
// Values allowed
// 0 : Radian (default)
// 1 : Degree
stepw_SetContextUnit (UnitLength,UnitAngle);
// OR Setting Conversion Length Unit (geometries and properties are taken from MM - angle is Radian)
// Setting Definition Tolerance for Geometries, also known as Tolerance
// The value may not be negative
double tol = ...:

Case of a single part

This sections tells about writing a single part. It is the basis, it will be reused for assemblies, for FDT (within a Part) .. FDT are explained separately, because they introduce specific notions.

There are also ANNEXES about data attached to the part and its geometry

Writing a single Part, Introduction of Product

A single part is a product which is self-contained, while an assembly is a product which is composed of other products. Each product has a name, which is unique in the STEP model. The STEP writer allocates an identifier to this product, which is then used by the application to handle it.

Firstly, start the writing of the part

// Start writing the product
int PartID; // will be provided in return, for use when writing the 3D part
if (stepw_InitProduct("Product" ,PartID))
return PartID;
// .. already written, do nothing more, just return the PartID
//Start writing of the 3D Part : the content of the Part

Then, writing the content of the part : examples are given after. Finally, end writing the product

// Close the current part and the product

The value of PartID can then be used by the application if this part is used in an assembly (see after, examples of assemblies)

Important Notice * Product Name must be UNIQUE in a step model. To be sure, call the function stepw_GiveUniqueProductName. If the name is already used in the current step writing session, it will be suffixed, by "--i" whereas i is an integer (–2 –3 etc).

Dtk_string UniqueProductName = stepw_GiveUniqueProductName(ProductName);

It can then be used for stepw_InitProduct.

Case of a single part : only one body (Dtk_Body)

The function stepw_Write3DPartBody takes a Dtk_Body with its content : geometry, topologies, colors, layers, names of items, attributes on the body or on items ..

Firstly, start writing a Part (repeated).

int WritePart()
{
// Start writing the product
int PartID; // will be provided in return, for use when writing the 3D part
if (stepw_InitProduct("Product" ,PartID))
return PartID;
// .. already written, do nothing more, just return the PartID
//Start writing of the 3D Part
stepw_Init3DPart (PartID);

Here, the specific action to write a Dtk_Body

Dtk_BodyPtr PartBody = ...;

Then the usual end of a Part (repeated).

// Close the current part and the product
return PartID;
}

Case of a single part : several bodies (Dtk_Body)

The way is similar as above : between stepw_Init3DPart and stepw_End3DPart, call stepw_Write3DPartBody for each Dtk_Body to be written.

Case of a single part : Meshing (Dtk_mesh)

The result of Tessellation is recorded in a Dtk_mesh. A Dtk_mesh can contain surfacic meshing, organised as a list of Dtk_MeshFace, wireframe meshing (independent curves and points). When the Tessellation has been computed from a Dtk_Body, a Dtk_MeshFace can have a reference to topoligical Face it comes from.

A Dtk_mesh can be written alone, or associated with the Dtk_Body it has been computed from. When written alone, if computed from a Dtk_Body by the Tessellation Library of DtkAPI, it can be written as "from the Body", to redirect the geometric links on items of the Body, to items of the Mesh.

Writing surfacic Tessellation is not recommended in STEP versions before AP242. AP242 brings a much more efficient description of tessellated data, and the capability to keep their association with topological data they come from. Using previous versions (AP203 or AP214) results in poorer data, and moreover very bigger files !

Subcase 1 : writing a Dtk_mesh alone
Dtk_MeshPtr PartMesh = ...;
Subcase 2 : writing a Dtk_mesh together with the Dtk_Body it comes from.
It is assumed that informations of original items are recorded for each tessellation item.
Dtk_BodyPtr PartBody = ...;
Dtk_MeshPtr PartMesh = ...; computed from PartBody
stepw_Write3DPartBodyAndMesh (PartBody,PartMesh);
Subcase 3 : writing a Dtk_mesh alone, with information of the Dtk_Body it comes from.
This allows geometric links (for instance from a FDT) to items of the Body to be redirected on the items of the Mesh instead
It is assumed that informations of original items are recorded for each tessellation item :
the Tessellation Library of DtkAPI records references from computed Dtk_Meshface to original Dtk_Face.
Dtk_BodyPtr PartBody = ...;
Dtk_MeshPtr PartMesh = ...; computed from PartBody
stepw_Write3DPartMeshFromBody (PartMesh,PartBody);

Writing Construction Geometries

A Product can contain construction geometries. A construction geometry is written as a body, but it is qualified as construction geometry. It can contain infinite curves or faces.

Remark about infinite entities (planes or unbounded faces on planes, lines as untrimmed ..) : They may not be written as basic geometry of a STEP model, they have to be written as construction geometries.

Writing Axis Systems

A Product can contains axis systems.

Dtk_AxisSystemPtr AxisSystem = ...;

Case of an Assembly

This applies to the case of an assembly (the main assembly or any sub-assembly).

Firstly is the basic example of writing an assembly. Variants and complements are for external references, FDT in assembly, etc, they are explained in separate sections to keep this basis simple.

Writing an Assembly

An assembly is a product which contains instances of other products.

Each instance in the assembly is defined by a component and a relative location (transformation matrix), it can have an instance name. A component is another product. Each product is identified by its PartID, provided by stepw_InitProduct.

Here below a sequence of writing an assembly. The products used as components can be written before the assembly, or after starting the assembly (stepw_InitProduct), but BEFORE the instances (stepw_AddInstance).

Each Product is written separately and completely then attached to a container product if needed. The global sequence is :

  • Write leaf parts completely - the ProdID returned by stepw_InitProduct for them, will be used for the assembly
  • Write the assembly which contains them - declare instances on contained parts
  • After an assembly has been completely written (after stepw_EndProduct for it), it can then be itself used as a sub-part of another assembly
  • So, each part (leaf part or assembly) can be used in as many instances in other assemblies

Generally, an assembly contains only instances of other products. But it can contain specific geometry, etc.

Firstly, case of an assembly without any specific data.

int WriteAsm()
{
// Start writing the product
int AssemblyID;
if (stepw_InitProduct("AssemblyProduct" ,AssemblyID))
return AssemblyID;
// .. already written, do nothing more, just return the PartID
// Firstly write the components = other products used in this assembly
int ComponentID = WritePart(); // see above
// Then add the instances of these components to the assembly
Dtk_transfo TransformationMatrix = ...; the relative position of the instance in the assembly
stepw_AddInstance(AssemblyID,ComponentID, TransformationMatrix,"PartInstance");
// When all the instances have been written :
// Write the part for this assembly, it is REQUIRED, even empty
stepw_Init3DPart(AssemblyID);
// Finally, close the Product
stepw_EndProduct(AssemblyID);
return AssemblyID;
}

When the assembly node itself has a specific content. It can be written as for a Part, between stepw_Init3DPart and stepw_End3DPart.

Attributes attached to an Instance in an Assembly

As for a Product (part or assembly) or as for a Body or a geometric item, it is possible to write attributes attached to an Instance (of a component in an assembly).

In a similar way, attributes are recorded in a Dtk_Info. So, the sequence is to

  • (Initially, set the writing mode for properties)
  • Create a Dtk_Info then fill it with the attributes
  • when writing the instance, call a variant of stepw_AddInstance : stepw_AddInstanceWithInfo, with this Dtk_Info

To fill the attributes in the Dtk_Info, see the dedicated Annex C : Writing Attributes.

Dtk_InfoPtr InstanceInfo = ..;
Dtk_transfo SubTransformationMatrix = ...;
.. Fill the attributes of the instance to be written
stepw_AddInstanceWithInfo (SubAssyID,ComponentID, SubTransformationMatrix,"PartInstance", InstanceInfo);

Remarks :

  • the fonction stepw_AddInstanceWithInfo has variants used for External Element References.
  • if the Dtk_Info is not created (null pointer), it is ignored and stepw_AddInstanceWithInfo acts as the basic function stepw_AddInstance

External references

It is possible to write a STEP model in several files, by specifying different files for some or all Products (except the root product, which is written in the main file, given to stepw_InitFile). If an assembly has instances of products written in different files, external references are written to link the files.

External STEP files are written in the same location (file path) as the main file : only root name and extension are specified.

Warning : External files must be STEP. The possibility to have references to non-STEP files will be addressed when recommended practices will be commonly agreed and published.

Important remark : not every combination is permitted. Two are possible :

  • "basic external references" : only leaf parts are written in separate files, so all the assembly tree is written in the main file
  • "nested external references" : every product, either assembly or leaf part, is written in a separate file

If no external reference is used, the writing is said "monolithic".

Other combinations can lead to an inconsistent result.

There must be a unique name for each additional STEP file.

When writing an assembly with external references to its leaf parts, it is also possible to consider the leaf parts already written and not rewrite them :

  • to write a product as external, the STEP file is declared before stepw_InitProduct, by calling the function stepw_AddExternalReference. These is no other action to do : all the content of this product will be written in this file, then the product will be designated (in assemblies) by external references of STEP.
  • to just declare it as external reference but not write it, call stepw_AddExternalReference and that's all : all the writing sequence for the product (from stepw_InitProduct to stepw_EndProduct included) is skipped.

Here is explained how to write a STEP file with external references, in the basic case i.e. the case of FDT in assembly is seen separately, later.

Writing a Part as external file : declaration (repeated).<i>
// Start writing the product
int ComponentID; // will be provided in return, for use when writing the 3D part

Specific action : declare this Part as external

// declare this part as external file
stepw_AddExternalReference ("Product", "SubPart.stp",ComponentID);
// The following sequence is for writing the Part as external file
// stepw_InitProduct is called with same product name, it reuses the same value for ComponentID

Then Writing the Part, as usual (repeated).

if (stepw_InitProduct("Product" ,ComponentID))
return ComponentID;
// Then, write the Part without change
// It will then fill the specified file
...
stepw_EndProduct (ComponentID);
// Writing the assembly is not changed

Additional function for external reference file name.

To ensure that name of STEP files are unique, the function stepw_GiveUniqueFileName can be used.

// declare this part as external file
Dtk_string subpart_filename = stepw_GiveUniqueFileName("SubPart.stp");
stepw_AddExternalReference ("SubPart", subpart_filename, ComponentID);

Writing FDT and Views in STEP

FDT in STEP are a combinatory subject, so they are covered by several paragraphs :

  • a general introduction on Nodes for FDT and Views
  • the introduction on FDT hereafter
  • case of FDT in a Part
  • FDT in assembly, in a monolithic STEP file
  • FDT in assembly, with external references
  • Writing Views

FDT and View in STEP : Entity, References, Node

Writing a FDT in STEP involves to

  • write the entity itself, which contains its semantic description and its graphical presentation (see hereafter)
  • write its links to geometries it applies to
  • from views which list it, write a link to it

This is made by defining a Node, with a Node Identifier (a positive integer value, unique in the scope of a Product, so within a sequence stepw_Init3DPart .. stepw_End3DPart). So in the scope of the Node, the FDT and the References to geometrical items are written.

Starting a Node :

int NodeID_FDT = 101; // positive integer which identifies this Node
stepw_InitNodeContext (NodeID_FDT);

Writing the FDT itself (more details below)

Dtk_FdtPtr PartFdt = ...;

Writing the References to geometries (example; more details below)

int IDFdtGeom1 = ...; // identifies the geometric item used by the FDT
stepw_ER ElementReference_1;
stepw_CreateReference (ElementReference_1, IDFdtGeom1);
stepw_AddReference (ElementReference_1);

Closing the Node

Remarks

  • A Node contains one Entity (here, one FDT)
  • Nodes cannot be embedded : starting a node cancels previously opened node if any
  • A Node started but not resumed is lost : the FDT can be written but its geometric links are lost

For a View, a similar sequence apply (see Writing Views)

FDT in STEP : Generals

Additional sections concern : Construction Geometries, Axis Systems (seen in the section Case of a single part) , Views (seen below).

In STEP, description of FDT strongly separate the GRAPHICAL data : the PRESENTATION, and the SEMANTIC data : the REPRESENTATION. Both can be related to geometry (semantic data must be) and to each other.

Definitions for FDT were already in AP214, then AP203E2 (Edition 2), a first implementation was done on AP203E2. However, tests done in the frame of CAX-IF and LOTAR have showed limitations and drawbacks, so these definitions have been completed and reworked for AP242, which is the most complete.

This concerns

  • semantics : more complete definitions have been introduced in AP242 E1, new ones are in progress for AP242 E2
  • graphics : better association with semantics, new way of recording in STEP
  • from AP242E2 : capability of "minimal graphics" (also known as "placeholder presentation"), which just provide some points from which the reader shall recompute its graphic presentation
  • links to geometries : FDT in assembly is now supported

This leads to several combinations to be supported :

  • according to the use case, semantics is needed or not : for instance, VIEWING needs only graphics, METROLOGY needs semantics
  • Semantics is not yet implemented by all STEP processors, so it makes sense to write it or not
  • Several variants of graphics are available, this depends on the version of STEP.

With AP203E2 and AP214, the semantics can be written only with "character based presentation", the graphics alone can be written as "character based" or "polyline". AP242 introduces "tessellated presentation" and allows to write any kind of graphics, alone or associated with semantics; also the mode "charactyer based" is deprecated. In addition, a "minimal presentation" is in discussion but not yet specified.

Types of presentation (graphics of FDT) :

  • "minimal presentation" : the idea is to have just a point and an orientation to compute a graphics from semantics. Discussions still running to reach a common agreement on which "key points" to write (at least, ends of leader lines). First availability with AP242E2.
  • "character based" : with texts, symbols, curves including polylines : the only one accepted in AP214/AP203E2 when semantics is also written. It is the closest to native definitions of FDT, but as a drawback, it is not very stable among processors (use of fonts for texts), so it is disregarded, because graphics is for viewing only.
  • "polyline" : all made of polylines, circles .. it is stable for viewing. It is supported in all versions of STEP, alone, or also with the semantics from AP242.
  • "tessellated" : all made of polylines written with the new Tessellation entities of AP242. Much more compact, stable for viewing, but only from AP242. There are "3D tessellation" (points are X Y Z) and "2D tessellation" (points are defined in a plane - it's even more compact)
  • it is also possible to write the semantics alone, without graphic presentation.

Links to geometries : they are based on the identifiers attached to geometric items provided by the original model, recorded in their Dtk_Info as GetId. So the identifiers are provided by the user.

Writing FDT in a Part

To write a FDT in a Part, the sequence is :

  • globally (just after stepw_InitFile), set the parameters to write FDTs
  • firstly (after stepw_InitProduct), specify that the PRODUCT (here, the Part) contains FDT or geometries used by a FDT : it is an ANCHOR Product. If it is not done, the geometric links cannot be written, as well as the links from Views to FDT
  • for each FDT, record it in the Part
  • and define the geometric links from the FDT to geometric items (generally, faces)

Initially, start the STEP writing itself (repeated)

stepw_InitFile( L"C:\\temp\\RootProduct.step", " sample ");

Firstly, Global setting of parameters to write FDTs

int FdtMode = 1;
int FdtPolylineMode = 0;
stepw_SetModeFdt (FdtMode, FdtPolylineMode);
/*
FdtMode can have these values
0 (default) : don't write FDT in STEP
-1 : write FDT as graphics only
1 : write FDT as semantic (representation) and graphical (presentation)
(previous modes 2 and 3 are not longer used : 2 graphical only is now -1 , 3 semantic only is obsolete)
FdtPolylineMode can have these values, to write graphics of FDT
0 (default) : redirects to "polyline presentation", so like 2 (except where the selected STEP version is AP203E2 or AP214,
which enforces "character based" only in that case)
1 : from AP242E2, "minimal presentation" known as "placeholder" - with previous versions of STEP, acts as 0
2 : "polyline presentation" : all the graphical items are converted to polylines, written with common STEP entities
POLYLINE and CIRCLE, expressed in the 3D space
3 : "tessellated presentation (2D)" : same as 2 but with new tessellation entities of AP242, expressed in the
plane of the Dtk_Fdt
4 : "tessellated presentation (3D)" : same as 3 but expressed in the 3D space
5 : from AP242, "dual presentation = placeholder + tessellated 3D" : 2 presentations are written, then the reader selects one
(by default the tessellated 3D, or if it supports it the placeholder)
About versions of STEP :
If the version has not been specified, AP242 is selected. AP203E2 and AP214 have these limitations :
FdtPolylineMode can be only 0 (character based) 1 2 (polylines) , values 3 and 4 are interpreted as 2
If FdtMode = 1 (semantic + graphics) with STEP version as AP203E2 or AP214, FdtPolylineMode is enforced to "character based"
*/

Then Writing a Part with FDT (repeated)

// Declaring the product
int PartID; // will be provided in return, for use when writing the 3D part
if (stepw_InitProduct("Product" ,PartID))
return PartID;

Just after the product is declared, specify it as an anchor

// Specify this Product as Anchor

Then Start write the Part (repeated)

Then Write a FDT in the Part

// The Node for the FDT
int NodeID_FDT = ...; // positive integer ..
stepw_InitNodeContext (NodeID_FDT);
// The FDT
Dtk_FdtPtr PartFdt = ...;
// Geometric Links
int IDFdtGeom1 = ...; // identifies the geometric item used by the FDT
stepw_ER ElementReference_1;
stepw_CreateReference (ElementReference_1, IDFdtGeom1);
stepw_AddReference (ElementReference_1);
// Resume this Node

Remarks :

  • There is no required order of writing body and adding FDT
  • The geometric links are IDs which are brought by items in the body, or any of the bodies (if several) written in the Part - also Construction Geometries are considered (see later)
  • A Geometric Link is not written if (1) the PRODUCT has not been specified as ANCHOR, (2) if the ID is not detained by any of the items of the body/ies written in the Part
  • In that case, no semantics is written, only the graphic presentation is

Remark about stepw_AddReference : it replaces the previous call to stepw_Add3dPartFdt with a Dtk_Fdt + a stepw_ER.

Additional functions for writing FDT

They complete the main functions already explained :

  • enforce a graphical presentation computed separately : stepw_Add3DPartFDT (variant)

It is possible to enforce a graphical presentation of a FDT, computed separately. This can be done by creating a second FDT, used only for the graphical definition, while the original FDT is used only for the semantic definition.

// The original FDT, used to write the semantic representation
Dtk_FdtPtr PartFdt = ...;
... attach geometrical links to PartFdt, see above
// The graphical definition
Dtk_FdtPtr GraphicalFdt = ...;
// Add PartFdt, with the graphical definition coming from GraphicalFdt
stepw_Add3DPartFDT (PartFdt,GraphicalFdt);

Remark : if the "dual presentation" is selected for graphical output, the placeholder presentation is computed from the PartFdt, the tessellated presentation from the GraphicalFdt. So it is assumed in that case, that PartFdt is suitable to produce a correct placeholder presentation.

Writing Views

In STEP, the term "View" corresponds to Model Display or Capture.

A View can contain some or all the FDTs written in the STEP model. It contains the complete 3D model. A View is written in a Product - between stepw_Init3DPart and stepw_End3DPart. Typically the root product.

- Example,  a View which contains all the FDTs
// Starting the Node for the View
int NodeID_View = ...; // positive integer ..
stepw_InitNodeContext (NodeID_View);
// Writing the View itself
// Resuming the Writing
- Example, a View which contains some FDTs
// Starting the Node for the View
int NodeID_View = ...; // positive integer ..
stepw_InitNodeContext (NodeID_View);
// Writing the View itself
// For each FDT : it is identified by its Node ID (given to stepw_InitNodeContext when writing the FDT)
int NodeID_Fdt1 = ..; // the Node ID used for this FDT
stepw_ER FdtReference1;
stepw_CreateReferenceToNode (FdtReference1, NodeID_Fdt1);
stepw_AddReference (FdtReference_1);
// Resuming the Writing

Warning : according to STEP recommended practices on Views and FDT, a FDT has to be listed in at least one View. A FDT which is not listed in any View will be enforced to be, in the last view recorded in the same Component (Part or Assembly).

Remark about stepw_AddReference : it replaces the previous call to stepw_Add3DFdtModelDisplay with a Dtk_ModelDisplay + Dtk_Fdt.

Writing a FDT in Assembly in a monolithic file

A FDT in Assembly : it is a FDT defined in a Product which is an Assembly, and with geometric links to sub-parts of this assembly.

Sub-Part of an assembly : an instance of a Product at any level in the assembly tree; this defines an instance path, starting from the root product which contains the FDT. An instance path can have one or more levels of instances (sub-assemblies + final part). The instance path may not start from a container of the product which contains the FDT.

So, to write a FDT in Assembly :

  • Firstly, the Products which contain the geometries used by the FDT are specified ANCHOR
  • Also, the Assembly Product is to be specified ANCHOR : because of links from Views to FDT, which are based on the same mechanism
  • As previously, the Products contain geometric items on which the FDT apply, they are identified by an Identifier (user provided)
  • In addition, each Instance (of Part, of sub-assembly) is identified by a User Identifier (for an assembly with external references, there is also a "reference designator")
  • This allows to describe a complete geometric identifier with : the geometric ID of the item, and the path in the assembky as a list of instances, starting by the highest level
  • The FDT is written within the assembly
  • Geometric Links are to describe the geometric items ADDED TO the instance paths

So, links from FDT to geometries introduce user identifiers for INSTANCES in Assemblies, added to them for geometric items in Parts.

For each Product which contains geometric items used by a FDT

Start writing the product (repeated)<i>
// Start writing the product
int ComponentID; // will be provided in return, for use when writing the 3D part
stepw_InitProduct("Product" ,ComponentID);

and specifiy it as anchor (specific for FDT)

// Specify this Product as Anchor

Write the content of the product, as usual (bodies, etc)

// Write the content of the product
stepw_Init3DPart (ComponentID);
...
// Close the current part and the product
stepw_EndProduct(ComponentID);

In this example, an intermediate sub-assembly is introduced in order to illustrate an instance path at several levels.

int SubAssyID;
stepw_InitProduct("SubAssyProduct" ,SubAssyID);
int PartInstanceID; // instance ID returned by the STEP writer
int InstUserID1 = 1; // USER instance ID, provided by the user - must be unique
Dtk_string RD_1 ("RD_1"); // reference designator - will be written in STEP - must be unique in each STEP file
Dtk_InfoPtr PartInstanceInfo; // at least null - can be defined for attributes of the instance
Dtk_transfo PartTransformationMatrix = ...; // position of the part in the sub-assembly
stepw_AddInstanceWithInfo (SubAssyID,ComponentID, PartTransformationMatrix,"PartInstance", PartInstanceInfo, PartInstanceID,InstUserID1,RD_1);
stepw_Init3DPart(SubAssyID);
stepw_EndProduct(SubAssyID);
// The sub-assembly is now complete

Now, write the assembly itself (repeated)

// Write the assembly
// Start writing the product
int AssemblyID;
if (stepw_InitProduct("AssemblyProduct" ,AssemblyID))
return AssemblyID;
// Then add the instances of these components to the assembly
// here below, TransformationMatrix gives the relative position of the instance
int SubAssyInstanceID; // instance ID returned by the STEP writer
int InstUserID2 = 2; // USER instance ID
Dtk_string RD_2 ("RD_2"); // reference designator
Dtk_InfoPtr SubAssyInstanceInfo; // at least null - can be defined for attributes of the instance
Dtk_transfo SubTransformationMatrix = ...; // position of the sub-assembly in the main assembly
stepw_AddInstance(AssemblyID,SubAssyID, SubTransformationMatrix,"SubAssyInstance", SubAssyInstanceInfo , SubAssyInstanceID,InstUserID2,RD_2);

When all the instances have been written : Write the part for this assembly, with its FDT in assembly, views if any ..

// Start writing the content specific of the assembly node - here, not empty
stepw_Init3DPart(AssemblyID);
// add the FDT in the product;
int NodeID_FdtAssy = ..;
stepw_InitNodeContext (NodeID_FdtAssy);
Dtk_FdtPtr FdtAssy = ...;
stepw_Add3DPartFDT (FdtAssy);
// define the geometric link : firstly the geometric item itself
int GeomID1 = ..;
stepw_ER ElementReference_1;
stepw_CreateReference (ElementReference_1,GeomID1,ComponentID); // the reference specifies the product
// then the instance path
stepw_ERP ElementReferencePath_1;
// 2 possible ways to define an instance path : use either
// legacy way : with stepw_CreateInstancePath
stepw_CreateInstancePath (ElementReferencePath_1);
stepw_AddInstanceToPath (ElementReferencePath_1,InstUserID2); // the USER instance IDs
stepw_AddInstanceToPath (ElementReferencePath_1,InstUserID1);
// new way (from V2024.2)
// RefPath1 lists user instance IDs
Dtk_tab&lt;Dtk_ID&gt; RefPath1;
RefPath1.push_back(UserInstID2);
RefPath1.push_back(UserInstID1);
// here below : true if RefPath1 lists user instance IDs, false if RefPath1 lists instance IDs returned by stepw_AddInstance..
stepw_DefineInstancePath(ElementReferencePath_1, RefPath1, true);
// then set this reference path
stepw_SetReferencePath (ElementReference_1,ElementReferencePath_1);
// attach this link to the FDT
stepw_AddReference (ElementReference_1);
// Close the node of this FDT
// Terminate the content of the assembly node

Finally, close the Product (repeated)

stepw_EndProduct(AssemblyID);
return AssemblyID;

Remarks :

  • to define an instance path must start from the highest level instance (in the root assembly) then go down.
  • a same instance path (object stepw_ERP) can be reused in several geometric links (object stepw_ER).
  • the instance is created with a "reference designator" : for a monolithic file this data is not used, but is is important in the case of "nested external references", see below

Writing a FDT in Assembly, with External References

Writing a FDT in Assembly, with External References , "basic" case

The principle is the same as for Writing a FDT in Assembly, in a monolithic file. Difference lies in the geometric links : in a monolithic file, geometric items (faces, ..) are directly pointed with the file, even if among several products.

With external references, the additional need is to make the geometric item "visible" from another file : the file written for the part has to specify which entities are "visible" from other models. This entities are "ANCHOR ENTITIES".

Geometric Links to Anchor Entities are called : External Element References.

(in a monolithic file, all items of a part are visible within this file, with external references the need is to have an explicit list).

With basic external references, all sub-assemblies and instances remain visible within the main file.

Changes from the previous case are, on the Part which contains geometric items to be specified anchors :

  • On the Part, an external reference file is defined (already seen for external references)
  • And anchor entities are specified : this means that they need to be known when starting on the Part

In a Product (typically a leaf part), an ANCHOR ENTITY is defined by :

  • the geometrical ID used to identify it, as usual
  • a public ID, it is a string, it is required to be unique (in the Part), and stable as much as possible (in order to recover the same value in case of rewriting)

Start writing the product (repeated)

int ComponentID; // will be provided in return, for use when writing the 3D part
stepw_InitProduct("Product" ,ComponentID);

Specify the geometric link for external reference

// Specify this Product as Anchor
// And specify the anchor entities
int GeomID1 = ...;
stepw_AddAnchorItem ( GeomID1, ComponentID, "123");

Continue the writing (repeated)

// the rest : unchanged from previous case
..

Remark : anchor entities can be specified in a monolithic file, but they are then ignored.

Writing a FDT in Assembly, with External References , "nested" case

The difference from previous case is that, here the instances are not longer in the main file, except the instances defined at root level.

Previously, when writing STEP the instances were directly used within the main file.

With "nested external references", instances can be in the main file or in other files. To identify them, it is necessary to write them with a unique identifier. As for anchor entities, this identifier is a string, required to be unique (in the Assembly) and stable.

When defined, "reference designator" of instances is written in STEP, but they are used (on reading) only in the case of "nested external references".

The code for writing the Part, the Sub-Assembly(ies), the Main Assembly, is unchanged

except the reference designator of the instance, required and to be unique.

// Writing the Part : no change (must specify the anchor entities)
..
// Writing the Sub-Assembly : no change EXCEPT the reference designator of the instance, must be unique
..
// Writing the Main Assembly : no change EXCEPT the reference designator of the instance, must be unique

As a summary, here is the complete example, it applies in every case. Differences are only about definition of external references.

This complete example requires unique (string) IDs for : anchor entities, instances - these IDs are used through external references, unuse within a same file.

For each Product which contains geometric items used by a FDT : starting repeated<i>
// Start writing the product
int ComponentID; // will be provided in return, for use when writing the 3D part

Specify this product as external reference

// In case of external reference : the leaf part is written in an external file
stepw_AddExternalReference ("Product", "SubPart.stp", ComponentID);

Declare the product for writing (repeated)

stepw_InitProduct("Product" ,ComponentID);

Specify the geometric link for external reference

// Specify this Product as Anchor
// And specify the anchor entities
int GeomID1 = ...;
stepw_AddAnchorItem ( GeomID1, ComponentID, "123");

Then write the content of the Product (repeated)

stepw_Init3DPart (ComponentID);
...
// Close the current part and the product
stepw_EndProduct(ComponentID);
// In this example, an intermediate sub-assembly is introduced
// in order to illustrate an instance path at several levels
int SubAssyID;

In case of nested external reference : the sub-assembly is written in an external file

stepw_AddExternalReference ("SubAssyProduct", "SubAssy.stp", SubAssyID);

Continue : Write the sub-assembly, the main assembly with its FDT(repeated)

// Write the sub-assembly itself
stepw_InitProduct("SubAssyProduct" ,SubAssyID);
int PartInstanceID;
int PartInstanceID; // instance ID returned by the STEP writer
int InstUserID1 = 1; // USER instance ID, provided by the user - must be unique
Dtk_string RD_1 ("RD_1"); // reference designator - will be written in STEP - must be unique in each STEP file
Dtk_InfoPtr PartInstanceInfo; // at least null - can be defined for attributes of the instance
Dtk_transfo PartTransformationMatrix = ...; // position of the part in the sub-assembly
stepw_AddInstance(SubAssyID,ComponentID, PartTransformationMatrix,"PartInstance", PartInstanceInfo, PartInstanceID,InstUserID1,RD_1);
stepw_Init3DPart(SubAssyID);
stepw_EndProduct(SubAssyID);
// The sub-assembly is now complete
// Write the assembly
// Start writing the product
int AssemblyID;
if (stepw_InitProduct("AssemblyProduct" ,AssemblyID))
return AssemblyID;
// Then add the instances of these components to the assembly
// here below, TransformationMatrix gives the relative position of the instance
int SubAssyInstanceID; // instance ID returned by the STEP writer
int InstUserID2 = 2; // USER instance ID
Dtk_string RD_2 ("RD_2"); // reference designator
Dtk_InfoPtr SubAssyInstanceInfo; // at least null - can be defined for attributes of the instance
Dtk_transfo SubTransformationMatrix = ...; // position of the sub-assembly in the main assembly
stepw_AddInstance(AssemblyID,SubAssyID, SubTransformationMatrix,"SubAssyInstance", SubAssyInstanceInfo, SubAssyInstanceID,InstUserID2,RD_2);
// When all the instances have been written :
// Write the part for this assembly, with its FDT in assembly, views if any ..
stepw_Init3DPart(AssemblyID);
// add the FDT in the product
int NodeID_FdtAssy = ..;
stepw_InitNodeContext (NodeID_FdtAssy);
Dtk_FdtPtr FdtAssy = ...;
stepw_Add3DPartFdt (FdtAssy);
// define the geometric link : firstly the geometric item itself
int GeomID1 = ..;
stepw_ER ElementReference_1;
stepw_CreateReference (ElementReference_1,GeomID1,ComponentID);
// then the instance path
stepw_ERP ElementReferencePath_1;
// 2 possible ways to define an instance path : use either
// legacy way : with stepw_CreateInstancePath
stepw_CreateInstancePath (ElementReferencePath_1);
stepw_AddInstanceToPath (ElementReferencePath_1,UserInstID2);
stepw_AddInstanceToPath (ElementReferencePath_1,UserInstID1);
// new way (from V2024.2)
// RefPath1 lists user instance IDs
Dtk_tab&lt;Dtk_ID&gt; RefPath1;
RefPath1.push_back(UserInstID2);
RefPath1.push_back(UserInstID1);
// here below : true if RefPath1 lists user instance IDs, false if RefPath1 lists instance IDs returned by stepw_AddInstance..
stepw_DefineInstancePath(ElementReferencePath_1, RefPath1, true);
// then set this reference path
stepw_SetReferencePath (ElementReference_1,ElementReferencePath_1);
// attach this link to the FDT
stepw_AddReference (ElementReference_1);
// Close the node of this FDT
// Finally, close the Product
stepw_EndProduct(AssemblyID);
return AssemblyID;



Annex A : Available modes for writing STEP files

Functions which set mode have a modal effect : the value of a setting is unchanged if the function is not called again.

Some functions apply to the writing itself : they must be called before stepw_InitFile which starts the writing session.

Some functions drive a general working mode : they can be called before or just after stepw_InitFile, but not after first specific call (starting by stepw_InitProduct).

Some functions can be called at any time, they apply on the following actions : the impacted actions are indicated. For instance, for a setting which is managed by stepw_InitProduct, its change applies on the calls to stepw_InitProduct which follow.

To be called before stepw_InitFile

  • Compression Mode. Function : stepw_SetModeCompress
// parameters and default values
int CompressMode = 0;
stepw_SetModeCompress (CompressMode); // 1 to activate compression mode, 0 to deactivate
  • Values of Header Fields. Function : stepw_SetHeaderData
// Value to be set : can be given as a basic string (char*) or a Dtk_string
char* value = "...";
or
Dtk_string value = "..."; // Can define an Unicode string
int num ..;
/*
num can have these values (one call per needed value) :
0 : Description
1 : Author
2 : Organization
3 : Originating System
4 : Authorization
*/
stepw_SetHeaderData (num, value);

To be called before or just after stepw_InitFile

  • Mode to write Names of individual items (bodies and their content : faces ..). Function : stepw_SetModeItemName
// parameters and default values
int ItemName = 0;
stepw_SetModeItemName(ItemName); // 0 : no name written - 1 : item names are written
// parameters and default values
int PropMode = 0;
stepw_SetModeProp (PropMode);
// 0 : no writing
// 1 : writing properties described as Dtk_val in the Dtk_Info's
// 2 : writing properties described as Dtk_MetaData attached to a product or a body (general case)
// 3 : writing properties as MetaData for special cases (see \ref stepw_annexe_C_metadata)
  • Mode to write FDT. Function : stepw_SetModeFdt

    Warning : this mode is under control of a licence. If the licence is not active, this function has no effect

// parameters and default values
int FdtMode = 0;
int FdtPolylineMode = 0;
stepw_SetModeFdt (FdtMode, FdtPolylineMode);
/*
FdtMode can have these values
0 (default) : don't write FDT in STEP
-1 : write FDT as graphics only
1 : write FDT as semantic (representation) and graphical (presentation)
(previous modes 2 and 3 are not longer used : 2 graphical only is now -1 , 3 semantic only is obsolete)
FdtPolylineMode can have these values, to write graphics of FDT
0 (default) : redirects to "polyline presentation", so like 2 (except where the selected STEP version is AP203E2 or AP214,
which enforces "character based" only in that case)
1 : from AP242E2, "minimal presentation" known as "placeholder" - with previous versions of STEP, acts as 0
2 : "polyline presentation" : all the graphical items are converted to polylines, written with common STEP entities
POLYLINE and CIRCLE, expressed in the 3D space
3 : "tessellated presentation (2D)" : same as 2 but with new tessellation entities of AP242, expressed in the
plane of the Dtk_Fdt
4 : "tessellated presentation (3D)" : same as 3 but expressed in the 3D space
5 : from AP242, "dual presentation = placeholder + tessellated 3D" : 2 presentations are written, then the reader selects one
(by default the tessellated 3D, or if it supports it the placeholder)
About versions of STEP :
If the version has not been specified, AP203E2 is selected. AP203E2 and AP214 have these limitations :
FdtPolylineMode can be only 0 (character based) 1 2 (polylines) , values 3 and 4 are interpreted as 2
If FdtMode = 1 (semantic + graphics), FdtPolylineMode can be only 0 (other values are ignored)
*/

Taken into account by folllowing calls to step_InitProduct

  • Setting Context : Units and/or 3D Tolerance. Functions stepw_SetContextUnit and stepw_SetContextTolerance
// Setting Units
int UnitLength = 0; // 0 : default
/*
UnitLength can have one of these values
0 : the default value : MM
1 : MM (as 0)
2 : CM
3 : M (meter)
4 : KM
5 : INCH
6 : FOOT
*/
int UnitAngle = 0; // 0 : default
/*
UnitAngle can have one of these values
0 : Radian (default)
1 : Degree
*/
SetContextUnit (UnitLength,UnitAngle);
// Setting Definition Tolerance for Geometries, also known as Tolerance
// The value may not be negative
double tol = 0.005; // default value
SetContextTolerance (tol);

Annex B : Writing data attached to a Dtk_Body and its content

Some data can be attached to the Body itself, added to geometry and topology. They are recorded in the Dtk_Info attached to the Dtk_Body itself and to each of its items. See the mapping table for details.

These data are :

  • Color : a color recorded in the Dtk_Info of the Dtk_Body itself is applied by default to all its content
  • for items with a different color, this color is written on them specifically
  • Style : for a wireframe, independent curves and points can have (in their Dtk_Info) additional data : curve style and thickness for a curve, point marker for a point.
  • Layer number if defined.
  • Invisibility if defined. REMARK : it is up to the caller to filter or not the invisible items. If they are written, they are with INVISIBILITY
  • Transparency if defined, from version 2014.3 - only with version AP242
  • Item Name : driven by the setting function stepw_SetModeItemName(0 or 1) : 0 to switch off, 1 to switch on
  • Attributes : this kind of data is described separately in Annex C below. Attributes in STEP have a specific form. Writing attributes can be switched on/off by calling the setting function stepw_SetModeProp(1 or 0).

The Annex C explains how to define attributes in the Dtk_Info to be written in STEP.


Annex C : Writing Attributes

STEP allows to attach properties to various kind of data : products, instances (in an assembly), bodies, items in bodies (like faces) ... These properties have definitions specific to STEP, explained here below.

To write properties attached to an item into STEP, they have to be recorded in its Dtk_Info, as Dtk_Val. So, for items which are given directly, their properties are taken from their Dtk_Info : bodies, faces, FDT, etc For items written with specific calls, additional functions allow to specify a Dtk_Info which brings the attributes to write.

In addition, Metadata ( class Dtk_Metadata ) can be attached to components or bodies, they concern high level attributes attached to a whole product or a whole body, including product data. Detailed in : Metadata.

Presentation of properties in STEP

STEP provides a general mechanism to attach properties to any item. Here is a simplified presentation, focused on the case of attributes.

Properties addressed in STEP this way can be

  • validation properties of any kind (geometrical, on assembly, on FDT, etc)
  • material properties (density, material designation)
  • user defined attributes

The type of value can be of any kind, in practice it can be

  • a text
  • a boolean value (from AP203E2 - previously, simulated by an integer 0/1 or rather a text TRUE/FALSE)
  • an integer value
  • a real value (no unit)
  • a dimensioned value, with simple, multiple, or combined unit(s) : length, area, volume, mass, density ..
  • a point
  • a list of points (for the case of cloud of points validation property)

A property can be attached to a large variety of STEP entities :

  • a whole component, here represented by a PRODUCT_DEFINITION_SHAPE
  • an instance (level one only), here represented by a NEXT_ASSEMBLY_USAGE_OCCURRENCE or a PRODUCT_DEFINITION_SHAPE
  • any type of REPRESENTATION_ITEM through a SHAPE_ASPECT : this then covers all the topological items (solids, shells, faces, etc), and now the new tessellation (in AP242)
  • an ANNOTATION; a FDT through its annotations (with a specific construct)
  • a view through the DRAUGHTING_MODEL which represents it (with a specific construct)
  • etc.. the list is extended at each enhancement of the coverage list (LOTAR/CAX-IF rules)

Properties are organized in sets of PROPERTY_DEFINITION, each of them having a list of properties represented by .. REPRESENTATION, finally the values of properties are items of the REPRESENTATION.

In practice, the matter is the NAMES of these different entities, rather than the organization of entities themselves : for instance, for geometric validation properties on a given solid, there is one PROPERTY_DEFINITION per property, its representation is named "volume" "surface area" etc.. respectively, rather than one PROPERTY_DEFINITION for all the geometric validation properties.

A property in STEP is identified by 3 terms :

  • global definition of the property, we can call it category - for instance "geometric validation property" - recorded in the PROPERTY_DEFINITION
  • name of the property itself - for instance "volume" - recorded in the REPRESENTATION - this name can be empty (hence, the name of the value is directly considered)
  • name of the value - for instance "volume measure" - recorded in each property item which brings a value
  • in addition, an item may have several properties with same names : examples, boints of bounding box, cloud of points

These 3 names are independent.

For instance with material designation, this property is a TEXT, definition name is "material property", representation name is "material name", while item name provides the Material ID (in a database) and its value is a TEXT which provides the common name.

Properties in STEP : Mapping with Datakit structures (Dtk_Info)

As a conclusion

  • a STEP property can be mapped to any kind of entity, not only a Dtk_Component or a Dtk_Node
  • a STEP property has a name in 3 parts : definition, representation, item
  • a STEP property can have various types of values, including dimensioned values (length, areas, density ..), point

Rules of grouping : for a given entity, properties with same names for definition and representation (which can empty) are gathered in STEP in a same property set.

Letting aside the case of cloud of points, this is well mapped as follows :

  • a property is mapped to a Dtk_Val recorded in the Dtk_Info of the entity
  • its title is organised in 3 parts, separated by columns, for instance "geometric validation property : volume : volume measure", or "pmi validation property : : number of annotations" (here, representation name is empty)
  • for an item with several properties with same names, a 4th part distinguishes them, it is free form and ignored when writing (because the Dtk_Info has one possible property for each complete name; example : bounding box corner point, there are 2)
  • its value can be
    • for a text : text
    • for an integer : integer
    • for a boolean : character 1 or 0
    • for a real, no unit : real
    • for a real with unit(s) : text "value unit" , for instance "17.5 mm" for a length, "300. mm3" for a volume, "7.89 g/cm3" for a density
    • allowed units : "mm" "cm" "m" "km" "in" "ft" , "kg" "g" "lb" , derived units : "mm2" "mm3" "kg/mm2"
    • for a point : Dtk_Pnt The case of cloud of points is not yet implemented, the need is to attach a list of points to each face and each edge.

Examples of property name, defined in the Title of the Dtk_Val :

  • "material property : density : density measure"
  • "geometric validation property : volume : volume measure" (old form)
  • "geometric validation property : : volume measure" (from AP242 - the representation name is empty, it must be present as ": :")
  • "geometric validation property : : bounding box corner point : 1" (bounding box : one of the 2 points - the additional num, here "1" is ignored on writing, it allow to keep it distinct it in the Dtk_Info)

Metadata are reserved for really general informations (like data for PDM, etc, attached to a Product).

Properties in STEP : Writing (Dtk_Info)

For various types of entities, it's enough to fill the Dtk_Info of the entity, the STEP writer then gets them for writing :

  • topological items (volume shell face edge vertex) : their Dtk_Info
  • tessellation : the Dtk_Info of the Dtk_mesh
  • views : the Dtk_Info of the Dtk_FdtCapture / Dtk_ModelDisplay (attached to the DRAUGHTING_MODEL for this capture)
  • FDT : the Dtk_Info of the Dtk_Fdt
  • components and instances : dedicated call forms, see below

For a component (leaf or assembly node), the Dtk_Info has to be explicitly given to the STEP writer, 2 possible attachments :

Here below, info is a Dtk_Info

int what ..; // 1 for the PRODUCT_DEFINITION_SHAPE, 2 for the PRODUCT_DEFINITION,
// 0 : for validation properties only, dispatched according to recommended practices (otherwise it is on the PDS)

For an instance, the Dtk_Info has to be explicitly given to the STEP writer, with a variant of AddInstance in replacement of stepw_AddInstance, with the Dtk_Info as additional parameter.

stepw_AddInstanceWithInfo (IDfather,IDchild, position, instancename, info);

Properties are attached to the NAUO or to the PDS, according to the recommended practices for validation properties, otherwise it is on the NAUO.

Only the Dtk_Val with title defined as "definition : representation : item" (like "geometric validation property : volume : volume measure") or "definition : representation : item : num" (with different "num", to have several properties with same names) are written to STEP properties.

Metadata

Metadata can be used to describe attributes of various kinds attached to products or bodies.

By default, Metadata are attached to products. It is possible to attach them to sub-parts of a product.

For STEP writing, there are are several kinds of metadata, according to their TYPE of MetaData, and to their TITLE. This is why a specific setting allows the user to filter the writing of properties as metadata : by calling stepw_SetModeProp.

  • Product data : attributes embedded in the definition of a product, they are recognized by their TITLE (for the type of MetaData, recommendation is TypeConfigurationProperty) :
    • "Nomenclature" : the usual name of a product, versus its identification, given to stepw_InitProduct, by default it is considered as equal to the name of the product
    • "Description" : a (free form) text for the description of the product
    • "Definition" : a (free form) text for the definition of the product
    • "Revision" : a text to specify the revision status of the product, by default it is empty
    • "Document" : an associated document for the product
    • "Source" : if defined, specifies if a product is Bought or Made, otherwise Unknown; value can be "Bought" or "Made"
  • Other MetaData, with type different from TypeFileProperty or TypeUnknown : they are written as individual properties attached to the product, the totle of the metadata defines the global definition of the property, while property name and value name are written empty
  • MetaData of type TypeFileProperty or TypeUnknown : they need a specific value for stepw_SetModeProp, but they are written the same way as other MetaData

To write MetaData, firstly activate the writing mode, can be done before or just after each call to stepw_InitProduct :

// 0 : no writing
// 1 : writing properties described as Dtk_val in the Dtk_Info's
// 2 : writing properties described as Dtk_MetaData attached to a product or a Body (general case)
// 3 : writing properties as MetaData for all cases (including type TypeFileProperty or TypeUnknown)

Then specify to which item the Metadata is attached.

  • By default, it is the product in which the Metadata is written , by calling stepw_Add3dPartMetaData (see hereafter) between stepw_Init3DPart and stepw_End3DPart. For Product Data, just after stepw_Init3DPart.
  • It is possible to attach a group of Metadata to a Body :
    • call stepw_InitPropertySet to attach MetaData to the next Body to be written, to be done before each Body with MetaData
    • record the MetaData(s) to be attached to it
    • write the Body or the Mesh
    • the Property Set is then switched to the default, i.e. attachment to the Product

To record the MetaData to the Product being written, the call is to be done just after the call to stepw_Init3DPart :

Dtk_MetaDataPtr metadata = ...; // the metadata to be written
stepw_Add3dPartMetaData (metadata);

To record the MetaData to the next Body or Mesh to be written :

stepw_InitPropertySet(1); // 1 for next body or mesh, 0 for the product (default value)
..
Dtk_MetaDataPtr metadata = ...; // the metadata to be written
stepw_Add3dPartMetaData (metadata);
..
.. or

Once the body or mesh has been written, the effect of stepw_InitPropertySet is over. Coming Metadata will then be attached to the product, unless stepw_InitPropertySet is called again.



Full Sample.

This example calls functions used for creation of bodies and FDT which are not here (they are general) :

  • Create Cube : creation of a Cube solid - with some validation properties (fake values), colors
  • CreateOpenShell : creation of a shell with just one surface (cylindrical)
  • CreateCurves : creation of a wireframe
  • CreateCylinder : creation of a Cylinder solid
  • CreateConstructionPlane : creation of a shell with just one surface, an infinite plane (used for construction geometries)
  • CreateFdtDatum : creation of a Datum attached on a face of the Cube
  • CreateFdtDimAssy ; creation of a Dimension in an assembly, between 2 faces of 2 different instances of the Cube in the Assembly
  • CreateView : creation of a ModelDisplay
  • CreateAxisSystem : creation of an Axis System
/*********************************************************/
/****
Writing a Product : a Part or an Assembly
Also with example of writing ATTRIBUTES attached at level of the Product , Part or Assembly
In particular, VALIDATION PROPERTIES
*/
//start_of_mainstepwrite
//This sample show you how to write a body with an unbounded surface and wireframe entity.
// IFDT = 1 to also write FDT, View, etc - 0 none
// IFDT = 2 to use this Part by a FDT in Assembly (needs to declare ANCHOR entities)
int WritePart(const Dtk_string& inReferenceName, const int ifdt)
{
// We construct a body
// TEST : adding wireframe
//You init the Part writer
int PartID;
return PartID;
// Following is required for writing of FDT with geometric links - either inside the Part or external designating anchors
// To be called before starting the part
stepw_SetAnchorProduct(PartID,PartID);
// IFDT = 2 : declaring some entities as ANCHOR for a FDT in Assembly
// This is needed where the Assembly is written in several files
if (ifdt == 2) {
int geomid1 = 73;
Dtk_string anchor1("73");
stepw_AddAnchorItem(geomid1,PartID,anchor1);
int geomid2 = 33;
Dtk_string anchor2("33");
stepw_AddAnchorItem(geomid2,PartID,anchor2);
}
// test : properties defined as Metadata (at part level)
stepw_Init3DPart (PartID);
// test : properties at part level - on the product_definition_shape
// test : validation properties - AP242 form (no intermediate name)
Dtk_Val valprop_area("1234 mm2");
part_info->AddAttribute("geometric validation property : : surface area measure",valprop_area);
Dtk_Val valprop_volume("5678 mm3");
part_info->AddAttribute("geometric validation property : : volume measure",valprop_volume);
Dtk_Val valprop_CG (Dtk_pnt(12.,34.,56.));
part_info->AddAttribute("geometric validation property : : centre point",valprop_CG);
// test : properties at part level - on the product_definition
Dtk_Val mat_name("Steel YC38");
prod_info->AddAttribute("material property : material name : Steel",mat_name);
Dtk_Val mat_density("7.89 g/cm3");
prod_info->AddAttribute("material property : density : density measure",mat_density);
// And we write body in the step file
stepw_Write3DPartBody (sbody); // test wire frame
// IFDT = 1 : writing a FDT within the Part (here, a Datum)
if (ifdt == 1) {
// Test Write FDT
int NodeID_Fdt1 = 101;
stepw_InitNodeContext (NodeID_Fdt1);
// Then write the geometrical links : within the same Part
int geomid1 = 73;
stepw_ER ElementReference_1;
stepw_CreateReference (ElementReference_1,geomid1);
stepw_AddReference (ElementReference_1);
// Test Write View
int NodeID_View1 = 201;
stepw_InitNodeContext (NodeID_View1);
stepw_AddReferenceToNode (NodeID_Fdt1);
// Test Construction Geometries & Axis System
}
// Close the current part
return PartID;
}
// Another Part, to test other data - with colors and tessellation
// itessel = 0 or 1 : body only
// itessel = 2 : tessellation only
// itessel = 3 : body + tessellation
int WritePartCyl(const Dtk_string& inReferenceName, const int itessel)
{
// We construct a body : a cylinder
//You init the Part writer
int PartID;
return PartID;
// Following is required for writing of FDT with geometric links
// To be called before starting the part
stepw_SetAnchorProduct(PartID,PartID);
stepw_Init3DPart (PartID);
// test : properties at part level - on the product_definition_shape
// test : validation properties - AP242 form (no intermediate name)
Dtk_Val valprop_area("1234 mm2");
part_info->AddAttribute("geometric validation property : : surface area measure",valprop_area);
Dtk_Val valprop_volume("5678 mm3");
part_info->AddAttribute("geometric validation property : : volume measure",valprop_volume);
Dtk_Val valprop_CG (Dtk_pnt(12.,34.,56.));
part_info->AddAttribute("geometric validation property : : centre point",valprop_CG);
// test : properties at part level - on the product_definition
// Test of Tessellation - NOT RECOMMENDED ON VERSIONS STEP BEFORE AP242
// To get the functions of tessellation : tess/tess.h
Dtk_bool TessWireframe=false;
tess_InitTesselation("E:\\temp\\",0.2);
tess_BodyToMeshes (body,listMesh,IsSolid,TessWireframe);
int nbmesh = listMesh.size();
if (nbmesh >= 1)
mesh = listMesh[0];
// Writing Tessellation
// Option 1 : Tessellation "alone" i.e. not linked to the body
// we write body in the step file, then the tessellation separately
if (itessel <= 1) stepw_Write3DPartBody (body);
if (itessel == 2) stepw_Write3DPartMesh (mesh);
if (itessel == 3) stepw_Write3DPartBodyWithMesh(body,mesh);
// Close the current part
return PartID;
}
/*
Variants of writing an assembly
All write an assembly the same way, but the variants focus on a specific capability (not all together for more clarity)
WriteAsm is the basic variant, completed with validation properties and user attributes on the assembly or items of it
*/
void WriteAsm()
{
int status = 0;
Dtk_transfo TransformationMatrix0,TransformationMatrix1,TransformationMatrix2;
Dtk_pnt orig1; orig1[0] = orig1[1] = 0.; orig1[2] = 200.;
Dtk_pnt orig2; orig2[0] = orig2[2] = 0.; orig2[1] = 300.;
TransformationMatrix1.setOrigin(orig1);
TransformationMatrix2.setOrigin(orig2);
//The ProcessPart is an user implemented function to create a part
int PartID = WritePart(L"essaiPart",0);
int ProdID,ProdID2;
//we init a product context in STEP : sub-assembly ...
status = stepw_InitProduct (L"SubProduct", ProdID2);
//...to insert a Part instance of "essaiPart"
status = stepw_AddInstance(ProdID2,PartID, TransformationMatrix0,"PartInstance");
// test : validation properties - AP242 form (no intermediate name)
Dtk_Val valprop_notional_CG (Dtk_pnt(10.,20.,30.));
part_info->AddAttribute("assembly validation property : : centre point",valprop_notional_CG);
Dtk_Val valprop_nbchildren(3);
prod_info->AddAttribute("assembly validation property : : number of children",valprop_nbchildren);
// the part for the sub-assembly is REQUIRED - assembly node : created empty
status = stepw_Init3DPart(ProdID2);
status = stepw_End3DPart();
//we close the CATProduct context and retrieve the resulting DocID
status = stepw_EndProduct(ProdID2);
//we create another assembly node (main assembly)
status = stepw_InitProduct (L"RootProduct", ProdID);
//and we insert another time the a part instance - multinstancing management -
// test : instance with property
Dtk_InfoPtr instance_info = Dtk_Info::create();
Dtk_Val instance_kind("first");
instance_info->AddAttribute("user defined attribute : : instance kind",instance_kind);
Dtk_Val instance_valprop(1);
instance_info->AddAttribute("attribute validation property : : text user attributes",instance_valprop);
// status = stepw_AddInstance(ProdID, PartID, TransformationMatrix0,"PartInstance");
status = stepw_AddInstanceWithInfo(ProdID, PartID, TransformationMatrix0,"PartInstance",instance_info);
//and two instances to the first sub-assembly
status = stepw_AddInstance(ProdID, ProdID2, TransformationMatrix1,"PartInstance1");
status = stepw_AddInstance(ProdID, ProdID2, TransformationMatrix2,"PartInstance2");
//finally we close the second assembly (root) ...
// the part for the sub-assembly is REQUIRED - assembly node : created empty
status = stepw_Init3DPart(ProdID);
status = stepw_End3DPart();
//we close the CATProduct context and retrieve the resulting DocID
status = stepw_EndProduct(ProdID);
}
/****
Variant to write the different products in several files
Similar to WriteAsm (just duplicated), with differences of external files : calls to stepw_AddExternalReference
level = 0 : monolithic file (so, like WriteAsm)
level = 1 : basic external references, only the leaf parts are written separately
level = 2 : nested external references, each component is written separately
Warning : these are the only allowed combinations, others may be not or bad supported by readers
asm_only = 0 : complete mode, all components (assemblies and leaf part) are written - monolithic writing is always complete
asm_only = 1 : only assemblies are written, part are declared as external products but not written
*/
void WriteAsmExt(const int level, const int asm_only)
{
int status = 0;
Dtk_transfo TransformationMatrix0,TransformationMatrix1,TransformationMatrix2;
Dtk_pnt orig1; orig1[0] = orig1[1] = 0.; orig1[2] = 200.;
Dtk_pnt orig2; orig2[0] = orig2[2] = 0.; orig2[1] = 300.;
TransformationMatrix1.setOrigin(orig1);
TransformationMatrix2.setOrigin(orig2);
//The ProcessPart is an user implemented function to create a part
// Option to write the Part as external file
int PartID;
if (level) stepw_AddExternalReference(L"essaiPart",L"RootPart.step",PartID);
//with external references, it is possible to declare parts as external products but not write them
// Each product is identified by its NAME - there is a unique equivalence between Product Name and returned vale of ProdID
if (!asm_only || level == 0)
PartID = WritePart(L"essaiPart",0);
int ProdID,ProdID2;
//we init a product context in STEP : sub-assembly ...
// Option to write the sub-assembly as external file
if (level > 1) stepw_AddExternalReference(L"SubProduct",L"RootSubAssy.step",ProdID2);
status = stepw_InitProduct (L"SubProduct", ProdID2);
//...to insert a Part instance of "essaiPart"
status = stepw_AddInstance(ProdID2,PartID, TransformationMatrix0,"PartInstance");
// test : validation properties - AP242 form (no intermediate name)
Dtk_Val valprop_notional_CG (Dtk_pnt(10.,20.,30.));
part_info->AddAttribute("assembly validation property : : centre point",valprop_notional_CG);
Dtk_Val valprop_nbchildren(3);
prod_info->AddAttribute("assembly validation property : : number of children",valprop_nbchildren);
// the part for the sub-assembly is REQUIRED - assembly node : created empty
status = stepw_Init3DPart(ProdID2);
status = stepw_End3DPart();
//we close the CATProduct context and retrieve the resulting DocID
status = stepw_EndProduct(ProdID2);
//we create another assembly node (main assembly)
status = stepw_InitProduct (L"RootProduct", ProdID);
//and we insert another time the a part instance - multinstancing management -
// test : instance with property
Dtk_InfoPtr instance_info = Dtk_Info::create();
Dtk_Val instance_kind("first");
instance_info->AddAttribute("user defined attribute : : instance kind",instance_kind);
Dtk_Val instance_valprop(1);
instance_info->AddAttribute("attribute validation property : : text user attributes",instance_valprop);
// status = stepw_AddInstance(ProdID, PartID, TransformationMatrix0,"PartInstance");
status = stepw_AddInstanceWithInfo(ProdID, PartID, TransformationMatrix0,"PartInstance",instance_info);
//and two instances to the first sub-assembly
status = stepw_AddInstance(ProdID, ProdID2, TransformationMatrix1,"PartInstance1");
status = stepw_AddInstance(ProdID, ProdID2, TransformationMatrix2,"PartInstance2");
//finally we close the second assembly (root) ...
// the part for the sub-assembly is REQUIRED - assembly node : created empty
status = stepw_Init3DPart(ProdID);
status = stepw_End3DPart();
//we close the CATProduct context and retrieve the resulting DocID
status = stepw_EndProduct(ProdID);
}
/****
Variant to write an assembly with a FDT at assembly level - monolithic or with external references
Similar to WriteAsmExt (just duplicated),including external files, but with a FDT in more, and validation properties in less
level = 0 : monolithic file (so, like WriteAsm)
level = 1 : basic external references, only the leaf parts are written separately
level = 2 : nested external references, each component is written separately
Warning : these are the only allowed combinations, others may be not or bad supported by readers
*/
void WriteAsmFdt(const int level)
{
int status = 0;
Dtk_transfo TransformationMatrix0,TransformationMatrix1,TransformationMatrix2;
Dtk_pnt orig1; orig1[0] = orig1[1] = 0.; orig1[2] = 200.;
Dtk_pnt orig2; orig2[0] = orig2[2] = 0.; orig2[1] = 300.;
TransformationMatrix1.setOrigin(orig1);
TransformationMatrix2.setOrigin(orig2);
//The ProcessPart is an user implemented function to create a part
// Option to write the Part as external file, with anchors entities for the FDT
int PartID;
if (level) stepw_AddExternalReference(L"essaiPart",L"RootPart.step",PartID);
PartID = WritePart(L"essaiPart",2);
int ProdID,ProdID2;
//we init a product context in STEP : sub-assembly ...
// Option to write the sub-assembly as external file
// To write FDT, Instances must have a user identifier
Dtk_InfoPtr instance_info = Dtk_Info::create();
if (level > 1) stepw_AddExternalReference(L"SubProduct",L"RootSubAssy.step",ProdID2);
status = stepw_InitProduct (L"SubProduct", ProdID2);
//...to insert a Part instance of "essaiPart"
int InstID1,InstID2,InstID3,InstID4;
int UserInstID1 = 1, UserInstID2 = 2, UserInstID3 = 3, UserInstID4 = 4;
status = stepw_AddInstanceWithInfo(ProdID2,PartID, TransformationMatrix0,"PartInstance",instance_info,InstID1,UserInstID1,"RD1");
// the part for the sub-assembly is REQUIRED - assembly node : created empty
status = stepw_Init3DPart(ProdID2);
status = stepw_End3DPart();
//we close the CATProduct context and retrieve the resulting DocID
status = stepw_EndProduct(ProdID2);
//we create another assembly node (main assembly)
status = stepw_InitProduct (L"RootProduct", ProdID);
//and we insert another time the a part instance - multinstancing management -
// status = stepw_AddInstance(ProdID, PartID, TransformationMatrix0,"PartInstance");
status = stepw_AddInstanceWithInfo(ProdID, PartID, TransformationMatrix0,"PartInstance",instance_info,InstID2,UserInstID2,"RD2");
//and two instances to the first sub-assembly
status = stepw_AddInstanceWithInfo(ProdID, ProdID2, TransformationMatrix1,"PartInstance1",instance_info,InstID3,UserInstID3,"RD3");
status = stepw_AddInstanceWithInfo(ProdID, ProdID2, TransformationMatrix2,"PartInstance2",instance_info,InstID4,UserInstID4,"RD4");
//finally we close the second assembly (root) ...
// the part for the sub-assembly is REQUIRED - assembly node : created empty
status = stepw_Init3DPart(ProdID);
// Here is the specifics of this variant : writing a FDT at assembly level
int NodeID_FdtAsm = 301;
stepw_InitNodeContext (NodeID_FdtAsm);
// Then write the geometrical links : within the same Part
int geomid1 = 73;
stepw_ER ElementReference_1;
stepw_ERP ElementReferencePath_1;
// 2 possible ways to define an instance path : use either
// legacy way : with stepw_CreateInstancePath
stepw_CreateInstancePath(ElementReferencePath_1);
stepw_AddInstanceToPath(ElementReferencePath_1,UserInstID2);
// new way (from V2024.2)
// RefPath1 lists user instance IDs
Dtk_tab&lt;Dtk_ID&gt; RefPath1;
RefPath1.push_back(UserInstID2);
// here below : true if RefPath1 lists user instance IDs, false if RefPath1 lists instance IDs returned by stepw_AddInstance..
stepw_DefineInstancePath(ElementReferencePath_1, RefPath1, true);
// then set this reference path
stepw_CreateReference (ElementReference_1,geomid1,PartID);
stepw_SetReferencePath (ElementReference_1,ElementReferencePath_1);
stepw_AddReference (ElementReference_1);
int geomid2 = 33;
stepw_ER ElementReference_2;
stepw_ERP ElementReferencePath_2;
// 2 possible ways to define an instance path : use either
// legacy way : with stepw_CreateInstancePath
stepw_CreateInstancePath(ElementReferencePath_2);
stepw_AddInstanceToPath(ElementReferencePath_2,UserInstID4);
stepw_AddInstanceToPath(ElementReferencePath_2,UserInstID1);
// new way (from V2024.2)
// RefPath2 lists user instance IDs
Dtk_tab&lt;Dtk_ID&gt; RefPath2;
RefPath2.push_back(UserInstID4);
RefPath2.push_back(UserInstID1);
// here below : true if RefPath2 lists user instance IDs, false if RefPath2 lists instance IDs returned by stepw_AddInstance..
stepw_DefineInstancePath(ElementReferencePath_2, RefPath2, true);
// then set this reference path
stepw_CreateReference (ElementReference_2,geomid2,PartID);
stepw_SetReferencePath (ElementReference_2,ElementReferencePath_2);
stepw_AddReference (ElementReference_2);
status = stepw_End3DPart();
//we close the CATProduct context and retrieve the resulting DocID
status = stepw_EndProduct(ProdID);
}
/****
Main routine of writing a STEP file
- Opening and Closing of the File
- (writing of content between the 2)
- Global Settings
*/
/**** mainstep0 : writing all in one file ****/
int
mainstep0()
{
//Step write start here
Dtk_ErrorStatus errorStatus = dtkNoError;
Dtk_API * MyAPI = Dtk_API::StartAPI("..\\..\\SampleFiles\\dtk\\", errorStatus);
if(MyAPI == NULL)
{
printf("Can't Start DATAKIT API\n");
//return dtkErrorAPINotStarted;
}
// First we initialize writing with name of files and protection function
// First you have to initialize the Step writer
// StepVersion 4 is for AP242 (Edition 1)
int status = stepw_InitFile( L"..\\..\\SampleFiles\\dtk\\RootProduct.step", " sample " , 4);
if (status)
{
printf("erreur : %s\n", dtkTypeError(status).c_str());
return status;
}
// Test :
// WritePartCyl for just one part (cylinder) with tessellation
// WritePart for just one part (cube) with properties, with or without FDT (2nd argument = 1 to have FDT, 0 none)
// WriteAsm for an assembly (all in one file)
// WriteAsmExt for an assembly in several files - complete or assembly only
// WriteAsmFdt for an assembly with FDT at assembly level - monolithic or in several files
// WritePartCyl("CylPart",2);
// WritePart("onlyonePart",1); // 1 : with FDT
// WriteAsm();
WriteAsmExt(2,0); // level=2 : nested external references - asm_only=0 : complete writing including leaf parts
// WriteAsmFdt(2);
//...and the Main writer
//At the end you stop DATAKIT API
return 0;
}
//end_of_mainstepwrite
stepw_AddInstanceWithInfo
DtkErrorStatus stepw_AddInstanceWithInfo(const int inIDfather, const int inIDchild, const Dtk_transfo &inPosition, const Dtk_string &inInstanceName, const Dtk_InfoPtr &inInstanceInfo)
Adds an instance of a sub-component (child) in a product (father : assembly node)
stepw_CreateReference
DtkErrorStatus stepw_CreateReference(stepw_ER &ER, const int inEntityID)
Dtk_ID
uint32_t Dtk_ID
Definition: define.h:689
stepw_AddInstance
DtkErrorStatus stepw_AddInstance(const int inIDfather, const int inIDchild, const Dtk_transfo &inPosition, const Dtk_string &inInstanceName)
Adds an instance of a sub-component (child) in a product (father : assembly node)
Dtk_transfo
This is the Transformation dedicated class.
Definition: dtk_transfo.hpp:19
Dtk_Info::AddAttribute
Dtk_ErrorStatus AddAttribute(Dtk_string name, Dtk_Val val)
stepw_Init3DPart
DtkErrorStatus stepw_Init3DPart(const int inID)
Initialise the writing of a 3D part : the own 3D part of a product (NOT its sub-components if any !...
stepw_DefineInstancePath
Dtk_ErrorStatus stepw_DefineInstancePath(stepw_ERP &ERP, const Dtk_tab< Dtk_ID > &inInstancePath, const bool userid)
stepw_SetReferencePath
DtkErrorStatus stepw_SetReferencePath(stepw_ER &ER, stepw_ERP &ERP)
Dtk_transfo::setOrigin
void setOrigin(const Dtk_pnt &O)
Set a new O center point.
Dtk_API::StartAPI
static Dtk_API * StartAPI(const Dtk_string &inTemporyDirectory, Dtk_ErrorStatus &outErrorCode, const Dtk_string &inCustomerID=Dtk_string())
Start DATAKIT API.
stepw_Write3DConstructionGeometry
DtkErrorStatus stepw_Write3DConstructionGeometry(const Dtk_BodyPtr &inBody)
Writes a Body as a Construction Geometry of a 3D part, of any kind (solid, shell / faces,...
stepw_ERP
Definition: stepw.hpp:394
stepw_SetModeFdt
DtkErrorStatus stepw_SetModeFdt(const int inMode, const int inPolyline=0)
Activates/Deactivates writing of FDT (ignored if product Step3dWriteFdt is not present)
stepw_Write3DPartMesh
DtkErrorStatus stepw_Write3DPartMesh(const Dtk_MeshPtr &inMesh)
Writes a Mesh of a 3D part (3D content of a product).
stepw_SetContextTolerance
Dtk_ErrorStatus stepw_SetContextTolerance(const double inTol)
Modal setting of Length Tolerance for the 3D geometry (uncertainty) To be called before Init3dPart,...
Dtk_string
This is a high level string class.
Definition: dtk_string.hpp:58
stepw_InitProduct
DtkErrorStatus stepw_InitProduct(const Dtk_string &inProductName, int &outID, Dtk_ID inCompID=0)
Initialise the writing of a product (assembly node and/or part with 3D bodies)
Dtk_bool
char Dtk_bool
Definition: define.h:725
WritePartCyl
int WritePartCyl(const Dtk_string &inReferenceName, const int itessel)
Definition: testlibstepwrite.cpp:204
stepw_AddReference
DtkErrorStatus stepw_AddReference(stepw_ER &ER)
stepw_Write3DPartBody
DtkErrorStatus stepw_Write3DPartBody(const Dtk_BodyPtr &inBody)
Writes a Body of a 3D part (3D content of a product), of any kind (solid, shell / faces,...
stepw_Write3DPartBodyWithMesh
DtkErrorStatus stepw_Write3DPartBodyWithMesh(const Dtk_BodyPtr &inBody, const Dtk_MeshPtr &inMesh, const int inMode=0)
Writes a Body of a 3D part (3D content of a product), associated with a Mesh \ brief The Mesh is assu...
tess_InitTesselation
int tess_InitTesselation(Dtk_string inWorkingDirectory, double inTolerance)
Init the tesselation library.
stepw_SetAnchorProduct
DtkErrorStatus stepw_SetAnchorProduct(const int stepw_ID, const int user_ID)
stepw_EndProduct
DtkErrorStatus stepw_EndProduct(const int inID)
Ends the writing of a product - calls WriteAssemblyInstances if not yet done.
stepw_SetModeProp
DtkErrorStatus stepw_SetModeProp(const int inMode)
Activates/Deactivates writing of Properties : User Attributes, Product Data.
Dtk_Val
Definition: dtk_val.hpp:67
stepw_Write3DPartMeshFromBody
DtkErrorStatus stepw_Write3DPartMeshFromBody(const Dtk_MeshPtr &inMesh, const Dtk_BodyPtr &inBody)
Writes a Mesh of a 3D part (3D content of a product), coming from a Body, BUT does not write the Body...
stepw_GiveUniqueFileName
Dtk_string stepw_GiveUniqueFileName(const Dtk_string &inFileName)
Creates a unique file name for an external reference - applies to the current session (InitFile-EndFi...
stepw_Add3DPartProperty
Dtk_ErrorStatus stepw_Add3DPartProperty(const Dtk_MetaDataPtr &inProperty)
Commands to write a Property to a Part (at the level of the whole Part) by default,...
catiav5w::inReferenceName
const Dtk_string & inReferenceName
Definition: catiav5w.hpp:456
stepw_CreateInstancePath
DtkErrorStatus stepw_CreateInstancePath(stepw_ERP &ERP)
sampleWriter::CreateFdtDimAssy
Dtk_FdtPtr CreateFdtDimAssy()
PMI in Assembly : a dimension between faces of different instances.
Definition: testcreatefdt.cpp:118
stepw_AddExternalReference
Dtk_ErrorStatus stepw_AddExternalReference(const Dtk_string &inProductName, const Dtk_string &inFileName, int &outID, Dtk_ID inInstCompId=0)
Declares a product to be written as external reference.
sampleWriter::CreateFdtDatum
Dtk_FdtPtr CreateFdtDatum()
Create Simple Datum.
Definition: testcreatefdt.cpp:19
Dtk_MetaData::TypeConfigurationProperty
@ TypeConfigurationProperty
Definition: dtk_metadata.hpp:30
stepw_CreateReferenceToNode
DtkErrorStatus stepw_CreateReferenceToNode(stepw_ER &ER, const int inNodeID, const int inProductID, const char *inRefKind="")
Dtk_MetaData::TypeProperty
@ TypeProperty
Definition: dtk_metadata.hpp:28
stepw_Add3DPartFDT
DtkErrorStatus stepw_Add3DPartFDT(const Dtk_FdtPtr &inFDT)
Commands to write a FDT of a 3D Part.
Dtk_ErrorStatus
Dtk_ErrorStatus
Definition: error_dtk.hpp:6
sampleWriter::CreateConstructionPlane
Dtk_BodyPtr CreateConstructionPlane()
Definition: testcreatecylfdt.cpp:1185
stepw_SetPartProperties
DtkErrorStatus stepw_SetPartProperties(const Dtk_InfoPtr &inInfo, const int inItem)
Defines properties to be attached directly to the component : considers the list of Dtk_Val in the Dt...
stepw_SetModeItemName
DtkErrorStatus stepw_SetModeItemName(const int inMode)
Selects a mode of writing names of internal (topological) 3D items (shells, faces,...
Dtk_SmartPtr
Definition: util_ptr_dtk.hpp:37
stepw_EndFile
DtkErrorStatus stepw_EndFile()
Ends the writing of the STEP file.
dtkTypeError
Dtk_string dtkTypeError(Dtk_Int32 errNumero)
stepw_End3DPart
DtkErrorStatus stepw_End3DPart()
Ends the writing of a part : the own 3D part of a product + product definition.
stepw_Write3DAxisSystem
DtkErrorStatus stepw_Write3DAxisSystem(const Dtk_AxisSystemPtr &inAxis)
Writes an Axis System of a 3D part - in STEP it is a construction geometry based on an axis placement...
CreateAxisSystem
Dtk_AxisSystemPtr CreateAxisSystem()
Definition: testlibstepwrite.cpp:80
WritePart
int WritePart(const Dtk_string &inReferenceName, const int ifdt)
Definition: testlibstepwrite.cpp:95
Dtk_pnt
This is a mathematical point class.
Definition: dtk_pnt.hpp:22
stepw_Add3DModelDisplay
Dtk_ErrorStatus stepw_Add3DModelDisplay(const Dtk_ModelDisplayPtr &inModelDisplay, const int inMode)
Commands to write a Model Display (type Dtk_ModelDisplay) in a 3d Part.
stepw_AddAnchorItem
Dtk_ErrorStatus stepw_AddAnchorItem(const int inEntityID, const int inProductID, const Dtk_string &inGUID)
stepw_InitFile
DtkErrorStatus stepw_InitFile(const Dtk_string &inFileOut, const char *Origin=" user ", const int StepSchema=0)
Initialise a file to be written.
tess_BodyToMeshes
Dtk_ErrorStatus tess_BodyToMeshes(const Dtk_BodyPtr &inBodyToWrite, Dtk_tab< Dtk_MeshPtr > &outMeshes, Dtk_tab< Dtk_Int32 > &outIsSolid, Dtk_bool inTessWireframe=DTK_FALSE, Dtk_bool inApplyRenderInfos=DTK_FALSE)
: Make Tesselation from a Dtk_body and create a Set of Dtk_mesh if available
stepw_SetContextUnit
Dtk_ErrorStatus stepw_SetContextUnit(const int inLength, const int inAngle=0)
Modal setting of Units in which the geometries, properties, .. are to be written. To be called before...
Dtk_tab
This is a high level array class.
Definition: util_stl_dtk.hpp:85
stepw_ER
Definition: stepw.hpp:387
sampleWriter::CreateCube
Dtk_BodyPtr CreateCube()
Definition: testcreatecube.cpp:1249
Dtk_tab::size
Dtk_Size_t size() const
Returns the size of the array.
Definition: util_stl_dtk.hpp:502
stepw_AddInstanceToPath
DtkErrorStatus stepw_AddInstanceToPath(stepw_ERP &ERP, const int inInstanceID)
stepw_SetHeaderData
DtkErrorStatus stepw_SetHeaderData(const int inNumItem, const wchar_t *inValItem)
Sets values of fields in Header.
Dtk_API::StopAPI
static void StopAPI(Dtk_API *&inAPI, Dtk_bool inWriteTimeInLog=1)
Stop DATAKIT API.
CreateView
Dtk_ModelDisplayPtr CreateView()
Definition: testlibstepwrite.cpp:39
stepw_SetModeCompress
DtkErrorStatus stepw_SetModeCompress(const int inMode)
Selects a mode of writing compact or compressed step files.
sampleWriter::CreateCylinder
Dtk_BodyPtr CreateCylinder()
Definition: testcreatecylfdt.cpp:1211
WriteAsm
void WriteAsm()
Definition: testlibstepwrite.cpp:270
sampleWriter::CreateCurves
Dtk_BodyPtr CreateCurves()
Definition: testcreatecube.cpp:1292
WriteAsmExt
void WriteAsmExt(const int level, const int asm_only)
Definition: testlibstepwrite.cpp:346
dtkNoError
@ dtkNoError
Definition: error_dtk.hpp:140
Dtk_tab::push_back
void push_back(const T &x)
Inserts an element at the end of the array.
Definition: util_stl_dtk.hpp:415
stepw_GiveUniqueProductName
Dtk_string stepw_GiveUniqueProductName(const Dtk_string &inProductName)
Creates a unique product name. If already recorded as "name" or "name--ii" while ii is an integer,...
Dtk_Info::create
static Dtk_SmartPtr< Dtk_Info > create()
stepw_SetConversionLengthUnit
Dtk_ErrorStatus stepw_SetConversionLengthUnit(const int inLength)
Modal setting of Length Units in which the geometries, properties, .. are to be converted and written...
stepw_InitPropertySet
Dtk_ErrorStatus stepw_InitPropertySet(const int inMode)
Commands Dtk_MetaData to be to be written, attached to the whole Part, or to the following Item to be...
stepw_InitNodeContext
void stepw_InitNodeContext(const int inNodeID)
Initialises the context to write items in a node of the model (internal model tree,...
stepw_EndNodeContext
void stepw_EndNodeContext(const int inNodeID=0)
WriteAsmFdt
void WriteAsmFdt(const int level)
Definition: testlibstepwrite.cpp:429
Dtk_API
Definition: dtk_api.hpp:75
Dtk_MetaData::CreateMetaData
static Dtk_MetaDataPtr CreateMetaData(const MetaDataTypeEnum &inEnumType, Dtk_string inTitle, Dtk_string inValue, Dtk_string inValueType=Dtk_string(L"STRING"))
Create a Dtk_MetaDataPtr .