请大家指点一下!急
我写了如下的一段代码#include "StdAfx.h"<BR>#include "StdArx.h"<BR>#include "string.h"<BR>long len1;/////////图形中所有管段的个数<BR>ads_name sspipe;///////图形中管段的选择集<BR>int line_data(ads_name ent,ads_point pt_start,ads_point pt_end)<BR>{struct resbuf *eb1=NULL,*eb2=NULL;<BR>eb1=acdbEntGet(ent);<BR>for(eb2=eb1;eb2!=NULL;eb2=eb2->rbnext)<BR>{if(eb2->restype==0)<BR>if(strcmp(eb2->resval.rstring,"LINE")!=0)<BR>{acutRelRb(eb1);<BR>return RTERROR;<BR>}<BR>if(eb2->restype==10)<BR>ads_point_set(eb2->resval.rpoint,pt_start);<BR>if(eb2->restype==11)<BR>ads_point_set(eb2->resval.rpoint,pt_end);<BR>}<BR>acutRelRb(eb1);<BR>return RTNORM;<BR>}<BR>// This is command 'GD'<BR>void vcstep1gd()////////此函数用来给管段编号<BR>{<BR> // TODO: Implement the command
ads_name pipe;///////前者为所有管段的集合,后者为单个管段<BR>struct resbuf res1;<BR>char str1,str2;////////str2为管段的标号<BR>ads_point s_point,e_point;<BR>ads_point mid_point;<BR>strcpy(str1,"LINE");<BR>res1.resval.rstring=str1;<BR>res1.restype=0;<BR>res1.rbnext=NULL;<BR>if(acedSSGet("X",NULL,NULL,&res1,sspipe)!=RTNORM)<BR>acedAlert("图形中还没有管线\n请绘制管线");<BR>acedSSLength(sspipe,&len1);<BR>acedCommand(RTSTR,"LAYER",RTSTR,"M",RTSTR,"HELLO",RTSTR,"S",RTSTR,"HELLO",RTSTR,"",0);<BR>for(int i=0;i<len1;i++)<BR>{acedSSName(sspipe,i,pipe);<BR> line_data(pipe,s_point,e_point);<BR>mid_point=(s_point+e_point)/2;<BR>mid_point=(s_point+e_point)/2;<BR>mid_point=0;<BR>ads_real angle=180/3.141592657589*acutAngle(s_point,e_point);///////每条直线的角度<BR>acdbRToS(i+1,2,2,str2);<BR>acedCommand(RTSTR,"CIRCLE",RTPOINT,s_point,RTREAL,10,0);<BR>acedCommand(RTSTR,"TEXT",RTPOINT,mid_point,RTSTR,"10",RTREAL,angle,RTSTR,str2,0);<BR>}<BR>}本意是想在CAD中给每个直线遍上号码,在直线的中间用TEXT命令写出来,同时在直线的端点上画圆,可是为什么圆总画不出来呢,在CAD中的提示是 Invalid type in acutBuildList() arg #7<BR> Invalid type in acutBuildList() arg #7拜托各位了
回复
调试:static int line_data(ads_name ent,ads_point pt_start,ads_point pt_end)<BR> {<BR> struct resbuf *eb1=NULL,*eb2=NULL;<BR> eb1=acdbEntGet(ent);<BR> for(eb2=eb1;eb2!=NULL;eb2=eb2->rbnext)<BR> {<BR> if(eb2->restype==0)<BR> if(strcmp(eb2->resval.rstring,"LINE")!=0)<BR> {acutRelRb(eb1);<BR> return RTERROR;<BR> }<BR> if(eb2->restype==10)<BR> ads_point_set(eb2->resval.rpoint,pt_start);<BR> if(eb2->restype==11)<BR> ads_point_set(eb2->resval.rpoint,pt_end);<BR> }<BR> acutRelRb(eb1);<BR> return RTNORM;<BR> }
// This is command 'GD'<BR> static void vcstep1gd()////////此函数用来给管段编号<BR> {<BR> // TODO: Implement the command
ads_name pipe;///////前者为所有管段的集合,后者为单个管段<BR> struct resbuf res1;<BR> char str1,str2;////////str2为管段的标号<BR> ads_point s_point,e_point;<BR> ads_point mid_point;<BR> strcpy(str1,"LINE");
res1.resval.rstring=str1;<BR> res1.restype=0;<BR> res1.rbnext=NULL;<BR> if(acedSSGet("X",NULL,NULL,&res1,sspipe)!=RTNORM)<BR> acedAlert("图形中还没有管线\n请绘制管线");<BR> acedSSLength(sspipe,&len1);<BR> acedCommand(RTSTR,"LAYER",RTSTR,"M",RTSTR,"HELLO",RTSTR,"S",RTSTR,"HELLO",RTSTR,"",0);
for(int i=0;i<len1;i++)<BR> {<BR> acedSSName(sspipe,i,pipe);<BR> line_data(pipe,s_point,e_point);<BR> mid_point=(s_point+e_point)/2;<BR> mid_point=(s_point+e_point)/2;<BR> mid_point=0;<BR> ads_real angle=180/3.141592657589*acutAngle(s_point,e_point);///////每条直线的角度<BR> acdbRToS(i+1,2,2,str2);<BR> acedCommand(RTSTR,"CIRCLE",RTPOINT,s_point,RTSTR,"10",RTNONE);<BR> acedCommand(RTSTR,"TEXT",RTPOINT,mid_point,RTSTR,"10",RTREAL,angle,RTSTR,str2,0);<BR> }<BR> if (sspipe)<BR> acedSSFree(sspipe);<BR> }
下次代码还是写清楚一点吧?
呵呵,真是非常感谢啊,不过能告诉我为什么要这样做吗》??不好意思啊,我是新手
回复
怎么做? 指什么? 其实下面还有如下的代码void vcstp2jd()<BR>{<BR> // TODO: Implement the command<BR>ads_name pipe;////////管段的数组<BR>ads_point as_point,ae_point;///////管段起始节点的数组<BR>ads_point totalpoint;<BR>for(int i=0;i<len1;i++)<BR>{acedSSName(sspipe,i,pipe);<BR>line_data(pipe,as_point,ae_point);<BR>totalpoint=as_point;<BR>totalpoint=as_point;<BR>totalpoint=as_point;<BR>totalpoint=ae_point;<BR>totalpoint=ae_point;<BR>totalpoint=ae_point;<BR>acedCommand(RTSTR,"CIRCLE",RT3DPOINT,as_point,RTREAL,10,0);<BR>acedCommand(RTSTR,"CIRCLE",RT3DPOINT,ae_point,RTREAL,10,0);<BR>}<BR>int sizeofpoint=sizeof(totalpoint)/4;
}可是在CAD下运行还是会出现Invalid type in acutBuildList() arg #7<BR>命令: Invalid type in acutBuildList() arg #7这样的问题,能告诉究竟是什么原因呢?? 从调试的结果
acedCommand(RTSTR,"CIRCLE",RT3DPOINT,as_point,RTREAL,10,0);
没有执行成功, 那问题就在这里了, 而这里acedCommand有7个参数, 但
"Invalid type in acutBuildList() arg #7 " 不一定准确, 总之能找到出错的位置!
你执行你的程序后, F2看一下AutoCAD Command Line, 也可以清楚地
看到CIRCLE和TEXT的执行过程! 你不是把子函数返回值定义为静态整数了吗》》?而且把选择集释放出来了啊,为什么这么做就可以了呢??呵呵,谢谢 到vcstp2jd()函数执行的时候即使按F2也就只能看见"Invalid type in acutBuildList() arg #7 "提示,是不是函数返回值的问题啊??还是不能定义点数组的问题啊??/<BR>
回复
这一句:acedCommand(RTSTR,"CIRCLE",RTPOINT,s_point,RTREAL,10,0); 改成了
acedCommand(RTSTR,"CIRCLE",RTPOINT,s_point,RTSTR,"10",RTNONE); 呵呵,是可以了啊,可是为什么呢??对了能把你的QQ号给我吗??这样讨教起来方便啊,呵呵