2026-10-04 00:04:20 +08:00
|
|
|
#include "stdafx.h"
|
2026-09-28 15:28:50 +08:00
|
|
|
#include "AecGiSubEntityTraits.h"
|
|
|
|
|
|
|
|
|
|
AecGiSubEntityTraits::AecGiSubEntityTraits()
|
|
|
|
|
{
|
|
|
|
|
m_nColor = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
AecGiSubEntityTraits::AecGiSubEntityTraits(const AecGiSubEntityTraits &src)
|
|
|
|
|
{
|
|
|
|
|
*this = src;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
AecGiSubEntityTraits::~AecGiSubEntityTraits()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
AecGiSubEntityTraits & AecGiSubEntityTraits::operator = (const AecGiSubEntityTraits &src)
|
|
|
|
|
{
|
|
|
|
|
m_idLayer = src.m_idLayer;
|
|
|
|
|
m_nColor = src.m_nColor;
|
|
|
|
|
m_idLineType = src.m_idLineType;
|
|
|
|
|
m_idMaterial = src.m_idMaterial;
|
|
|
|
|
return *this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
CString GetSymbolName(AcDbObjectId idSymbolRec)
|
|
|
|
|
{
|
|
|
|
|
CString sName = _T("0");
|
|
|
|
|
AcDbSymbolTableRecord* pStyleRec = NULL;
|
|
|
|
|
if ( Acad::eOk == acdbOpenObject((AcDbObject*&)pStyleRec,idSymbolRec,AcDb::kForRead))
|
|
|
|
|
{
|
|
|
|
|
const TCHAR *pszName = NULL;
|
|
|
|
|
pStyleRec->getName(pszName);
|
|
|
|
|
if (pszName != NULL)
|
|
|
|
|
{
|
|
|
|
|
sName = pszName;
|
|
|
|
|
}
|
|
|
|
|
pStyleRec->close();
|
|
|
|
|
}
|
|
|
|
|
return sName;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void AecGiSubEntityTraits::SetFrom(const AcDbEntity *pEnt)
|
|
|
|
|
{
|
|
|
|
|
int color = pEnt->colorIndex();
|
|
|
|
|
AcDbObjectId layer = pEnt->layerId();
|
|
|
|
|
AcDbObjectId lineType = pEnt->linetypeId();
|
|
|
|
|
|
|
|
|
|
if (!m_idLayer)
|
|
|
|
|
{
|
|
|
|
|
m_idLayer = layer;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (!!layer)
|
|
|
|
|
{
|
|
|
|
|
CString sName = GetSymbolName(layer);
|
|
|
|
|
if (sName.CompareNoCase( _T("0") ) != 0)
|
|
|
|
|
{
|
|
|
|
|
m_idLayer = layer;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!m_nColor)
|
|
|
|
|
{
|
|
|
|
|
m_nColor = color;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (color > 0 && color <= 256)
|
|
|
|
|
{
|
|
|
|
|
m_nColor = color;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!m_idLineType)
|
|
|
|
|
{
|
|
|
|
|
m_idLineType = lineType;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (!!lineType)
|
|
|
|
|
{
|
|
|
|
|
CString sName = GetSymbolName(lineType);
|
|
|
|
|
if (sName.CompareNoCase( _T("0") ) != 0)
|
|
|
|
|
{
|
|
|
|
|
m_idLineType = lineType;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#if ARX > 16
|
|
|
|
|
AcDbObjectId material = pEnt->materialId();
|
|
|
|
|
if (!m_idMaterial)
|
|
|
|
|
{
|
|
|
|
|
m_idMaterial = material;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (!!material)
|
|
|
|
|
{
|
|
|
|
|
ACHAR *sName = pEnt->material();
|
|
|
|
|
if (sName != NULL)
|
|
|
|
|
{
|
|
|
|
|
if (_tcsicmp(sName, _T("BYBLOCK")) != 0)
|
|
|
|
|
{
|
|
|
|
|
m_idMaterial = material;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
acutDelString(sName);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void AecGiSubEntityTraits::SetTo(AcDbEntity *pEnt) const
|
|
|
|
|
{
|
|
|
|
|
int nColor = pEnt->colorIndex();
|
|
|
|
|
AcDbObjectId idLayer = pEnt->layerId();
|
|
|
|
|
AcDbObjectId idLineType = pEnt->linetypeId();
|
|
|
|
|
if ((nColor == 0 || nColor > 256) && m_nColor > 0 && m_nColor <= 256)
|
|
|
|
|
{
|
|
|
|
|
pEnt->setColorIndex(m_nColor);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!!m_idLayer)
|
|
|
|
|
{
|
|
|
|
|
if (!idLayer)
|
|
|
|
|
{
|
|
|
|
|
pEnt->setLayer(m_idLayer);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
CString sName = GetSymbolName(idLayer);
|
|
|
|
|
if (sName.CompareNoCase(_T("0")) == 0)
|
|
|
|
|
{
|
|
|
|
|
pEnt->setLayer(m_idLayer);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!!m_idLineType)
|
|
|
|
|
{
|
|
|
|
|
if (!idLineType)
|
|
|
|
|
{
|
|
|
|
|
pEnt->setLinetype(m_idLineType);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
CString sName = GetSymbolName(idLineType);
|
|
|
|
|
if (sName.CompareNoCase(_T("BYBLOCK")) == 0)
|
|
|
|
|
{
|
|
|
|
|
pEnt->setLinetype(m_idLineType);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#if ARX > 16
|
|
|
|
|
AcDbObjectId idMaterial = pEnt->materialId();
|
|
|
|
|
if (!!m_idMaterial)
|
|
|
|
|
{
|
|
|
|
|
if (!idMaterial)
|
|
|
|
|
{
|
|
|
|
|
pEnt->setMaterial(m_idMaterial);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
ACHAR* sName = pEnt->material();
|
|
|
|
|
if (sName!=NULL)
|
|
|
|
|
{
|
|
|
|
|
if (sName == _T("BYBLOCK"))
|
|
|
|
|
{
|
|
|
|
|
pEnt->setMaterial(m_idMaterial);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
acutDelString(sName);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void AecGiSubEntityTraits::SetTo(AcDbVoidPtrArray &entSet) const
|
|
|
|
|
{
|
|
|
|
|
int nLen = entSet.length();
|
|
|
|
|
for(int i = 0; i < nLen; i++)
|
|
|
|
|
{
|
|
|
|
|
AcDbEntity *pEnt = (AcDbEntity *)entSet[i];
|
|
|
|
|
SetTo(pEnt);
|
|
|
|
|
}
|
|
|
|
|
}
|