|
我写了如下的一段代码
#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[20],str2[20];////////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[20],str2[20];////////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[X]=(s_point[X]+e_point[X])/2;
mid_point[Y]=(s_point[Y]+e_point[Y])/2;
mid_point[Z]=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);
}
下次代码还是写清楚一点吧? |
|