![Logo](tetiere_ht.jpg) |
DATAKIT API
V2025.1
|
|
Table Of Contents:
Full samples source code
0.Introduction
PLMXML allows to write assemblies, where each leaf is a part written in another format. For our examples, we will write JT leaves, using Datakit JT Writer.
Before writing PLMXML files, you need to initialise Datakit API.
Checking the main, we need to :
1.Assembly sample
This is a sample writing a simple assembly with instances, and metadatas.
template <typename T>
inline void Shift(T& mesh,
double sh)
{
mesh->Transform(t);
}
{
}
{
Dtk_string outputDirectory = inResultDirectory + L
"dtk/Plmxml/";
Dtk_string axlename = outputDirectory + L
"axle.jt";
Dtk_string wheelname = outputDirectory + L
"wheel.jt";
Dtk_string plmxmlfile = outputDirectory + L
"sample1.plmxml";
CHECK_OK(P.OpenInstance(
"Axles", id_of_axles));
std::cout <<
"=> " << plmxmlfile.
c_str() << endl;
}
Lets see the function PlmxmlwritesampleJT. We provide the ouptput directory.
- First, we create each parts. In our example, we create JT parts.
We create 2 cylinders, axle and wheel, radius 0.2 meters, height 5 meters for axle, and radius 1 meter and height 1 meter for wheel.
Note that PLMXML unit is in meters.
Function CreateJtFileForPLMXML create the JT files, check Jt Writer documentation for more options for these files.
You can check axle.jt and wheel.jt from this point into the inResultDirectory.
- Next, we prepare datas for PLMXML, vectors X,Y,Z for assemblies matrices, metadatas, and id for reinstancied parts or subassemblies.
meta1 will contain 2 datas ("One","Two"), meta2 will contain one data "Other"
Then creating the PLMXML
The constructor needs plmxml file, gives back an output error (checked after), and also 0.001 : this is a scale between millimeters and meters, because we will provide all matrix in millimeters after, so we need to scale to meters.
We open the RootNode.
Then we create the node "Axles" : we provide id_of_axles because we will reinstance the whole subassembly "Axels" later. Note that you can provide id you want.
We create subassembly "Axle", and then add the extern file "axlename" that is a JT file.
We create subassembly "wheels"
We create subassembly "wheel", providing id_of_wheel for later, and a matrix.
For "wheel2" : we reuse id_of_wheel : it means we reinstanciate the same wheel (with another matrice), do not call SetExternFic anymore for wheel, juste CloseLastInstance immediatly
We also provide "meta1" to "wheel2" instance.
We close Wheels ans Axles.
Then we reinstanciate whole Axles subassembly, calling it "Axles2", and reclose immediatly. We also provide "meta2"
The destructor of P finish the process.
Here is the result : we use JT2Go to see the result, and we retrieve the fullassembly
We see the metadatas on the selected instances.
We see unit is in meters.
This is the Transformation dedicated class.
Definition: dtk_transfo.hpp:19
Definition: plmxmlw.hpp:12
Dtk_BodyPtr CreateCyl(double radius, double height)
Definition: testcreatecube.cpp:1791
This is a high level string class.
Definition: dtk_string.hpp:58
int tess_InitTesselation(Dtk_string inWorkingDirectory, double inTolerance)
Init the tesselation library.
Dtk_ErrorStatus PlmxmlwritesampleJT(const Dtk_string &inResultDirectory)
Definition: testlibplmxmlwrite.cpp:36
int64_t Dtk_Int64
Definition: define.h:692
Dtk_ErrorStatus CreateJtFileForPLMXML(const Dtk_string &ficname, const Dtk_BodyPtr &body)
Definition: testlibplmxmlwrite.cpp:27
Dtk_ErrorStatus
Definition: error_dtk.hpp:6
#define CHECK_OK(X)
Definition: testwriters.h:9
Definition: util_ptr_dtk.hpp:37
const char * c_str() const
Retrieve the ASCII conversion string.
int mkdir() const
File Utility : Create a Directory.
This is a mathematical point class.
Definition: dtk_pnt.hpp:22
void FixPathSeparator()
File Utility : Fixes path separator consistency. It lets you replace the '\' or '/' by the OS needed ...
int tess_ComputeBoundariesFromMesh()
: Check value of option memorize noundaries of mesh
This is a high level array class.
Definition: util_stl_dtk.hpp:85
void addTranslate(const Dtk_dir &V)
Translate the Dtk_transfo.
void tess_EndTesselation()
Free the data used by tesselation library.
@ dtkNoError
Definition: error_dtk.hpp:140
void push_back(const T &x)
Inserts an element at the end of the array.
Definition: util_stl_dtk.hpp:415
This is Jt Interface class used to write Jt files.
Definition: jtw.h:8
void Shift(T &mesh, double sh)
Definition: testlibplmxmlwrite.cpp:20
This is a mathematical direction class.
Definition: dtk_dir.hpp:15
Dtk_ErrorStatus AddBody(const Dtk_BodyPtr &inToWrite, const Dtk_tab< Dtk_Float32 > &makelods=Dtk_tab< Dtk_Float32 >(), Dtk_Float32 inLossytol=0)
Add a body into the current node.
int PlmxmlWriteSample(const Dtk_string &inResultDirectory)
Definition: testlibplmxmlwrite.cpp:100