天气与日历 切换到窄版

 找回密码
 立即注册
中国膜结构网
十大进口膜材评选 十大国产膜材评选 十大膜结构设计评选 十大膜结构公司评选
查看: 63|回复: 0

如何使用 ObjectARX 转换块引用及其所有属性?‎

[复制链接]

该用户从未签到

主题

0

回帖

2912

积分

管理员

积分
2912
发表于 2024-6-22 09:46:18 | 显示全部楼层 |阅读模式
[code]AcDbBlockReference * getBR();



//TRANS - translates the selected block reference by (100,100,0).

void Asdktrans()

{

   AcDbBlockReference * pBR = getBR();



   if (pBR == NULL)

     return;



   AcGeMatrix3d mat;

   mat = mat.setToTranslation(AcGeVector3d(100,100,0));

   pBR->transformBy(mat);



   pBR->close();

}



//ROT - rotates the selected block reference by 45 degrees.

void Asdkrot()

{

   AcDbBlockReference * pBR = getBR();



   if (pBR == NULL)

     return;



   AcGeMatrix3d mat;

   mat = mat.rotation(0.785398, pBR->normal(), pBR->position());

   pBR->transformBy(mat);



   pBR->close();

}



//SCAL - scales the selected block reference by a factor of 2.

void Asdkscal()

{

   AcDbBlockReference * pBR = getBR();


   if (pBR == NULL)

     return;



   AcGeMatrix3d mat;

   mat = mat.scaling(2, AcGePoint3d(0,0,0));

   pBR->transformBy(mat);



   pBR->close();

}



//ROTSCALTRANS - performs all three operations in a single call to transformBy().

void Asdkrotscaltrans()

{

   AcDbBlockReference * pBR = getBR();



   if (pBR == NULL)

     return;



   AcGeMatrix3d mat1;

   mat1 = mat1.rotation(0.785398, pBR->normal(), pBR->position());

   AcGeMatrix3d mat2;

   mat2 = mat2.scaling(2, AcGePoint3d(0,0,0));

   AcGeMatrix3d mat3;

   mat3 = mat3.setToTranslation(AcGeVector3d(100,100,0));



   AcGeMatrix3d mat;

   mat = mat1*mat2*mat3;

   pBR->transformBy(mat);



   pBR->close();

}



// Opens block reference chosen by user

AcDbBlockReference * getBR()

{

  ads_name ename;

  ads_point pt;

  AcDbObjectId objId;

  Acad::ErrorStatus es;



  if (RTNORM != acedEntSel(_T("\nSelect Block : "), ename, pt))

    return NULL;



  es = acdbGetObjectId(objId, ename);


  if (es != Acad::eOk)

    return NULL;



  AcDbBlockReference * pBR;

  AcDbObject * pObj;



  acdbOpenObject(pObj, objId, AcDb::kForWrite);



  pBR = AcDbBlockReference::cast(pObj);



  if (pBR == NULL)

  {

    pObj->close();

    acutPrintf(_T("\nThis is not a block."));

    return NULL;

  }



  return pBR;

}[/code]

 

 

 

 

如何使用 ObjectARX 转换块引用及其所有属性?‎
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|Archiver|中国膜结构网|中国膜结构协会|进口膜材|国产膜材|ETFE|PVDF|PTFE|设计|施工|安装|车棚|看台|污水池|中国膜结构网_中国空间膜结构协会

GMT+8, 2024-11-1 10:35 , Processed in 0.142108 second(s), 26 queries .

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表