[ObjectARX]修改实体的比例

本应用程序示范了怎样对选择集使用ads_matrix数据类型的矩阵和怎样使用对ads_matri x数据类型进行操作的选择集函数acedXformSS().本程序示例了实体的比例变换。
  acrxEntryPoint.cpp命令函数的实现:

	static void aaaMyGroupMyCommand () {
		acutPrintf(_T("\\n进入aaaMyGroupMyCommand函数."));
		ads_matrix xform;  //转换矩阵
		ads_name ssGrp;  //the entities that make up transform SS
		int rc; //返回码
		ads_real sf;  //Scale Factor

		//Select the entitise
		acedPrompt(_T("\\nSelect entities to scale (transform)"));
		rc = acedSSGet(NULL, NULL, NULL, NULL, ssGrp);
		if (rc != RTNORM)
		{
			acutPrintf(_T("\\nEmpty or invalid selection set."));
			return;
		}

		//input the scale factor
		acedInitGet(RSG_NONULL + RSG_NONEG + RSG_NOZERO, NULL);
		acedGetReal(_T("\\nTransformation Scale factor:"), &sf);

		//initialise the matrix
		COtherUtil::ident_init(xform);

		//Apply the scaling factor to the matrix
		for (int i = 0; i <= 3; i++)
		{
			xform[i][i] = sf;
		}

		rc = acedXformSS(ssGrp, xform);
		if (rc != RTNORM)
		{
			acutPrintf(_T("\\nFailed in transformation of selection set."));
		}
		acedSSFree(ssGrp);

		acutPrintf(_T("\\n完成aaaMyGroupMyCommand函数."));
	}	

其中,

ident_init(ads_matrix id)函数的实现:

void COtherUtil::ident_init(ads_matrix id)
{
	acutPrintf(_T("\\n进入ident_init函数."));
	int i, j;

	for ( i = 0; i <= 3; i++)
	{
		for (j = 0; j <= 3; j++)
		{
			id[i][j] = 0.0;
		}
	}

	for (int i = 0; i <= 3; i++)
	{
		id[i][i] = 1.0;
	}
	acutPrintf(_T("\\n完成ident_init函数."));
}

效果:

参考资料:

《AutoCAD 2000 ObjectARX编程指南》

© 版权声明
THE END
喜欢就支持一下吧
点赞0 分享
评论 抢沙发
头像
欢迎您留下宝贵的见解!
提交
头像

昵称

取消
昵称表情代码图片

    暂无评论内容