![Logo](tetiere_ht.jpg) |
DATAKIT API
V2025.1
|
|
the Document ID Notion
The main idea of the Assemblies CATIA V5 Writing is to add instances of a previously written Document.
For this, DATAKIT APIs introduce the Document ID notion.
The first thing to do is to create Document Reference (DocID) giving a file fullpath and a reference name.
It will result to a Document ID that you can use easily to add an instance into a CATProduct.
The CATProduct writing step-by-step.
- First create Document IDs by catiav5w::CreateCGRDocId or catiav5w::CreateV4ModelDocId:
Dtk_string CATPartFileName = L
"C:\\sample_files\\catiav5\\V5_sample.CATPart";
Dtk_Size_t PartID, V4ID, CgrID, ProdID,ProdID2, ProdID3;
These functions create Reference link to an existing file. For CATIA V4 files, you can only reference '.model' files.
At this time the CatiaV5 Writer can only reference CATPart written by the writer.
The writer can't handle external CATPart references.
So, to reference a CATPart file, you have to provide an additional parameter.
This parameter is the CATPart UUID and it is given by the catiav5w::InitPart function. So you can call the CreatePartDocId function:
- Once you have created the Part DocIds, you can create CATProduct file. For this you have to create a CATProduct context with the catiav5w::InitProduct.
- Once the CATProduct context is created, you can easily add instances into it by the catiav5w::AddInstance function.
TransformationMatrix.
setOrigin( 0.0,0.0,0.0);
TransformationMatrix.
setOrigin( 0.0,500.0,0.0);
TransformationMatrix.
setOrigin( 0.0,-500.0,0.0);
- Finally you have to ends the CATProduct context - to explicitely write the CATProduct file - by the catiav5w::EndProduct function. This function will give you a resulting DocID to insert the CATProduct into multi level Assemblies.
Referencing existing files from a CATProduct
You can reference existing or previously created files into a CATProduct for theses extensions:
The Virtual Component writing step-by-step.
The most important to know is that a virtual component ALWAYS belongs to a CATProduct context.
So you have to cal catiav5w::InitProduct prior calling catiav5w::InitVirtualComponent.
Moreover you can add a virtual component instance only into the same product context that his creation.
So you can only call catiav5w::AddVirtualComponentInstance prior the catiav5w::EndProduct call.
This piece of code is correct:
...whereas this piece of code is wrong:
...
catiav5w::InitProduct( SubProductFileName, "SubProduct");
Full Sample.
{
return PartUUID;
}
{
Dtk_string CATPartFileName = L
"..\\SampleFiles\\dtk\\V5_sample.CATPart";
Dtk_string CGRFileName = L
"..\\SampleFiles\\cgr\\Engine.cgr";
Dtk_string V4ModelFileName = L
"..\\SampleFiles\\v4\\EngineComponent.model";
Dtk_string SubProductFileName = L
"..\\SampleFiles\\dtk\\SubProduct.CATProduct";
Dtk_string RootProductFileName = L
"..\\SampleFiles\\dtk\\RootProduct.CATProduct";
Dtk_ID PartID, V4ID, CgrID, ProdID,ProdID2, CompID1, CompID2;
TransformationMatrix.
setOrigin( 0.0,0.0,0.0);
TransformationMatrix.
setOrigin( 0.0,0.0,0.0);
TransformationMatrix.
setOrigin( 0.0,500.0,0.0);
TransformationMatrix.
setOrigin( 0.0,-500.0,0.0);
TransformationMatrix.
setOrigin( 0.0,1000.0,0.0);
TransformationMatrix.
setOrigin( 0.0,0.0,50.0);
TransformationMatrix.
setOrigin( 1000.0,0.0,0.0);
TransformationMatrix.
setOrigin( -1000.0,0.0,0.0);
}
Here a snapshot of the resulting V5 Assembly (from Full Sample)
Dtk_ErrorStatus ProcessAsm(const Dtk_string &inResultDirectory)
Definition: testlibcatiav5write.cpp:350
uint32_t Dtk_ID
Definition: define.h:689
This is the Transformation dedicated class.
Definition: dtk_transfo.hpp:19
Dtk_ErrorStatus InitVirtualComponent(const Dtk_string &inReferenceName, const catiav5w::FileDescription &inFileDescription=catiav5w::FileDescription())
Initialize a virtual component during CATProduct process.
Dtk_ErrorStatus AddVirtualComponentInstance(const Dtk_ID &inDocId, const Dtk_string &inInstanceName, const Dtk_transfo &inTransfo, Dtk_ID &outInstanceId)
Add an instance to a DocID into the Current (Sub/Root) CATProduct.
void setOrigin(const Dtk_pnt &O)
Set a new O center point.
@ NodeTypeGeometricSet
Definition: catiav5w.hpp:428
Dtk_ErrorStatus ProcessPart(const Dtk_string &inOutputFile, const Dtk_string &inReferenceName)
Definition: testlibcatiav5write.cpp:70
This is a high level string class.
Definition: dtk_string.hpp:58
size_t Dtk_Size_t
Definition: define.h:712
Dtk_ErrorStatus WriteEntity(const Dtk_EntityPtr &inEntity)
Write the entity provided in parameter.
Definition: dtk_uuid.hpp:8
Dtk_ErrorStatus CreateNode(const NodeType &inNodeType, const Dtk_string &inNodeName=Dtk_string())
Create a node in the Specification Tree.
Dtk_ErrorStatus InitProduct(const Dtk_string &inFileName, const Dtk_string &inReferenceName, const catiav5w::FileDescription &inFileDescription=catiav5w::FileDescription())
Initialize a sub Product during CATProduct process.
Dtk_ErrorStatus CreateCGRDocId(const Dtk_string &inCGRFileName, const Dtk_string &inCGRName, Dtk_ID &outDocId)
Create a CGR Reference and DocID related to a given CGR File.
const Dtk_string & inReferenceName
Definition: catiav5w.hpp:456
Dtk_ErrorStatus InitPart(const Dtk_string &inOutputFile, const Dtk_string &inReferenceName, Dtk_UUID &outPartUUID, const catiav5w::FileDescription &inFileDescription=catiav5w::FileDescription())
Initialize the part
Dtk_ErrorStatus EndVirtualComponent(Dtk_ID &outDocId)
End - and write - the virtual component initialized by catiav5w::InitVirtualComponent.
static Dtk_SmartPtr< Dtk_Entity > DtkDynamicCast(const Dtk_SmartPtr< T2 > &p)
Definition: util_ptr_dtk.hpp:101
Dtk_ErrorStatus AddInstance(const Dtk_ID &inDocId, const Dtk_string &inInstanceName, const Dtk_transfo &inTransfo, Dtk_ID &outInstanceId)
Add an instance to a DocID into the Current (Sub/Root) CATProduct.
Dtk_ErrorStatus CreateV4ModelDocId(const Dtk_string &inV4ModelFileName, const Dtk_string &inV4ModelName, Dtk_ID &outDocId)
Create a V4 Model Reference and DocID related to a given V4 Model File.
Dtk_ErrorStatus EndWrite()
Free the Catia V5 Writer
Dtk_ErrorStatus CreatePartDocId(const Dtk_string &inPartFileName, const Dtk_string &inPartName, Dtk_ID &outDocId)
Create a Part Reference and DocID related to a given CATPart.
Dtk_ErrorStatus EndProduct(Dtk_ID &outDocId)
Write effectively the Sub Product initialized by catiav5w::InitProduct.
Dtk_ErrorStatus CloseCurrentNode()
close the current node previously created by catiav5w::CreateNode.
Dtk_ErrorStatus EndPart()
Free data allocated by catiav5w::InitPart
Dtk_ErrorStatus InitWrite(const Dtk_string &inLogFile, Licence_dtk inLicFct, const WriteOptions &inOptions=WriteOptions())
Initialize the Catia V5 Writer
static Dtk_PointPtr Create(const Dtk_Point &inToCopy)
constructors returning Smart pointers
Definition: util_ent_dtk.hpp:329