- UID
- 1
- 积分
- 15926
- 精华
- 贡献
-
- 威望
-
- 活跃度
-
- D豆
-
- 在线时间
- 小时
- 注册时间
- 2002-1-3
- 最后登录
- 1970-1-1
|
发表于 2002-10-11 13:40:50
|
显示全部楼层
下面的代码是XDRX_API里面关于拖动选择集部分的虚函数worldDraw(..)的实现,里面拖动BLOCK,考虑了属性等,你参考下
- [FONT=courier new]
- virtual Adesk::Boolean worldDraw(AcGiWorldDraw * wd)
- {
- wd->geometry().pushModelTransform(m_mat);
- AcDbEntity* pE;
- for (int i=0;i<m_idArray.length();i++)
- {
- if (acdbOpenObject(pE,m_idArray[i],AcDb::kForRead)==Acad::eOk)
- {
- // see if the entity is a block reference, if so then check for any attributes so we don't display the
- // definitions
- AcDbBlockReference *pBlockref = AcDbBlockReference::cast (pE);
- // if it is a block reference
- if (pBlockref != NULL)
- {
- // create an attribute iterator so we can check to see if any attribute asre attached
- AcDbObjectIterator *pAttributeIterator = pBlockref->attributeIterator ();
- // if it allocated ok
- if (pAttributeIterator != NULL)
- {
- AcDbObjectId ObjId;
- AcDbAttribute *pAttribute = NULL;
- // now loop through them
- for (int count=0; !pAttributeIterator->done(); pAttributeIterator->step(), ++count)
- {
- // get the object id of the attribute
- ObjId = pAttributeIterator->objectId();
- // open the object so we can draw it
- if (acdbOpenObject (pAttribute, ObjId, AcDb::kForRead) != Acad::eOk)
- continue;
- // now draw it
- wd->geometry().draw (pAttribute);
- // now close the attribute
- pAttribute->close();
- }
- // delete the iterator
- delete pAttributeIterator;
-
- // see if we have any attributes attached to this block
- // if we have then to stop the attribute definitions being drawn
- if (count)
- {
- AcDbVoidPtrArray entitySet;
- // explode and get some temporary entities
- Acad::ErrorStatus es = pBlockref->explode (entitySet);
- // if it worked ok
- if (es == Acad::eOk)
- {
- // loop round getting the intersection points
- for (long i=0l; i<entitySet.length (); ++i)
- {
- // get a pointer to the entity object
- AcDbEntity *pNewEnt = (AcDbEntity *)entitySet.at (i);
-
- AcDbAttributeDefinition *pAttributeDef = AcDbAttributeDefinition::cast (pNewEnt);
- // if it is NOT an attribute definition
- if (pAttributeDef == NULL)
- {
- // then draw it
- wd->geometry().draw (pNewEnt);
- }
-
- // delete the temporary entity
- delete pNewEnt;
- }
- }
- }
- // no attributes - just draw
- else
- {
- wd->geometry().draw(pE);
- }
- }
- // failed attribute iterator - just draw it
- else
- {
- wd->geometry().draw(pE);
- }
- }
- // not a block reference - just draw then
- else
- {
- wd->geometry().draw(pE);
- }
- pE->close();
- }
- }
-
- wd->geometry().popModelTransform();
- return Adesk::kTrue;
- }
- [/FONT]
复制代码 |
|