修改线方向
修改线方向(line, lwpolyline, polyline)请下载rtf文件:
//取得POLYLINE结点坐标<BR>void<BR>collectVertices(const AcDb2dPolyline* pline, AcGePoint3dArray& pts, bool asWcsPts)<BR>{<BR> ASSERT(pline != NULL);<BR> ASSERT(pts.isEmpty());
AcDbObjectIterator* vertexIter = pline->vertexIterator();<BR> ASSERT(vertexIter != NULL);<BR> if (vertexIter == NULL)<BR> return;
AcDb2dVertex* vertex;<BR> for (; !vertexIter->done(); vertexIter->step()) {
if (acdbOpenObject(vertex, vertexIter->objectId(), AcDb::kForRead) == Acad::eOk) {<BR> AcGePoint3d pp(pline->vertexPosition(*vertex));<BR> if (vertex->vertexType() != AcDb::k2dSplineCtlVertex) {<BR> if (asWcsPts)<BR> pts.append(pline->vertexPosition(*vertex)); // return WCS<BR> else<BR> pts.append(vertex->position()); // return ECS<BR> }<BR> vertex->close();<BR> }<BR> }<BR> delete vertexIter;
ASSERT(pts.isEmpty() == Adesk::kFalse);
if (pline->isClosed()) {<BR> AcGePoint3d tmpPt = pts; // used to be a bug in dynamic arrays (not sure if its still there??)<BR> pts.append(tmpPt);<BR> }<BR>}
//取得LWPOLYLINE结点坐标<BR>void<BR>collectVertices(const AcDbPolyline* pline, AcGePoint3dArray& pts)<BR>{<BR> ASSERT(pline != NULL);<BR> ASSERT(pts.isEmpty());
AcGePoint3d pt;<BR> for (int vertexNumber = 0; vertexNumber < pline->numVerts(); vertexNumber++) {<BR> pline->getPointAt(vertexNumber, pt);<BR> pts.append(pt);<BR> }
ASSERT(pts.isEmpty() == Adesk::kFalse);
if (pline->isClosed()) {<BR> AcGePoint3d tmpPt = pts;<BR> pts.append(tmpPt);<BR> }<BR>} 实体定位工具 : <A href="http://www.mjtd.com/mcdown/list.asp?id=524" target="_blank" >http://www.mjtd.com/mcdown/list.asp?id=524</A>
动态查询.swf
通过自定义的窗口显示实体查询信息:本帖最后由 作者 于 2005-5-6 12:22:03 编辑 <br /><br /> 有时在程序中修改了实体,比如删除了实体,但在屏幕上没有及时地刷新,这时执行屏幕选取实体函数acedSSGet(), <BR><BR>仍然能够选中原来的实体,明明它们已经删除了,这时怎么办呢,考虑用acedCommand(RTSTR, "REGEN", RTNONE); <BR><BR>虽然也可以,但它会重新生成整个图形数据库,如果数据量很大,那么重生成的速度会很慢, <BR><BR>这样就不可能在程序的一段循环语句中修改每一个实体后都对数据库重生成,那程序运行的时间大部分都花在刷新数据库上了, <BR><BR>显然这不合理. <BR><BR>解决方法: <BR><BR> <SPAN style="FONT-SIZE: 9pt; COLOR: #008000; FONT-FAMILY: 新宋体">// 刷新显示屏幕 <BR></SPAN> actrTransactionManager->flushGraphics(); <BR> acedUpdateDisplay(); <DIV id=mainbody><SPAN style="FONT-SIZE: 9pt; COLOR: #008000; FONT-FAMILY: 宋体">[整理]<BR><BR>默认状态下AutoCAD2004是多文档应用程序,系统变量SDI=0, <BR><BR>acdbHostApplicationServices()->workingDatabase(); <BR><BR>不是指一个文档,而是多个文档.当使用模态对话框时,这个对话框资源属于唯一的一个文档,所以不会产生错误; <BR>而使用非模态对话框时,对话框资源不属于任何一个文档,如果修改往数据库(写操作),就会导致AutoCAD异常. <BR><BR>解决的方法是: <BR><BR>使用非模态对话框时要显式地管理文档的状态,当然,如果不需要多文档,则将系统变量SDI设为1也能解决非模态对话框的问题, <BR>一般以写的方式操作实体时,要将当前文档锁定,操作结束后,解锁文档,而以读的方式打开对象,不需要锁定文档: <BR><BR>acDocManager->lockDocument(acDocManager->curDocument(), AcAp::kWrite, NULL, NULL, <SPAN style="FONT-SIZE: 9pt; COLOR: #0000ff; FONT-FAMILY: 新宋体">true</SPAN></SPAN>); <BR><BR>这个函数的使用是锁定文档以便访问它们的资源,这些资源包括与文档相关联的的数据库对象(AcDbDatabases objects associated with a document),以及这些数据库中的实体对象(AcDbObject objects),还有数据库常驻系统变量(all AcDbDatabase resident system variables). <BR>它还包括了基于系统变量的所有文档(all document based system variables),及与文档关联的事务管理器(the Transaction Manager associated with a document).文档在以AcDb::kForRead打开一个AcDbObject对象时不需要锁定,读取系统变量时也不需要锁定文档. <BR>... <BR>acDocManager->unlockDocument(acDocManager->curDocument()); <BR><BR><BR>示例: <BR><BR><SPAN style="FONT-SIZE: 9pt; COLOR: #0000ff; FONT-FAMILY: 新宋体">void</SPAN></SPAN> lockDocument_Test() <BR>{ <BR> AcGePoint3d start(0.0,0.0,0.0), end(10.0,10.0,0.0); <BR> AcDbLine *line = <SPAN style="FONT-SIZE: 9pt; COLOR: #0000ff; FONT-FAMILY: 新宋体">new</SPAN></SPAN> AcDbLine(start, end); <BR> AcDbBlockTable *pBlockTable; <BR><BR> <SPAN style="FONT-SIZE: 9pt; COLOR: #008000; FONT-FAMILY: 新宋体">// 锁定当前文档 <BR></SPAN></SPAN> acDocManager->lockDocument(acDocManager->curDocument(), AcAp::kWrite, NULL, NULL, <SPAN style="FONT-SIZE: 9pt; COLOR: #0000ff; FONT-FAMILY: 新宋体">true</SPAN></SPAN>); <BR><BR> acDocManager->curDocument()->database()->getBlockTable(pBlockTable, AcDb::kForRead); <BR> <SPAN style="FONT-SIZE: 9pt; COLOR: #008000; FONT-FAMILY: 新宋体">//acdbHostApplicationServices()->workingDatabase()->getBlockTable(pBlockTable, AcDb::kForRead); <BR></SPAN></SPAN> AcDbBlockTableRecord *pBlockTableRec; <BR> pBlockTable->getAt(ACDB_MODEL_SPACE, pBlockTableRec, AcDb::kForWrite); <BR> pBlockTable->close(); <BR> AcDbObjectId objId; <BR> pBlockTableRec->appendAcDbEntity(objId, line); <BR> line->close(); <BR> pBlockTableRec->close(); <BR> <SPAN style="FONT-SIZE: 9pt; COLOR: #008000; FONT-FAMILY: 新宋体">// 运行完解锁文档 <BR></SPAN></SPAN> acDocManager->unlockDocument(acDocManager->curDocument()); <BR>} <BR></DIV> <A name=80974><FONT color=#990000><B>王咣生</B></FONT></A>:
请看以下这个版本多文档原代码