ljlzm 发表于 2006-7-17 23:59:00

[ARX求助]ARX怎样获得模型空间中点中的实体并获得其对象数据

本帖最后由 作者 于 2006-7-18 9:12:03 编辑 <br /><br /> <P>各位大侠,我有几个问题请教,一直没解决,请各位帮忙</P>
<P>)(感谢高手批评,第一次发帖一着急贴错了,现更正如下)</P>
<P>(1)在CAD的模型控件直接点击选中一个实体,ARX怎样得到这个实体的句柄</P>
<P>(2)如果这个不能实现,那么我的下面的用选择集的程序有什么问题,为什么pEntity为空,如何再获得VBA里的Handle值</P>
<P>&nbsp;AcDbObject * pEntity;<BR>&nbsp;Acad::ErrorStatus es;<BR>&nbsp;long n=0&nbsp;</P>
<P>ads_name ssname;<BR>&nbsp;AcDbObjectId eId;<BR>&nbsp;acedSSGet(NULL,NULL,NULL,NULL,ssname);<BR>&nbsp;if(acedSSLength(ssname,&amp;n)!=RTNORM)<BR>&nbsp;{&nbsp; acutPrintf("<A href="file://n/" target="_blank" >\\n</A>获取选择集长度出错!"); <BR>&nbsp;&nbsp;return; <BR>&nbsp;}<BR>&nbsp;ads_name ent;<BR>&nbsp;for(long i=0;i&lt;=n;i++)<BR>&nbsp;{<BR>&nbsp;&nbsp;if(acedSSName(ssname,i,ent)!=RTNORM)<BR>&nbsp;&nbsp;{<BR>&nbsp;&nbsp;&nbsp;acutPrintf("<A href="file://n/" target="_blank" >\\n</A>获取选择集内第%d个实体出错!",i); </P>
<P>&nbsp;&nbsp;&nbsp; return;&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp; }<BR><BR>&nbsp;&nbsp;&nbsp; acdbGetObjectId(eId, ent);<BR>&nbsp;&nbsp;&nbsp; acdbOpenObject(pEntity, eId, AcDb::kForWrite);<BR>&nbsp;}<BR>&nbsp;acedSSFree(ssname);</P>
<P>(3)用VBA获得对象数据的如下程序如何用ARX实现?</P>
<P>Public Function GetOD(acadObject As AcadEntity)<BR>&nbsp;&nbsp;&nbsp; Dim AcadMap As Object<BR>&nbsp;&nbsp;&nbsp; Dim prj As Project<BR>&nbsp;&nbsp;&nbsp; Dim odTbl As odTable<BR>&nbsp;&nbsp;&nbsp; Dim odRds As ODRecords<BR>&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp; Set AcadMap = ThisDrawing.Application.GetInterfaceObject("AutoCADMap.Application.2")<BR>&nbsp;&nbsp;&nbsp; Set prj = AcadMap.Projects(ThisDrawing)<BR>&nbsp;&nbsp;&nbsp; prj.ProjectOptions.DontAddObjectsToSaveSet = True<BR>&nbsp;&nbsp;&nbsp; Set odTbl = prj.ODTables.Item("ObjectInfo")<BR>&nbsp;&nbsp;&nbsp; Set odRds = odTbl.GetODRecords<BR>&nbsp;&nbsp;&nbsp; boolVal = odRds.Init(acadObject, True, False)</P>
<P>&nbsp;&nbsp;&nbsp; GetOD = odRds.Record.Item(1).Value&nbsp;&nbsp; <BR>End Function</P>

pglyxq 发表于 2006-7-18 01:16:00

pglyxq 发表于 2006-7-18 01:31:00

ljlzm 发表于 2006-7-18 09:04:00

本帖最后由 作者 于 2006-7-18 10:56:52 编辑 <br /><br /> 不好意思,
<P>long n=0&nbsp;ads_name ssname;是上来的时候粘错了</P>
<P>AcGePoint3d ptInsert=pEntity-&gt;startPoint();也是后面的</P>
<P>现在把AcDbEntity * pEntity改为AcDbEntity * pEntity = NULL就可以了</P>
<P>请问楼上的高手我现在想由pEntity获得他的句柄应该怎么做</P>
页: [1]
查看完整版本: [ARX求助]ARX怎样获得模型空间中点中的实体并获得其对象数据