- UID
- 9841
- 积分
- 0
- 精华
- 贡献
-
- 威望
-
- 活跃度
-
- D豆
-
- 在线时间
- 小时
- 注册时间
- 2002-9-12
- 最后登录
- 1970-1-1
|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?立即注册
×
#if !defined(_SELECTENTITYARRAY_H)
#define _SELECTENTITYARRAY_H
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#include "dbmain.h"
#include "StdArx.h"
#include "acgi.h"
class SelectEntityArray : public AcDbEntity
{
AcGeMatrix3d m_mat;
AcDbObjectIdArray m_IdArray;
public:
void setTransform(const AcGeMatrix3d& mat)
{
m_mat=mat;
}
void setObjectIdArray(const AcDbObjectIdArray& marray)
{
m_IdArray=marray;
}
virtual Adesk::Boolean worldDraw(AcGiWorldDraw* mode)
{
AcDbEntity *pEntity=NULL;
AcGePoint3d parray[2];
AcGePoint3d p1;
AcDbLine *pLine=NULL;
AcDbCircle *pCircle=NULL;
Acad::ErrorStatus es=Acad::eOk;
for(int i=0;i<m_IdArray.length();i++)
{
es=acdbOpenAcDbEntity(pEntity,m_IdArray.at(i),AcDb::kForRead);
if(es!=Acad::eOk)
continue;
pLine=AcDbLine::cast(pEntity);
if(pLine)
{
p1=pLine->endPoint();
p1=p1.transformBy(m_mat);
parray[0]=p1;
p1=pLine->startPoint();
p1=p1.transformBy(m_mat);
parray[1]=p1;
pLine->close();
mode->geometry().polyline(2,parray);
continue;
}
pCircle=AcDbCircle::cast(pEntity);
if(pCircle)
{
p1=pCircle->center();
p1=p1.transformBy(m_mat);
mode->geometry().circle(p1,pCircle->radius(),pCircle->normal());
pCircle->close();
continue;
}
//在这里可以增加其他对象 AcDbPolyline AcDbMline .....
}
return Adesk::kTrue;
}
};
#endif
//
// ObjectARX defined commands, created by [九月/12/2002], ,
#include "StdAfx.h"
#include "StdArx.h"
class SelectJig : public AcEdJig
{
public :
SelectJig(const AcDbObjectIdArray&,const AcGePoint3d p1);
virtual ~SelectJig();
void doIt();
virtual DragStatus sampler();
virtual Adesk::Boolean update();
virtual AcDbEntity * entity()const;
void append();
private:
SelectEntityArray *pSelect;
AcGeMatrix3d m_max;
AcGePoint3d m_point1,m_point2;
AcDbObjectIdArray m_IdArray;
};
SelectJig::SelectJig(const AcDbObjectIdArray& idarray,const AcGePoint3d p1)
{
m_IdArray=idarray;
m_point1=p1;
}
SelectJig::~SelectJig()
{
delete pSelect;
}
void SelectJig::doIt()
{
pSelect=new SelectEntityArray;
pSelect->setObjectIdArray(m_IdArray);
drag();
append();
}
AcEdJig::DragStatus
SelectJig::sampler()
{
DragStatus stat;
static AcGePoint3d point1;
stat = acquirePoint(m_point2);
if(point1!=m_point2)
point1=m_point2;
else if(stat== AcEdJig::kNormal)
return AcEdJig::kNoChange;
return stat;
}
Adesk::Boolean
SelectJig::update()
{
AcGeVector3d vect=m_point2-m_point1;
m_max=AcGeMatrix3d(vect);
pSelect->setTransform(m_max);
return Adesk::kTrue;
}
AcDbEntity *
SelectJig::entity()const
{
return pSelect;
}
void SelectJig::append()
{
AcDbObjectId objId;
AcDbEntity *pEntity=NULL;
int len1=m_IdArray.length();
if(len1==0)
return;
for(int i=0;i<len1;i++)
{
objId=m_IdArray.at(i);
if(acdbOpenAcDbEntity(pEntity,objId,AcDb::kForWrite)!=Acad::eOk)
continue;
pEntity->transformBy(m_max);
pEntity->close();
}
}
//-----------------------------------------------------------------------------
// This is command 'YY, by [九月/12/2002], ,
void ZFSyanchengyy()
{
#ifdef OARXWIZDEBUG
acutPrintf ("\nOARXWIZDEBUG - ZFSyanchengyy() called.");
#endif // OARXWIZDEBUG
ads_name namess,name1;
AcGePoint3d pickpoint;
long len;
if(acedSSGet(NULL,NULL,NULL,NULL,namess)!=RTNORM)
return;
if(acedSSLength(namess,&len)!=RTNORM)
return;
AcDbObjectId id;
AcDbObjectIdArray idarray;
for(int i=0;i<len;i++)
{
if(acedSSName(namess,i,name1)!=RTNORM)
{ acedSSFree(namess);
return;
}
if(acdbGetObjectId(id,name1)!=Acad::eOk)
{ acedSSFree(namess);
return;
}
idarray.append(id);
}
if(idarray.length()==0)
{ acedSSFree(namess);
return;
}
acedSSFree(namess);
if(acedGetPoint(NULL,NULL,asDblArray(pickpoint))!=RTNORM)
return;
SelectJig *jig=new SelectJig(idarray,pickpoint);
jig->doIt();
delete jig;
} |
|