yulinxx 发表于 2010-8-25 17:07:00

[求助]ARX 如何画两根或多根直线

<div>我是ARX初学者,画一根直线我现在是可以画了,</div><div><br/></div><div>可是如果画两根呢? 具体怎么操作?</div><div><br/></div><div>望指点 谢谢</div>

th_gsb 发表于 2010-8-26 08:36:00

<p>一条都会了,多条又有何困难的呢?</p>
<p>代码都是一样的啊,修改一个第一条直线的端点坐标不就可以了嘛。</p>

yulinxx 发表于 2010-8-26 09:00:00

<div>我用向导生成的。再在里面加上如下代码创建一直线,代码是教材里面的</div><div>改的话,改了 ptStart &nbsp;ptEnd坐标就可以了? &nbsp;那我创建两条的话,是不是要创建总共四个点?</div><div><br/></div><div>那些指针也得新增一些?</div><div>具体有一个代码就好了,我看一下可能就会明白 了</div><div><br/></div><div><br/></div><div><br/></div><div><br/></div><div>// 在内存上创建一个新的对象&nbsp;</div><div>&nbsp;&nbsp;AcGePoint3d ptStart(0, 0, 0);&nbsp;</div><div>&nbsp;&nbsp;AcGePoint3d ptEnd(100, 100, 0);&nbsp;</div><div>&nbsp;&nbsp;AcDbLine *pLine = new AcDbLine(ptStart, ptEnd);&nbsp;</div><div>&nbsp;&nbsp;</div><div>&nbsp;// 获得指向块表的指针&nbsp;</div><div>&nbsp;AcDbBlockTable *pBlockTable;&nbsp;</div><div>&nbsp;acdbHostApplicationServices()-&gt;workingDatabase()&nbsp;</div><div>&nbsp;&nbsp;-&gt;getBlockTable(pBlockTable, AcDb::kForRead);&nbsp;</div><div>&nbsp;</div><div>&nbsp;// 获得指向特定的块表记录(模型空间)的指针&nbsp;</div><div>&nbsp;AcDbBlockTableRecord *pBlockTableRecord;&nbsp;</div><div>&nbsp;&nbsp; &nbsp;pBlockTable-&gt;getAt(ACDB_MODEL_SPACE, pBlockTableRecord,&nbsp;</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;AcDb::kForWrite); &nbsp; &nbsp;&nbsp;</div><div>&nbsp;&nbsp;</div><div>&nbsp;// 将AcDbLine类的对象添加到块表记录中&nbsp;</div><div>&nbsp;AcDbObjectId lineId;&nbsp;</div><div>&nbsp;&nbsp; &nbsp;pBlockTableRecord-&gt;appendAcDbEntity(lineId, pLine);&nbsp;</div><div>&nbsp;&nbsp;</div><div>&nbsp;// 关闭图形数据库的各种对象&nbsp;</div><div>&nbsp;pBlockTable-&gt;close();&nbsp;</div><div>&nbsp;&nbsp; &nbsp;pBlockTableRecord-&gt;close();&nbsp;</div><div>&nbsp;&nbsp; &nbsp;pLine-&gt;close(); &nbsp;</div>

th_gsb 发表于 2010-8-30 15:51:00

<div>// 在内存上创建一个新的对象&nbsp;</div>
<div>&nbsp;&nbsp;AcGePoint3d ptStart(0, 0, 0);&nbsp;</div>
<div>&nbsp;&nbsp;AcGePoint3d ptEnd(100, 100, 0);&nbsp;</div>
<div>&nbsp;&nbsp;AcDbLine *pLine = new AcDbLine(ptStart, ptEnd);&nbsp;</div>
<div><font color="#800080">&nbsp;&nbsp;//再加一条</font>
<div><font color="#800080">&nbsp;&nbsp;AcGePoint3d ptStart1(0, 0, 0);&nbsp;</font></div>
<div><font color="#800080">&nbsp;&nbsp;AcGePoint3d ptEnd1(0, 100, 0);&nbsp;</font></div>
<div><font color="#800080">&nbsp;&nbsp;AcDbLine *pLine1 = new AcDbLine(ptStart1, ptEnd1);&nbsp;</font></div></div>
<div>&nbsp;// 获得指向块表的指针&nbsp;</div>
<div>&nbsp;AcDbBlockTable *pBlockTable;&nbsp;</div>
<div>&nbsp;acdbHostApplicationServices()-&gt;workingDatabase()&nbsp;</div>
<div>&nbsp;&nbsp;-&gt;getBlockTable(pBlockTable, AcDb::kForRead);&nbsp;</div>
<div>&nbsp;</div>
<div>&nbsp;// 获得指向特定的块表记录(模型空间)的指针&nbsp;</div>
<div>&nbsp;AcDbBlockTableRecord *pBlockTableRecord;&nbsp;</div>
<div>&nbsp;&nbsp; &nbsp;pBlockTable-&gt;getAt(ACDB_MODEL_SPACE, pBlockTableRecord,&nbsp;</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;AcDb::kForWrite); &nbsp; &nbsp;&nbsp;</div>
<div>&nbsp;&nbsp;</div>
<div>&nbsp;// 将AcDbLine类的对象添加到块表记录中&nbsp;</div>
<div>&nbsp;AcDbObjectId lineId;&nbsp;</div>
<div>&nbsp;&nbsp; &nbsp;pBlockTableRecord-&gt;appendAcDbEntity(lineId, pLine);&nbsp;</div>
<div><font color="#800080">&nbsp;&nbsp;//&nbsp;将第二条线也加进模型空间中</font></div>
<div><font color="#800080">pBlockTableRecord-&gt;appendAcDbEntity(lineId, pLine1);&nbsp;</font></div>
<div><font color="#800080">//虽然这么写不太严谨,但后面你对lineId也没做什么操作所以就这么给你添加上了,希望你能了解就好</font></div>
<div><font color="#800080"></font>&nbsp;</div>
<div>&nbsp;// 关闭图形数据库的各种对象&nbsp;</div>
<div>&nbsp;pBlockTable-&gt;close();&nbsp;</div>
<div>&nbsp;&nbsp; &nbsp;pBlockTableRecord-&gt;close();&nbsp;</div>
<div>&nbsp;&nbsp; &nbsp;pLine-&gt;close(); &nbsp;</div>
<div><font color="#800080">//千万别忘了关闭实体,否则日后头疼的问题会出现很多</font></div>
<div><font color="#800080">&nbsp;&nbsp;&nbsp; pLine1-&gt;close();</font></div>

yulinxx 发表于 2010-8-31 12:43:00

好人! 谢谢 现在完全理解了
页: [1]
查看完整版本: [求助]ARX 如何画两根或多根直线