许可优化
许可优化
产品
产品
解决方案
解决方案
服务支持
服务支持
关于
关于
软件库
当前位置:服务支持 >  软件文章 >  CATIA二次开发CAA框架下的批处理建立新零件

CATIA二次开发CAA框架下的批处理建立新零件

阅读数 40
点赞 0
article_banner

CAA 建立批处理生成有序零件

   初学CAA,C++,在VS2012下建立程序,主程序传入需要生成part文件的地址值。注:头文件是CAA partinterface 框架  示例中的,不需要这么多。

   本程序灵感源于CATIA机械设计下的文件管理与命名问题。

#include"CATSession.h"//needed to manage Session
#include"CATDocument.h" // needed to manage documents
#include "CATDocumentServices.h" // needed to create/save documents
#include "CATSessionServices.h"  // needed to create/delete session
#include "CATInit.h"             // needed to retrieve root container from document

#include "CATMathPlane.h"        // needed to manage planes
#include "CATMathDirection.h"    // needed to manage directions
#include "CATMathPoint.h"        // needed to manage points

#include "CATISketchFactory.h"   // needed to create sketchs
#include "CATI2DWFFactory.h"     // needed to create 2D elements
#include "CATISketch.h"          // needed to edit/modify sketch
#include "CATI2DCurve.h"         // needed to define the start and end point
                                 // of a sketch
#include "CATI2DPoint.h"         // needed to define the start and end point
                                 // of a sketch
#include "CATIPrtFactory.h"      // needed to create pad feature
#include "CATIPad.h"             // needed to manage pad
#include "CATLimitDefs.h"        // needed to access limit type of the pad feature

#include "CATIPrtContainer.h"    // needed to retrieve factories
#include "CATIPrtPart.h"         // needed to access reference planes

#include<stdio.h>
#include<stdlib.h>
#include<string>


using std::string;

string Transferaddress(int name,string baseadress)
{
	string Finaladdress;
	string s("\\");
	char tempname[50];
	string nametemp=itoa(name,tempname,10);
	Finaladdress=baseadress+s+nametemp;
	return Finaladdress;
}

	
int main(int iArgc,char*iArgv[])
{
	int rc=0;
	if(2!=iArgc)
		return 1;
	string base=iArgv[1];
	int i=0;
	for(i=0;i<10;i++)
   {
	CATSession * pSampleSession = NULL;
    Create_Session("SampleSession",pSampleSession);
	CATDocument * pDoc= NULL;
    CATDocumentServices::New("CATPart",pDoc);
	HRESULT boolSave = E_FAIL;
	string nomPart2=Transferaddress(i,base);
	char *Finaladdress=(char*)nomPart2.c_str();
    boolSave = CATDocumentServices::SaveAs(*pDoc,Finaladdress);

  // Closes the session   
  ::Delete_Session("SampleSession"); 
    }
    return rc;
};

下图为生成结果。
在这里插入图片描述

Vs2012下不支持C++11新特性 to_string  转换整型至字符型,这里采用

   C语言方法itoa。

   初次学习,请多指教。


免责声明:本文系网络转载或改编,未找到原创作者,版权归原作者所有。如涉及版权,请联系删


相关文章
技术文档
QR Code
微信扫一扫,欢迎咨询~
customer

online

联系我们
武汉格发信息技术有限公司
湖北省武汉市经开区科技园西路6号103孵化器
电话:155-2731-8020 座机:027-59821821
邮件:tanzw@gofarlic.com
Copyright © 2023 Gofarsoft Co.,Ltd. 保留所有权利
遇到许可问题?该如何解决!?
评估许可证实际采购量? 
不清楚软件许可证使用数据? 
收到软件厂商律师函!?  
想要少购买点许可证,节省费用? 
收到软件厂商侵权通告!?  
有正版license,但许可证不够用,需要新购? 
联系方式 board-phone 155-2731-8020
close1
预留信息,一起解决您的问题
* 姓名:
* 手机:

* 公司名称:

姓名不为空

姓名不为空

姓名不为空
手机不正确

手机不正确

手机不正确
公司不为空

公司不为空

公司不为空