[求助]ARX 如何画两根或多根直线
<div>我是ARX初学者,画一根直线我现在是可以画了,</div><div><br/></div><div>可是如果画两根呢? 具体怎么操作?</div><div><br/></div><div>望指点 谢谢</div> <p>一条都会了,多条又有何困难的呢?</p><p>代码都是一样的啊,修改一个第一条直线的端点坐标不就可以了嘛。</p> <div>我用向导生成的。再在里面加上如下代码创建一直线,代码是教材里面的</div><div>改的话,改了 ptStart ptEnd坐标就可以了? 那我创建两条的话,是不是要创建总共四个点?</div><div><br/></div><div>那些指针也得新增一些?</div><div>具体有一个代码就好了,我看一下可能就会明白 了</div><div><br/></div><div><br/></div><div><br/></div><div><br/></div><div>// 在内存上创建一个新的对象 </div><div> AcGePoint3d ptStart(0, 0, 0); </div><div> AcGePoint3d ptEnd(100, 100, 0); </div><div> AcDbLine *pLine = new AcDbLine(ptStart, ptEnd); </div><div> </div><div> // 获得指向块表的指针 </div><div> AcDbBlockTable *pBlockTable; </div><div> acdbHostApplicationServices()->workingDatabase() </div><div> ->getBlockTable(pBlockTable, AcDb::kForRead); </div><div> </div><div> // 获得指向特定的块表记录(模型空间)的指针 </div><div> AcDbBlockTableRecord *pBlockTableRecord; </div><div> pBlockTable->getAt(ACDB_MODEL_SPACE, pBlockTableRecord, </div><div> AcDb::kForWrite); </div><div> </div><div> // 将AcDbLine类的对象添加到块表记录中 </div><div> AcDbObjectId lineId; </div><div> pBlockTableRecord->appendAcDbEntity(lineId, pLine); </div><div> </div><div> // 关闭图形数据库的各种对象 </div><div> pBlockTable->close(); </div><div> pBlockTableRecord->close(); </div><div> pLine->close(); </div> <div>// 在内存上创建一个新的对象 </div>
<div> AcGePoint3d ptStart(0, 0, 0); </div>
<div> AcGePoint3d ptEnd(100, 100, 0); </div>
<div> AcDbLine *pLine = new AcDbLine(ptStart, ptEnd); </div>
<div><font color="#800080"> //再加一条</font>
<div><font color="#800080"> AcGePoint3d ptStart1(0, 0, 0); </font></div>
<div><font color="#800080"> AcGePoint3d ptEnd1(0, 100, 0); </font></div>
<div><font color="#800080"> AcDbLine *pLine1 = new AcDbLine(ptStart1, ptEnd1); </font></div></div>
<div> // 获得指向块表的指针 </div>
<div> AcDbBlockTable *pBlockTable; </div>
<div> acdbHostApplicationServices()->workingDatabase() </div>
<div> ->getBlockTable(pBlockTable, AcDb::kForRead); </div>
<div> </div>
<div> // 获得指向特定的块表记录(模型空间)的指针 </div>
<div> AcDbBlockTableRecord *pBlockTableRecord; </div>
<div> pBlockTable->getAt(ACDB_MODEL_SPACE, pBlockTableRecord, </div>
<div> AcDb::kForWrite); </div>
<div> </div>
<div> // 将AcDbLine类的对象添加到块表记录中 </div>
<div> AcDbObjectId lineId; </div>
<div> pBlockTableRecord->appendAcDbEntity(lineId, pLine); </div>
<div><font color="#800080"> // 将第二条线也加进模型空间中</font></div>
<div><font color="#800080">pBlockTableRecord->appendAcDbEntity(lineId, pLine1); </font></div>
<div><font color="#800080">//虽然这么写不太严谨,但后面你对lineId也没做什么操作所以就这么给你添加上了,希望你能了解就好</font></div>
<div><font color="#800080"></font> </div>
<div> // 关闭图形数据库的各种对象 </div>
<div> pBlockTable->close(); </div>
<div> pBlockTableRecord->close(); </div>
<div> pLine->close(); </div>
<div><font color="#800080">//千万别忘了关闭实体,否则日后头疼的问题会出现很多</font></div>
<div><font color="#800080"> pLine1->close();</font></div> 好人! 谢谢 现在完全理解了
页:
[1]