- 积分
- 227
- 明经币
- 个
- 注册时间
- 2003-8-22
- 在线时间
- 小时
- 威望
-
- 金钱
- 个
- 贡献
-
- 激情
-
|
下面是我的一个画地面线的程序代码,我想做两个修改:
1、高程放大10倍
2、画出高程线
请问我应该如何修改?
代码如下:
/////////////////////////////////////////////
// ObjectARX defined commands
#include "StdAfx.h"
#include "StdArx.h"
#include<math.h>
void layer_operation( char *manner, char *layer_name );
// This is command 'DMX'
void try_try_dmx()
{
// TODO: Implement the command
ads_point Coor, pt1;
//double scale;
int os_flag, status;
struct resbuf *entlist, result, osrb;
FILE *fp;
char *fn = "dmxcheck.txt";
char tempstr[32];
// 修改捕捉方式
ads_getvar( "OSMODE", &osrb );
os_flag = osrb.resval.rint;
osrb.resval.rint = 0; // Osnap off
ads_setvar( "OSMODE", &osrb );
//设置图层
layer_operation( "make", "graph" );
layer_operation( "set", "graph" );
//打开数据文件
fp = fopen ( fn, "r" );
//检查数据文件是否存在
if ( fp == NULL ) {
sprintf( tempstr, "\n地面线数据文件不存在!");
acedAlert( tempstr );
return;
}
//设置高程放大系数
//acedGetReal( "\n 请输入高程放大系数(纵向:横向)", &scale );
//初始化多义线链表
entlist = acutBuildList (
RTDXF0, "OLYLINE",
8, "graph",
66, 1,
75, 6,
0 );
if ( entlist == NULL ) {
sprintf( tempstr, "\n不能创建实体数据链表!");
acedAlert( tempstr );
return;
}
status = acdbEntMake (entlist);
acutRelRb (entlist);
if ( status != RTNORM ) {
acutPrintf ( "%d", status );
acedGetVar ( "ERROR NUM", &result );
acutPrintf ( "\nERROR== %d", result.resval.rint );
sprintf( tempstr, "\n不能创建地面线!");
acedAlert( tempstr );
return;
}
//绘制多义线
while ( !feof(fp) ) {
fscanf ( fp, "%lf %lf", &Coor[X], &Coor[Y] );
//Coor[Y] = Coor[Y] * scale;
pt1[X] = Coor[X];
pt1[Y] = 0.0;
pt1[Z] = 0.0;
entlist = acutBuildList (
RTDXF0, "VERTEX",
8, "graph",
10, Coor,
0 );
if ( entlist == NULL ) {
sprintf( tempstr, "\n创建链表失败!");
acedAlert( tempstr );
return;
}
status = acdbEntMake ( entlist );
acutRelRb ( entlist );
if ( status != RTNORM ) {
sprintf( tempstr, "\n不能在地面线中增加节点!");
acedAlert( tempstr );
return;
}
}
//定义多义线终点
entlist = acutBuildList (
RTDXF0, "SEQEND",
8, "graph",
0 );
if ( entlist == NULL ) {
sprintf( tempstr, "\n 创建链表失败!");
acedAlert( tempstr );
return;
}
status = acdbEntMake ( entlist );
acutRelRb ( entlist );
if ( status == RTERROR ) {
sprintf( tempstr, "\n不能完成地面线的创建!");
acedAlert( tempstr );
return;
}
fclose ( fp );
layer_operation( "set", "0" );
//绘制背景格网高程线
layer_operation( "make", "backgroud" );
layer_operation( "set", "backgroud" );
//Top = ceil( Hmax ) * scale;
//*while ( Top > 0 ) {
Coor[Y] = Coor[Y] * scale;
pt1[X] = Coor[X];
pt1[Y] = 0.0;
pt1[Z] = 0.0;*/
acedCommand( RTSTR, "zoom", RTSTR, "e", RTNONE );
}
//层操作
void layer_operation( char *manner, char *layer_name )
{
if ( ads_command(RTSTR,"layer",RTSTR,manner,RTSTR,layer_name,RTSTR,"", 0 ) != RTNORM) {
ads_printf("Can not run layer operation\n");
}
return;
}
// This is command 'CHECKDATA'
void try_try_checkdata()
{
// TODO: Implement the command
FILE *in, *out;
char *fn1 = "dmx.txt", *fn2 = "dmxcheck.txt";
double Stake, High, CheckStake;
double Hmax, FirstStake;
char tempstr[32];
in = fopen ( fn1, "r" );
out = fopen ( fn2, "w");
//检测数据文件是否存在
if( in == NULL ) {
sprintf(tempstr, "\n数据文件不存在!");
acedAlert( tempstr );
return ;
}
fscanf ( in, "%lf %lf\n" , &Stake, &High );
CheckStake = Stake;
FirstStake = Stake;
Hmax = High;
acutPrintf( "\nStake==%8.3lf,High==%6.2lf", Stake, High );
fprintf ( out, "%lf %lf \n", Stake, High );
while ( !feof(in) ) {
fscanf ( in, "%lf %lf\n", &Stake, &High );
acutPrintf( "\nStake==%8.3lf,High==%6.2lf", Stake, High );
if ( Stake < CheckStake ) {
sprintf(tempstr, "\n数据文件有误,请检查!");
acedAlert( tempstr );
fclose ( out );
return ;
}
CheckStake = Stake;
if ( High > Hmax ) Hmax = High;
fprintf ( out, "%lf %lf \n", Stake, High );
}
fclose ( in );
fclose ( out );
} |
|