Proe 6.0 C++开发环境,将一打开的模型另存为新的路径 代码实现
时间: 2023-12-14 19:35:59 浏览: 38
在 Pro/Engineer 中,可以使用以下 C++ 代码将当前打开的模型另存为新路径:
```c++
#include <ProToolkit.h>
#include <ProSolid.h>
ProError SaveAsNewPath(char* new_path) {
ProError status;
ProMdl current_model;
ProName model_name;
ProPath old_path;
ProPath new_path_struct;
// 获取当前打开的模型
status = ProMdlCurrentGet(¤t_model);
if (status != PRO_TK_NO_ERROR) {
return status;
}
// 获取当前模型的名称和路径
status = ProMdlNameGet(current_model, model_name);
if (status != PRO_TK_NO_ERROR) {
ProMdlFree(current_model);
return status;
}
status = ProMdlPathGet(current_model, old_path);
if (status != PRO_TK_NO_ERROR) {
ProMdlFree(current_model);
return status;
}
// 将新路径转换为 ProPath 结构体
status = ProPathAlloc(new_path, &new_path_struct);
if (status != PRO_TK_NO_ERROR) {
ProMdlFree(current_model);
return status;
}
// 另存为新路径
status = ProSolidSaveAs(current_model, new_path_struct, PRO_B_FALSE);
if (status != PRO_TK_NO_ERROR) {
ProMdlFree(current_model);
return status;
}
// 释放资源
ProPathFree(&new_path_struct);
ProMdlFree(current_model);
return PRO_TK_NO_ERROR;
}
```
该函数的参数 `new_path` 是新路径的字符串,例如 `"C:\\NewFolder\\NewModel.prt"`。函数返回 `PRO_TK_NO_ERROR` 表示成功,否则表示失败。
相关推荐
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)