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

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。
初次学习,请多指教。

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值