CAA创建基于草图拉伸(Pad) 的状态命令

2014-09-21 16:28:52|?次阅读|上传:wustguangh【已有?条评论】发表评论

关键词:C/C++, CAA, CATIA|来源:唯设编程网

7.  验证用户输入—ValidateInput

//验证用户输入
CATBoolean CAAPadCreateStCmd::ValidateInput(){
	//1. 获取编辑框用户输入的偏移长度
	CATDlgEditor* pEditor1 = _pDlgInput->GetEditorControl(2);
	if(NULL == pEditor1)
		return CATFalse;

	CATDlgEditor* pEditor2 = _pDlgInput->GetEditorControl(3);
	if(NULL == pEditor2)
		return CATFalse;
	//2. 将用户输入的字符串转换成浮点数
	CATUnicodeString strOffset("");

	strOffset = pEditor1->GetText();
	strOffset.ConvertToNum(&_fOffset1);

	strOffset = pEditor2->GetText();
	strOffset.ConvertToNum(&_fOffset2);

	//3. 验证草图
	if(NULL_var == _spSketchObj)
		return CATFalse;

	return CATTrue;
}

8.  创建拉伸体—CratePad

//创建拉伸体
CATBoolean CAAPadCreateStCmd::CreatePad(void* data){
	//1. 重置按钮响应代理
	_pDlgOKAgent->InitializeAcquisition();
	//2. 验证输入数据
	if(!ValidateInput())
		return CATFalse;
	//3. 获取零件工厂
	if(NULL_var == _spSketchObj)
		return CATFalse;

	CATIContainer_var spContainer = _spSketchObj->GetFeatContainer();
	if(NULL_var == spContainer)
		return CATFalse;

	CATIPrtFactory_var spPrtFactory = spContainer;
	if(NULL_var == spPrtFactory)
		return CATFalse;
	//4.获取草图方向
	CATMathDirection mathDirect(0,0,1);

	CATISketch_var spSketch = _spSketchObj;
	if(NULL_var == spSketch)
		return CATFalse;

	CATISpecObject_var spSketchPlaneObj = spSketch->GetSupport();
	if(NULL_var == spSketchPlaneObj)
		return CATFalse;

	CATPlane_var spSketchPlane = spSketchPlaneObj;
	if(NULL_var == spSketchPlane)
		return CATFalse;

	double planePos[3] = {0};
	CATMathPoint ptCenter;
	CATMathVector coordVector;
	spSketchPlane->GetNormal(ptCenter, coordVector);

	mathDirect.SetCoord(coordVector.GetX(),
		coordVector.GetY(),
		coordVector.GetZ());

	//5. 创建拉伸
	CATIPad_var spPad = spPrtFactory->CreatePad(_spSketchObj,
		_fOffset1,
		_fOffset2,
		mathDirect);
	if(NULL_var == spPad)
		return CATFalse;

	CATISpecObject_var spPadObj = spPad;
	if(NULL_var == spPadObj)
		return CATFalse;

	spPadObj->Update();

	//6. 更新零件特征
	CATIPrtContainer_var spPrtContainer = spContainer;
	if(NULL_var == spPrtContainer)
		return CATFalse;

	CATISpecObject_var spPrtObj = spPrtContainer->GetPart();
	spPrtObj->Update();

	return CATTrue;
}
发表评论0条 】
网友评论(共?条评论)..
CAA创建基于草图拉伸(Pad) 的状态命令