- 积分
- 73549
- 明经币
- 个
- 注册时间
- 2001-6-7
- 在线时间
- 小时
- 威望
-
- 金钱
- 个
- 贡献
-
- 激情
-
|
//我用两种方法都行不通,请高手指教
void CDocData:rawLine()
{
acutPrintf("\nBegin drawing!\n");
--AcGePoint3d startPt;
--AcGePoint3d endPt;
--AcDbBlockTable* pBlockTable;
--acdbCurDwg()->getBlockTable(pBlockTable,AcDb::kForRead);
--AcDbBlockTableRecord* pBlockTableRecord;
--pBlockTable->getAt(ACDB_MODEL_SPACE,pBlockTableRecord,AcDb::kForWrite);
--pBlockTable->close();
--//Create hatch
AcDbObjectIdArray objIds;
--ads_name objName[4];
--AcDbObjectId plid;
--AcDbPolyline *pPl = new AcDbPolyline();
--pPl->addVertexAt( 0,AcGePoint2d(0,10) );
--pPl->addVertexAt( 1,AcGePoint2d(2,30) );
--pPl->addVertexAt( 2,AcGePoint2d(7,68) );
--pPl->addVertexAt( 3,AcGePoint2d(10,100) );
--pBlockTableRecord->appendAcDbEntity(plid,pPl);
--pPl->close();
--if( acdbGetAdsName(objName[0],plid) != Acad::eOk )
--{
----ads_printf("Changing to AdsName error!");
--}
--objIds.append( plid );
--pPl = new AcDbPolyline();
--pPl->addVertexAt( 0,AcGePoint2d(0,98) );
--pPl->addVertexAt( 1,AcGePoint2d(200,130) );
--pBlockTableRecord->appendAcDbEntity(plid,pPl);
--pPl->close();
--acdbGetAdsName(objName[1],plid);
--objIds.append( plid );
--pPl = new AcDbPolyline();
--pPl->addVertexAt( 0,AcGePoint2d(180,150) );
--pPl->addVertexAt( 1,AcGePoint2d(180,-10) );
--pBlockTableRecord->appendAcDbEntity(plid,pPl);
--pPl->close();
--acdbGetAdsName(objName[2],plid);
--objIds.append( plid );
--pPl = new AcDbPolyline();
--pPl->addVertexAt( 0,AcGePoint2d(188,0) );
--pPl->addVertexAt( 1,AcGePoint2d(0,10) );
--pBlockTableRecord->appendAcDbEntity(plid,pPl);
--pPl->close();
--if( acdbGetAdsName(objName[3],plid) != Acad::eOk )
--{
----ads_printf("Changing to AdsName error!");
--}
--objIds.append( plid );
--
--ads_point p;
--p[X] = 30; p[Y] = 30; p[Z] = 0;
--//问题1:acedCommand()函数老是出现访问错,请指教!!!(Test.pat为自定义充填文件)
--acedCommand(RTSTR,"-BHatch",RTSTR,"",
RTSTR,"Test",RTSTR,"1",RTSTR,"0",
----RTSTR,"a",RTSTR,"b",RTSTR,"n",
----RTENAME,objName[0],RTENAME,objName[1],
RTENAME,objName[2],RTENAME,objName[3],
----RTSTR,"",RTSTR,"",RTPOINT, p,RTSTR,"",0);
--//问题2:本想用AcDbHatch创建一个充填,但有问题
--//add hatch
--AcDbHatch* pHatch = new AcDbHatch();
--pHatch->setPatternAngle(0);
--pHatch->setPatternSpace(1);
--pHatch->setPatternDouble(Adesk::kFalse);
--pHatch->setAssociative( Adesk::kTrue );
--pHatch->setHatchStyle(AcDbHatch::kNormal );
--if( pHatch->setPattern(AcDbHatch::kCustomDefined, "Test") != Acad::eOk)
--{
----ads_printf("Create hatch pattern error!");
----delete pHatch;
--}
--else
--{
----Acad::ErrorStatus es;
----//此处出错
----if ( ( es = pHatch->appendLoop(AcDbHatch::kDefault, objIds)) != Acad::eOk )
{
ads_printf("hatch appendLoop error!");
delete pHatch;
}
else
if( pHatch->evaluateHatch() != Acad::eOk )
{
ads_printf("EvaluateHatch hatch pattern error!");
delete pHatch;
}
else
{
pBlockTableRecord->appendAcDbEntity(pHatch);
pHatch->close();
}
}
pBlockTableRecord->close();
acutPrintf("\nEnd drawing!\n");
} |
|