明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 1599|回复: 0

基于ActiveX通过vc进行AutoCAD二次开发有问题要问!!!

[复制链接]
发表于 2003-4-20 15:12 | 显示全部楼层 |阅读模式
通过一个4×4的矩阵对一条直线进行缩放和平移
代码如下:
  void CWanDlg::OnButtonRelativeScale()
{
    UpdateData(true);

    IAcadLine Line;
    IAcadModelSpace m_IMSpace;

    SAFEARRAYBOUND RSbound;
    RSbound.lLbound = 0;
    RSbound.cElements = 4*4;

    SAFEARRAY * pStartPoint = NULL;
    pStartPoint= ::SafeArrayCreate(VT_R8,1,&RSbound);
    if(!pStartPoint) AfxMessageBox("SafeArrayCreate error!");

    double TransMatrix[4][4];
    int index1,index2;

    //初始化矩阵
    for(index1=0;index1<4;index1++)   
     {
        for(index2=0;index2<4;index2++)
          {
        TransMatrix[index1][index2]=0;
          }
     }

    //m_RSFactor为4*4矩阵的对角线上的变量
    TransMatrix[0][0]=m_RSFactor;
    TransMatrix[1][1]=m_RSFactor;
    TransMatrix[2][2]=m_RSFactor;
    TransMatrix[3][3]=1;

//把数组赋值道SAFEARRAY里   
long i=0;
for(index1=0;index1<4;index1++)
{
    for(index2=0;index2<4;index2++)
    {
      SafeArrayPutElement(pStartPoint,&i,&TransMatrix[index1][index2]);
                  i++;
    }  
}

VARIANT pRS;
VariantInit(&pRS);
pRS.vt =VT_ARRAY|VT_R8;
pRS.parray =pStartPoint;

//激活所绘的最后一条直线         
int m_LineNum=m_IMSpace.GetCount();
VARIANT temp;
VariantInit(&temp);
temp.vt =VT_I2;
temp.iVal =m_LineNum-1;
Line=m_IMSpace.Item(temp);

Line.TransformBy(pRS);//转置 (这里出现了问题)
望各位大侠能帮小弟解决!!!
您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|CAD论坛|CAD教程|CAD下载|联系我们|关于明经|明经通道 ( 粤ICP备05003914号 )  
©2000-2023 明经通道 版权所有 本站代码,在未取得本站及作者授权的情况下,不得用于商业用途

GMT+8, 2024-5-4 13:38 , Processed in 0.165546 second(s), 23 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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