|
DATAKIT API
V2025.1
|
|
Table Of Contents:
Overview
The Solidworks Writer APIs support the version 2006 , you can create Part file (sldprt) or Assembly file (sldasm). Add the metadata for each file and set the unit DTK_UNIT_MM or DTK_UNIT_INCH of the file .
All functions are used from the namespace solidworksw .
So you need to initialize the writer as :
Dtk_ErrorStatus solidworksw::InitWriter(const Dtk_string& inLogFile,Licence_dtk inLicFct ,solidworksw::language inLanguage=solidworksw::english);
and delete the writer as :
Dtk_ErrorStatus solidworksw::EndWriter();
How to create a Part file (sldprt) step-by-step.
- You initialize part with its name , the metadata list and the unit , by default it is DTK_UNIT_MM
Dtk_string inFilename =
"../SampleFiles/dtk/essai.sldprt";
- You add all bodies by Dtk_Body or a parasolid file (only if you use PSKERNEL)
Dtk_Body body_plan = sampleWriter::CreatePlane();
.....
#ifdef PSKERNEL_USER
Dtk_string ParasolidFile = L
"../SampleFiles/dtk/Part5.x_t";
#endif
....
- You finalize the part
How to create a Assembly file (sldasm) step-by-step.
- You initialize assembly with its name , the metadata list and the unit , by default it is DTK_UNIT_MM
Dtk_string inFilename =
"../SampleFiles/dtk/essai.sldasm";
- You add all instances with full path name , instance name and position
Dtk_string disk_name =
"../SampleFiles/dtk/child.sldprt";
Dtk_transfo position =
Dtk_transfo(
Dtk_dir(1,0,0),
Dtk_dir(0,1,0),
Dtk_dir(0,0,1),
Dtk_pnt(0,0,0));
disk_name = "../SampleFiles/dtk/child.sldasm";
instance_name = L"MyAssembly2";
....
- You finalize the assembly
Full Sample.
#include <stdio.h>
#ifdef PSKERNEL_USER
void StartParasolid();
void StopParasolid();
#endif
void
{
for (i=0;i<sizei;i++)
{
if (topo.IsNotNULL())
{
if (face.IsNotNULL())
{
if (info.IsNULL())
{
}
cpt++;
Dtk_string face_name = inBody->get_info()->GetName() + L
"Face_";
}
}
}
}
void
{
Dtk_Body body_plan = sampleWriter::CreatePlane();
}
void
{
Dtk_transfo position =
Dtk_transfo(
Dtk_dir(1,0,0),
Dtk_dir(0,1,0),
Dtk_dir(0,0,1),
Dtk_pnt(0,0,0));
instance_name = L"MyPart2";
}
int main(
int argc,
char* argv[])
{
{
temp = L"../../SampleFiles/dtk/my_test_part.sldprt";
temp = L"../../SampleFiles/dtk/my_test_part2.sldprt";
temp = L"../../SampleFiles/dtk/my_test_assembly.sldasm";
temp = L"../../SampleFiles/dtk/logwrite.txt";
}
_putenv("FLEXLM_BATCH=0");
#ifdef _X64
_wchdir(L"../../bin_x64");
StrSchemaPath = "../bin_x64/Schema/";
#else
_wchdir(L"../../bin");
StrSchemaPath = "../bin/Schema/";
#endif
#ifdef PSKERNEL_USER
StartParasolid();
wchar_t *schPath;
schPath = (
wchar_t*)malloc(
sizeof(
wchar_t) * (StrSchemaPath.
len() + 10));
swprintf(schPath, 255, L"P_SCHEMA=%s", StrSchemaPath.w_str());
_wputenv(schPath);
free(schPath);
schPath=NULL;
#endif
if(MyAPI == NULL)
{
printf("Can't Start DATAKIT API %d\n",errorStatus);
}
Dtk_string xmtfile = L
"../SampleFiles/xmt/CS_WHEEL_CAP.X_T";
Dtk_string FilenamePart = L
"../SampleFiles/dtk/my_test_part.sldprt";
FilenamePart = L"../SampleFiles/dtk/my_test_part2.sldprt";
Dtk_string FilenameAssm = L
"../SampleFiles/dtk/my_test_assembly.sldasm";
#ifdef PSKERNEL_USER
StopParasolid();
#endif
return 0;
}
Dtk_BodyPtr CreateAxis()
Definition: testcreatecube.cpp:1492
Dtk_InfoPtr get_info() const
uint32_t Dtk_ID
Definition: define.h:689
This is the Transformation dedicated class.
Definition: dtk_transfo.hpp:19
Dtk_ErrorStatus Transform(const Dtk_transfo &inTransfo)
Dtk_ErrorStatus InitWriter(const Dtk_string &inLogFile, Licence_dtk inLicFct, solidworksw::language inLanguage=solidworksw::english)
Initialize the Solidworks Writer
@ DTK_TYPE_UNKNOWN
Definition: define.h:37
Dtk_ErrorStatus ClosePart()
Free data allocated by solidworksw::OpenPart
This is the generic Info class.
Definition: util_ent_dtk.hpp:115
Dtk_ErrorStatus SetName(Dtk_string inName)
Dtk_ErrorStatus OpenPart(const Dtk_string &inSolidworksFile, const solidworksw::FileDescription &inFileDescription=solidworksw::FileDescription(), Dtk_Unit inUnit=DTK_UNIT_MM, const Dtk_string &inConfigurationName=Dtk_string())
Initialize the part
int main(int argc, char **argv)
Definition: LibReadersSample/main.cpp:36
is a surface bounded by Dtk_Loop.
Definition: util_topology_dtk.hpp:524
void setOrigin(const Dtk_pnt &O)
Set a new O center point.
Dtk_ErrorStatus AddEntity(const Dtk_EntityPtr &inEntity)
Write the entity provided in parameter.
static Dtk_API * StartAPI(const Dtk_string &inTemporyDirectory, Dtk_ErrorStatus &outErrorCode, const Dtk_string &inCustomerID=Dtk_string())
Start DATAKIT API.
void create_assembly(const Dtk_string &inFilename, const Dtk_string &inFilenamePart)
Definition: testlibswwrite.cpp:144
Definition: util_topology_dtk.hpp:27
This is a high level string class.
Definition: dtk_string.hpp:58
Dtk_ErrorStatus CloseAssembly()
Write effectively the Assembly initialized by solidworksw::OpenAssembly.
void create_part(const Dtk_string &inFilename, const Dtk_string &inParasolidFile)
Definition: testlibswwrite.cpp:56
int unlink() const
File Utility : Delete a file.
@ DTK_UNIT_MM
Definition: util_draw_dtk.hpp:85
Dtk_AxisSystemPtr CreateAxisSystem()
Definition: testcreatecube.cpp:1465
const Dtk_string & GetWorkingDir() const
@ dtkErrorAPINotStarted
Definition: error_dtk.hpp:101
Dtk_ErrorStatus SetSchemaDir(const Dtk_string &inSchemaDir)
Set Schema Directory needed for Unigraphics, Parasolid, Solidedge, Solidworks and Jt readers.
void SetIsAlreadyStart(const Dtk_Int32 &inStop)
ONLY for PSKERNEL user.
Dtk_ErrorStatus EndWriter()
Free the Solidworks Writer
This is a high level mesh class.
Definition: util_mesh_dtk.hpp:485
void add_int(const int integer, int force_unsigned_int=0)
concat an int to the Dtk_string (convert the int to Dtk_string)
This class provides several informations about a Solidworks File. It can be used with solidworksw::Op...
Definition: solidworksw.hpp:36
Dtk_FdtPtr CreateFdtDimAssy()
PMI in Assembly : a dimension between faces of different instances.
Definition: testcreatefdt.cpp:118
Dtk_BodyPtr CreatePoint()
Definition: testcreatecube.cpp:1407
Dtk_BodyPtr CreateEsquisse2D()
Definition: testcreatecube.cpp:1625
Dtk_FdtPtr CreateFdtDatum()
Create Simple Datum.
Definition: testcreatefdt.cpp:19
int32_t Dtk_Int32
Definition: define.h:687
@ english
Definition: solidworksw.hpp:17
static Dtk_SmartPtr< Dtk_Entity > DtkDynamicCast(const Dtk_SmartPtr< T2 > &p)
Definition: util_ptr_dtk.hpp:101
Dtk_ErrorStatus
Definition: error_dtk.hpp:6
Dtk_BodyPtr CreateEsquisse3D()
Definition: testcreatecube.cpp:1524
Dtk_ErrorStatus AddInstanceComponent(Instance &inInstance)
Add an instance into the Current Assembly (sldasm).
Definition: util_ptr_dtk.hpp:37
Dtk_MeshPtr CreateMeshCylinder(int nbpoints)
Mesh Cylinder sample.
Definition: testcreatemesh.cpp:337
This is a mathematical point class.
Definition: dtk_pnt.hpp:22
This is a high level array class.
Definition: util_stl_dtk.hpp:85
Dtk_BodyPtr CreateCube()
Definition: testcreatecube.cpp:1249
static void StopAPI(Dtk_API *&inAPI, Dtk_bool inWriteTimeInLog=1)
Stop DATAKIT API.
Dtk_ErrorStatus AddMetaData(const Dtk_MetaDataPtr &inEntity)
int len() const
Retrieve the length of the Dtk_string.
Dtk_BodyPtr CreateCurves()
Definition: testcreatecube.cpp:1292
Dtk_ErrorStatus AddParasolidFile(const Dtk_string &inParasolidFile)
Add parasolid file.
@ 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
Definition: dtk_rgb.hpp:7
Dtk_ErrorStatus OpenAssembly(const Dtk_string &inFileName, const solidworksw::FileDescription &inFileDescription=solidworksw::FileDescription(), Dtk_Unit inUnit=DTK_UNIT_MM, const Dtk_string &inConfigurationName=Dtk_string())
Initialize a Assembly .
Dtk_ErrorStatus SetColor(const int &R, const int &G, const int &B)
static Dtk_SmartPtr< Dtk_Info > create()
This class provides Instance about a Solidworks File. It can be used with solidworksw::OpenAssembly f...
Definition: solidworksw.hpp:79
A Dtk_Body Dtk_Body is the highest level topological entity. It allow you to handle manifold and non-...
Definition: util_topology_dtk.hpp:801
void AddColortoFace(const Dtk_BodyPtr &inBody)
Definition: testlibswwrite.cpp:25
This is a mathematical direction class.
Definition: dtk_dir.hpp:15
Definition: dtk_api.hpp:75
This is the Dtk_AxisSystem class.
Definition: util_ent_dtk.hpp:722
This is the FD&T class. The base PMI Class contains a Dtk_2dEntity and Transformation Matrix to loca...
Definition: util_draw_dtk.hpp:7347