高手帮我看看程序吧,在线等,谢谢!
高手帮我看看程序吧,在线等,谢谢!
画了一个正方形,想填充一下,调试通过了,但是已运行arx就报错!高手帮我分析分析吧,多谢了!
acad::errorstatus createsubstationrecord () {
acdbhatch* phatch = new acdbhatch();
// set hatch plane
acgevector3d normal(0.0, 0.0, 1.0);
phatch->setnormal(normal);
phatch->setelevation(0.0);
// set hatch pattern to ansi31 predefined type
//
phatch->setpattern(acdbhatch::kpredefined, "ansi31");
// set associativity
//
phatch->setassociative(adesk::ktrue);
acgepoint3darray ptsubstation;
ptsubstation.setlogicallength(4);
ptsubstation[0].set(0.0,0.0,0.0);
ptsubstation[1].set(0.0,100.0,0.0);
ptsubstation[2].set(100.0,100.0,0.0);
ptsubstation[3].set(100.0,0.0,0.0);
acdbobjectid lineid,;
acdbobjectidarray dbobjids;
acdbline *pline;
for (int i = 0; i < 4; i++) {
pline = new acdbline();
pline->setstartpoint(ptsubstation[i]);
pline->setendpoint(ptsubstation[(i == 3) ? 0 : i+1]);
posttodatabase(pline, lineid);
dbobjids.append(lineid);
}
// append an external rectangular loop to hatch boundary
//
phatch->appendloop(acdbhatch::kexternal, dbobjids);
phatch->evaluatehatch();
return acad::eok;
}
////////下面是post函数
acad::errorstatus
posttodatabase(/*[in]*/acdbentity* pent,/*[out]*/acdbobjectid& idobj)
{
acad::errorstatus es;
acdbblocktable* pblocktable;
acdbblocktablerecord* pspacerecord;
//确定当前有正在工作的数据库
if (acdbhostapplicationservices()->workingdatabase()==null)
return acad::enodatabase;
//获得当前图形的指针
//获得图形的块表,打开准备读取数据
if ((es = acdbhostapplicationservices()->workingdatabase()->getblocktable(pblocktable, acdb::kforread))==acad::eok){
//获得建模空间的记录,打开准备写数据
if ((es = pblocktable->getat(acdb_model_space, pspacerecord, acdb::kforwrite))==acad::eok){
//添加实体指针到建模空间后关闭指针和建模空间记录
if ((es = pspacerecord->appendacdbentity(idobj, pent))==acad::eok)
pent->close();
pspacerecord->close();
}
//关闭块表
pblocktable->close();
}
//返回状态信息
return es;
}
/////////////////////
调试通过了????????????????????
acdbobjectid lineid,;多一个逗号
phatch->appendloop(acdbhatch::kexternal, dbobjids);
phatch->evaluatehatch();
后面加如下(填充还没有提交到数据库)
acdbobjectid hatchid;
posttodatabase(phatch, hatchid);
*******************
e_mail :
siebeneagle@yahoo.com.cn
msn :
siebeneagle@hotmail.com
qq : 812928665
谢谢sieben的回复,帮助很大,但是怎么把花的图形和填充图案,通过程序保存为一个块呢!请求大家帮助
虚心学习...