|
- // 选取"JMD"图层类型为"ARC,POLYLINE,CIRCLE"的实体,选择结果不是,则提示退出
- void test()
- {
- ads采用name ent;
- if ( PickEntity( 采用T("\n选择要拉直的2D曲线: "), 采用T("ARC,POLYLINE,CIRCLE"), 采用T("JMD"), ent ) )
- {
- DoSomeThing();
- }
- }
- int PickEntity( TCHAR *promptstr, TCHAR *EntType, TCHAR *EntLayer, ads采用name resent )
- {
- int f1=0,f2=0;
- ads采用point pt;
- struct resbuf *edata, *rb;
- while( ads采用entsel( promptstr, resent, pt ) == RTNORM )
- {
- edata = ads采用entget( resent );
- if ( EntType != NULL && EntType[0] != '\0' )
- {
- rb = dxf( edata, 0 );
- f1 = isKeywordInString( rb->resval.rstring, EntType );
- }
- if ( EntLayer != NULL && EntLayer[0] != '\0' )
- {
- rb = dxf( edata, 8 );
- f2 = isKeywordInString( rb->resval.rstring, EntLayer );
- }
- ads采用relrb( edata );
- if ( !f1 && !f2 )
- return 1;
- else
- ads采用printf(采用T( "\n\n***** 请重新选择物体 *****" ));
- }
- return 0;
- }
- int isKeywordInString( TCHAR *keyword, TCHAR *inputstr )
- {
- TCHAR *pc1, *pc2;
- int fret = 1;
- pc1 = pc2 = inputstr;
- while( *pc1 != '\0' && fret != 0 )
- {
- while( *pc2 != ',' && *pc2 != ';' && *pc2 != '|' && *pc2 != ' ' && *pc2 != '\0' )
- pc2++;
- fret = memcmp( keyword, pc1, (pc2-pc1)*sizeof(TCHAR) );
- if ( *pc2 != '\0' )
- pc2 = pc2 + 1;
- pc1 = pc2;
- }
- return fret;
- }
- struct resbuf *dxf( struct resbuf *edata, short DXF采用CODE )
- {
- struct resbuf *p;
- p = edata;
- while( p != NULL )
- {
- if ( p->restype == DXF采用CODE )
- break;
- p = p->rbnext;
- }
- return p;
- }
复制代码 |
|