kellyyang1 发表于 2004-10-29 21:26:00

请大家指点一下!急

我写了如下的一段代码
#include "StdAfx.h"
#include "StdArx.h"
#include "string.h"
long len1;/////////图形中所有管段的个数
ads_name sspipe;///////图形中管段的选择集
int line_data(ads_name ent,ads_point pt_start,ads_point pt_end)
{struct resbuf *eb1=NULL,*eb2=NULL;
eb1=acdbEntGet(ent);
for(eb2=eb1;eb2!=NULL;eb2=eb2->rbnext)
{if(eb2->restype==0)
if(strcmp(eb2->resval.rstring,"LINE")!=0)
{acutRelRb(eb1);
return RTERROR;
}
if(eb2->restype==10)
ads_point_set(eb2->resval.rpoint,pt_start);
if(eb2->restype==11)
ads_point_set(eb2->resval.rpoint,pt_end);
}
acutRelRb(eb1);
return RTNORM;
}
// This is command 'GD'
void vcstep1gd()////////此函数用来给管段编号
{
        // TODO: Implement the command
ads_name pipe;///////前者为所有管段的集合,后者为单个管段
struct resbuf res1;
char str1,str2;////////str2为管段的标号
ads_point s_point,e_point;
ads_point mid_point;
strcpy(str1,"LINE");
res1.resval.rstring=str1;
res1.restype=0;
res1.rbnext=NULL;
if(acedSSGet("X",NULL,NULL,&res1,sspipe)!=RTNORM)
acedAlert("图形中还没有管线\n请绘制管线");
acedSSLength(sspipe,&len1);
acedCommand(RTSTR,"LAYER",RTSTR,"M",RTSTR,"HELLO",RTSTR,"S",RTSTR,"HELLO",RTSTR,"",0);
for(int i=0;irbnext)
                {
                        if(eb2->restype==0)
                        if(strcmp(eb2->resval.rstring,"LINE")!=0)
                        {acutRelRb(eb1);
                        return RTERROR;
                }
                if(eb2->restype==10)
                ads_point_set(eb2->resval.rpoint,pt_start);
                if(eb2->restype==11)
                ads_point_set(eb2->resval.rpoint,pt_end);
                }
                acutRelRb(eb1);
                return RTNORM;
        }
        // This is command 'GD'
        static void vcstep1gd()////////此函数用来给管段编号
        {
                // TODO: Implement the command
                ads_name pipe;///////前者为所有管段的集合,后者为单个管段
                struct resbuf res1;
                char str1,str2;////////str2为管段的标号
                ads_point s_point,e_point;
                ads_point mid_point;
                strcpy(str1,"LINE");
                res1.resval.rstring=str1;
                res1.restype=0;
                res1.rbnext=NULL;
                if(acedSSGet("X",NULL,NULL,&res1,sspipe)!=RTNORM)
                acedAlert("图形中还没有管线\n请绘制管线");
                acedSSLength(sspipe,&len1);
                acedCommand(RTSTR,"LAYER",RTSTR,"M",RTSTR,"HELLO",RTSTR,"S",RTSTR,"HELLO",RTSTR,"",0);
                for(int i=0;i<len1;i++)
                {
                        acedSSName(sspipe,i,pipe);
                        line_data(pipe,s_point,e_point);
                        mid_point=(s_point+e_point)/2;
                        mid_point=(s_point+e_point)/2;
                        mid_point=0;
                        ads_real angle=180/3.141592657589*acutAngle(s_point,e_point);///////每条直线的角度
                        acdbRToS(i+1,2,2,str2);
                        acedCommand(RTSTR,"CIRCLE",RTPOINT,s_point,RTSTR,"10",RTNONE);
                        acedCommand(RTSTR,"TEXT",RTPOINT,mid_point,RTSTR,"10",RTREAL,angle,RTSTR,str2,0);
                }
                if (sspipe)
                        acedSSFree(sspipe);
        }
下次代码还是写清楚一点吧?

王咣生 发表于 2004-10-29 21:58:00

呵呵,真是非常感谢啊,不过能告诉我为什么要这样做吗》??不好意思啊,我是新手

kellyyang1 发表于 2004-10-29 22:35:00

怎么做? 指什么?

王咣生 发表于 2004-10-29 22:42:00

其实下面还有如下的代码
void vcstp2jd()
{
        // TODO: Implement the command
ads_name pipe;////////管段的数组
ads_point as_point,ae_point;///////管段起始节点的数组
ads_point totalpoint;
for(int i=0;i<len1;i++)
{acedSSName(sspipe,i,pipe);
line_data(pipe,as_point,ae_point);
totalpoint=as_point;
totalpoint=as_point;
totalpoint=as_point;
totalpoint=ae_point;
totalpoint=ae_point;
totalpoint=ae_point;
acedCommand(RTSTR,"CIRCLE",RT3DPOINT,as_point,RTREAL,10,0);
acedCommand(RTSTR,"CIRCLE",RT3DPOINT,ae_point,RTREAL,10,0);
}
int sizeofpoint=sizeof(totalpoint)/4;
}可是在CAD下运行还是会出现Invalid type in acutBuildList() arg #7
命令: Invalid type in acutBuildList() arg #7这样的问题,能告诉究竟是什么原因呢??

kellyyang1 发表于 2004-10-29 22:44:00

从调试的结果
acedCommand(RTSTR,"CIRCLE",RT3DPOINT,as_point,RTREAL,10,0);
没有执行成功, 那问题就在这里了, 而这里acedCommand有7个参数, 但
"Invalid type in acutBuildList() arg #7 " 不一定准确, 总之能找到出错的位置!
你执行你的程序后, F2看一下AutoCAD Command Line, 也可以清楚地
看到CIRCLE和TEXT的执行过程!

王咣生 发表于 2004-10-29 22:49:00

你不是把子函数返回值定义为静态整数了吗》》?而且把选择集释放出来了啊,为什么这么做就可以了呢??呵呵,谢谢

kellyyang1 发表于 2004-10-29 22:52:00

到vcstp2jd()函数执行的时候即使按F2也就只能看见"Invalid type in acutBuildList() arg #7 "提示,是不是函数返回值的问题啊??还是不能定义点数组的问题啊??/

kellyyang1 发表于 2004-10-29 22:59:00

这一句:
acedCommand(RTSTR,"CIRCLE",RTPOINT,s_point,RTREAL,10,0); 改成了
acedCommand(RTSTR,"CIRCLE",RTPOINT,s_point,RTSTR,"10",RTNONE);

王咣生 发表于 2004-10-29 23:10:00

呵呵,是可以了啊,可是为什么呢??对了能把你的QQ号给我吗??这样讨教起来方便啊,呵呵
页: [1]
查看完整版本: 请大家指点一下!急