Exemplo n.º 1
3
void Additional_Class::addXdata( AcDbObjectId entID, CString xdataStr, CString xdataNameStr )
{
	AcDbEntity * pEnt;
	struct resbuf * pRb;

	if(Acad::eOk != acdbOpenAcDbEntity(pEnt, entID, AcDb::kForWrite))
	{
		pEnt->close();
		return;
	}
	TCHAR * tempTchar = CString2TCHAR(xdataNameStr);
	//TCHAR strAppName[] = tempTchar;
	acdbRegApp(tempTchar);
	TCHAR  * typeName = CString2TCHAR(xdataStr);

	struct resbuf * pTemp;
	pTemp = pEnt->xData(tempTchar);

	pRb = acutBuildList(AcDb::kDxfRegAppName, tempTchar,
		AcDb::kDxfXdAsciiString, typeName, 
		RTNONE);
	pEnt->setXData(pRb);

	acutRelRb(pRb);
	pEnt->close();
	return;
}
void frgExtractTopologicalEntsFromLinesAlgm::_extract_from_seg(Vertex2dsOnSegment2d &stru)
{
	// - 获取相关的线段(相交、重合)
	AcDbObjectIdArray ids;
	_search_related_segs(ids, stru.seg);

	// - 分为两类进行处理:相交和重叠
	// -- 增加起点和终点
	rlVertex2d *v = NULL;
	stru.vertex2ds.insert(std::make_pair(0.0, v));
	stru.vertex2ds.insert(std::make_pair(1.0, v));

	// -- 处理每一个线段
	AcDbEntity *entity = NULL;
	for (int i = 0; i < ids.length(); i++)
	{
		acdbOpenAcDbEntity(entity, ids[i], AcDb::kForRead);
		if (entity == NULL)
			continue;

		if (entity->isA() != AcDbLine::desc())
		{
			entity->close();
			continue;
		}
		AcDbLine *_line = (AcDbLine *)entity;

		AcGeLineSeg2d _seg(AcGePoint2d(_line->startPoint().x, _line->startPoint().y),
			AcGePoint2d(_line->endPoint().x, _line->endPoint().y));
		_line->close();

		_extract_vertices(stru, _seg);
	}
}
Exemplo n.º 3
0
static void CopyBack( AcDbEntity* pSrcEnt, const AcDbObjectId& objId )
{
    AcDbEntity* pEnt;
    acdbOpenAcDbEntity( pEnt, objId, AcDb::kForWrite );
    pEnt->copyFrom( pSrcEnt );
    pEnt->close();
}
Exemplo n.º 4
0
BOOL CDetailShow::OnInitDialog()
{
	CAcUiDialog::OnInitDialog();

	// TODO:  在此添加额外的初始化
	long len = m_objIds.length();
	//取得选择集的长度
	//遍历选择集中的实体,将其打开并修改其颜色为红色
	for (int i =0;i<len;i++)
	{
		ads_name entres;
		AcDbObjectId objId;
		AcDbEntity *obj;
		Acad::ErrorStatus es;
		es = acdbOpenAcDbEntity(obj, m_objIds[i], AcDb::kForRead, true);
		if (es == Acad::eOk) {
			LPCTSTR str;
			str = obj->isA()->name();
			m_listBox.AddString(str);
			obj->close();
		}
		
	}
	return TRUE;  // return TRUE unless you set the focus to a control
	// 异常: OCX 属性页应返回 FALSE
}
Exemplo n.º 5
0
void Additional_Class::Insert_TableRow( AcDbObjectId TableID, vector<CString> StrList)
{
	AcDbEntity *pEnt_Temp = NULL;
	Acad::ErrorStatus es = acdbOpenAcDbEntity(pEnt_Temp, TableID, AcDb::kForRead);
	if (es != Acad::eOk)
	{
		acutPrintf(_T("\nOPEN TABLE ERROR"));
		return;
	}
	if (!pEnt_Temp->isKindOf(AcDbTable::desc()))
	{
		acutPrintf(_T("\nENTITY NOT TABLE"));
		return;
	}
	AcDbTable *pTable = AcDbTable::cast(pEnt_Temp);
	int Row = pTable->numRows();
	int Col = pTable->numColumns();
	if (Col < StrList.size())
	{
		acutPrintf(_T("\nTABLE ERROR"));
		pTable->close();
		return;
	}
	double RowHeight = pTable->rowHeight(0);
	double TextHeight = pTable->textHeight(0, 0);
	pTable->insertRows(Row, RowHeight,1);
	for (int i=0; i<StrList.size(); i++)
	{
		pTable->setTextString(Row, i, StrList.at(i));
		pTable->setTextHeight(Row, i,TextHeight);
	}
	pTable->close();
	pEnt_Temp->close();
}
Exemplo n.º 6
0
AcGePoint3dArray Additional_Class::Get_PolyLinePointArray( AcDbObjectId PolyLineId )
{
	AcGePoint3dArray LineCorner_List;
	AcDbIntArray Osnap_List, GeomID_List;
	AcDbEntity *pEnt_Temp = NULL;
	Acad::ErrorStatus es = acdbOpenAcDbEntity(pEnt_Temp, PolyLineId, AcDb::kForRead);
	if (es != Acad::eOk)
	{
		acutPrintf(_T("\nOPEN ENTITY ERROR "));
		return LineCorner_List;
	}
	if (!pEnt_Temp->isKindOf(AcDbPolyline::desc()))
	{
		acutPrintf(_T("\nENETITY IS NOT POLYLINE"));
		return LineCorner_List;
	}
	AcDbPolyline *pPolyLine = AcDbPolyline::cast(pEnt_Temp);
	if (pPolyLine->getGripPoints(LineCorner_List, Osnap_List, GeomID_List) != Acad::eOk)
	{
		acutPrintf(_T("\nGET GRIP POINT ERROR!"));
		pPolyLine->close();
		return LineCorner_List;
	}
	pPolyLine->close();
	return LineCorner_List;
}
void frgExtractTopologicalEntsFromLinesAlgm::_extract_vertices_from_lines(std::vector<Vertex2dsOnSegment2d> &seg_pnts_pairs,
	const AcDbObjectIdArray &ids)
{
	AcDbEntity *entity = NULL;
	acedSetStatusBarProgressMeter(_T("正在提取每根线段上的节点..."), 0, ids.length());
	for (int i = 0; i < ids.length(); i++)
	{
		acdbOpenAcDbEntity(entity, ids[i], AcDb::kForRead);
		if (entity == NULL)
			continue;

		if (entity->isA() != AcDbLine::desc())
		{
			entity->close();
			continue;
		}
		AcDbLine *line = (AcDbLine *)entity;

		Vertex2dsOnSegment2d stru;
		stru.seg.set(AcGePoint2d(line->startPoint().x, line->startPoint().y),
			AcGePoint2d(line->endPoint().x, line->endPoint().y));
		entity->close();

		_extract_from_seg(stru);
		seg_pnts_pairs.push_back(stru);
		acedSetStatusBarProgressMeterPos(i);
	}
	acedRestoreStatusBar();
}
Exemplo n.º 8
0
int set_color_index(AcDbObjectId id, int color_index)
{
	AcDbEntity * pEnt;
	if (acdbOpenAcDbEntity(pEnt, id, AcDb::kForWrite) == Acad::eOk) {
		return set_color_index(pEnt, color_index);
	}
	return -1;
}
Exemplo n.º 9
0
void CDlgReadInfo::FlashEntity(AcDbObjectId ObjId) 
{ 
	LockDocument _Lock;

	AcDbEntity *pEnt=NULL; 
	AcTransaction* pTrans=actrTransactionManager->startTransaction();
	if(Acad::eOk != acdbOpenAcDbEntity(pEnt,ObjId,AcDb::kForWrite))
	{
		actrTransactionManager->endTransaction();
		return; 
	}
	pEnt->highlight(); 
	acedUpdateDisplay();


	DWORD dwCount=GetTickCount(); 
	while(1)
	{
		if(GetTickCount()-dwCount>=200) break;      
	}
	pEnt->unhighlight(); 
	acedUpdateDisplay();

	dwCount=GetTickCount(); 
	while(1)
	{
		if(GetTickCount()-dwCount>=200) break;      
	}
	pEnt->highlight(); 
	acedUpdateDisplay();
	dwCount=GetTickCount(); 
	while(1)
	{
		if(GetTickCount()-dwCount>=200) break;      
	}
	pEnt->unhighlight(); 
	acedUpdateDisplay();

	dwCount=GetTickCount(); 
	while(1)
	{
		if(GetTickCount()-dwCount>=200) break;      
	}
	pEnt->highlight(); 
	acedUpdateDisplay();
	dwCount=GetTickCount(); 
	while(1)
	{
		if(GetTickCount()-dwCount>=200) break;      
	}
	pEnt->unhighlight(); 
	acedUpdateDisplay();

	pEnt->close();

	actrTransactionManager->endTransaction();
}
Exemplo n.º 10
0
bool MySSGetFilter::canBeSelected(AcDbObjectId id) const
{
	bool ans = true;
	AcDbEntity * pEnt;
	if (acdbOpenAcDbEntity(pEnt, id, AcDb::kForRead) == Acad::eOk) {
		ans = canBeSelected(pEnt);
		pEnt->close();
	}
	return ans;
}
Exemplo n.º 11
0
void CMyDlg::UpdateListCtr()
{
	acDocManager->lockDocument(curDoc());
	int nCount = m_ListCtr.GetItemCount();
	acutPrintf("%d\n", nCount);
	long lId;
	CString str;
	AcDbObjectId LineId;
	AcDbEntity *pEnt = NULL;
	AcDbLine *pLine = NULL;
	Acad::ErrorStatus es;
	
	if (nCount > 0)
	{
			for (int i = 0; i < nCount; ++i)
			{
				str = m_ListCtr.GetItemText(i, 0);
				lId = atol(str);
				LineId.setFromOldId(lId);
				//获得指针
				es = acdbOpenAcDbEntity(pEnt, LineId, AcDb::kForWrite);

				//检查是否被删除
				pLine = AcDbLine::cast(pEnt);
				if (es == Acad::eWasErased)
				{
					m_ListCtr.DeleteItem(i);
					--m_lLineCnt;
					--i;
					--m_Row;
				} 
				//检查颜色
				else if (es == Acad::eOk)
				{
					if (pLine)
					{
						str = m_ListCtr.GetItemText(i, 1);
						Adesk::UInt16 usColor = (Adesk::UInt16)atoi(str);
						if (pLine->colorIndex() != usColor)
						{
							char *buf = (char*)malloc(20);
							itoa((int)pLine->colorIndex(), buf, 10);
							m_ListCtr.SetItemText(i, 1, buf);
							free(buf);
						}
						pLine->close();
					}
				}						
			}
	}
	
	UpdateData(FALSE);
	acDocManager->unlockDocument(curDoc());
}
Exemplo n.º 12
0
void Additional_Class::Delete_AcDbObject( AcDbObjectId LineID )
{
	AcDbEntity *pEnt_Temp;
	if (acdbOpenAcDbEntity(pEnt_Temp, LineID, AcDb::kForWrite) != Acad::eOk	)
	{
		acutPrintf(_T("\nOPEN ENTITY ERROR"));
		return;
	}
	pEnt_Temp->erase();
	pEnt_Temp->close();
	return;
}
bool
ArxDbgUtils::isOnLockedLayer(AcDbObjectId& id, bool printMsg)
{
    AcDbEntity* ent;
	Acad::ErrorStatus es = acdbOpenAcDbEntity(ent, id, AcDb::kForRead);
    if (es == Acad::eOk) {
        bool result = isOnLockedLayer(ent, printMsg);
        ent->close();
        return result;
    }

    return true;  // by default we "lock" data
}
Exemplo n.º 14
0
void Additional_Class::Get_PolyLine_Point( AcDbObjectId PolyLineId,AcGePoint3dArray &PointArray )
{
	AcDbEntity *pEnt_Temp = NULL;
	Acad::ErrorStatus es = acdbOpenAcDbEntity(pEnt_Temp, PolyLineId, AcDb::kForRead);
	if (es != Acad::eOk)
	{
		acutPrintf(_T("\nOPEN POLYLINE ERROR"));
		return;
	}
	if (!pEnt_Temp->isKindOf(AcDbPolyline::desc()))
	{
		acutPrintf(_T("\nENTITY IS NOT POLYLINE"));
		return;
	}
	AcDbPolyline *pPolyLine = AcDbPolyline::cast(pEnt_Temp);
	int num = pPolyLine->numVerts();
	AcGePoint3d Start_temp_PT,End_temp_PT;
	for (int index=0; index<num; index++)
	{
		if (pPolyLine->segType(index) == AcDbPolyline::kLine)
		{
			AcGeLineSeg3d tempLine;
			pPolyLine->getLineSegAt(index,tempLine);
			Start_temp_PT = tempLine.startPoint();
			End_temp_PT = tempLine.endPoint();
			PointArray.append(Start_temp_PT);
			PointArray.append(End_temp_PT);
		}
		else if (pPolyLine->segType(index) == AcDbPolyline::kArc)
		{
			AcGeCircArc2d tempArc;
			pPolyLine->getArcSegAt(index,tempArc);
			Start_temp_PT.set(tempArc.startPoint().x,tempArc.startPoint().y,0);
			End_temp_PT.set(tempArc.endPoint().x,tempArc.endPoint().y,0);
			PointArray.append(Start_temp_PT);
			PointArray.append(End_temp_PT);
		}
	}
	pEnt_Temp->close();
	AcGeIntArray IndexArray;
	for (int i=1; i<PointArray.length();i++)
	{
		if (PointArray[i] == PointArray[i-1])
		{
			IndexArray.append(i);
			PointArray.remove(PointArray[i]);
		}
	}
}
Exemplo n.º 15
0
void Additional_Class::RotateEnt( AcDbObjectId EntID, double RotateAng, AcGePoint3d InpPt)
{
	AcDbEntity *pEnt_Temp;
	if (acdbOpenAcDbEntity(pEnt_Temp, EntID, AcDb::kForWrite) != Acad::eOk)
	{
		acutPrintf(_T("\nOPEN ERROR"));
		return;
	}
	 AcGeMatrix3d tt;
	 AcGeVector3d zAxis;
	 zAxis.set(0,0,1);
	tt.setToRotation(RotateAng, zAxis, InpPt);
	pEnt_Temp->transformBy(tt);
	pEnt_Temp->close();
}
Exemplo n.º 16
0
void ArxEntityHelper::TransformEntities2( const AcDbObjectIdArray& objIds, const AcGeMatrix3d& xform )
{
    if( objIds.isEmpty() ) return;

	int len = objIds.length();
    for( int i = 0; i < len; i++ )
    {
		AcDbEntity* pEnt;
		if( Acad::eOk == acdbOpenAcDbEntity( pEnt, objIds[i], AcDb::kForWrite ) )
		{
			pEnt->transformBy( xform );
			pEnt->close();
		}
    }
}
Exemplo n.º 17
0
void Additional_Class::Get_PolyLineType( AcDbObjectId PolyLineId,LINEINFO &LineInfo_List )
{
	double PI=3.1415926535897932384626433832795;
	AcDbEntity *pEnt_Temp = NULL;
	Acad::ErrorStatus es = acdbOpenAcDbEntity(pEnt_Temp, PolyLineId, AcDb::kForRead);
	if (es != Acad::eOk)
	{
		acutPrintf(_T("\nOPEN POLYLINE ERROR"));
		return;
	}
	if (!pEnt_Temp->isKindOf(AcDbPolyline::desc()))
	{
		acutPrintf(_T("\nENTITY NOT POLYLINE"));
		return;
	}
	AcDbPolyline *pPolyLine = AcDbPolyline::cast(pEnt_Temp);
	int num = pPolyLine->numVerts();
	LineInfo_List.push_back("");
	for (int index=0; index<num; index++)
	{
		if (pPolyLine->segType(index) == AcDbPolyline::kLine)
		{
			CString tempStr_Line;
			tempStr_Line = "直线段";
			LineInfo_List.push_back(tempStr_Line);
		}
		else if (pPolyLine->segType(index) == AcDbPolyline::kArc)
		{
			AcGeCircArc2d tempArc;
			pPolyLine->getArcSegAt(index,tempArc);
			double StartAngle = tempArc.startAng();
			double EndAngle = tempArc.endAng();
			double Angle = abs(EndAngle-StartAngle);
			Angle = (180/PI)*Angle;
			double Radius = tempArc.radius();
			CString tempStr_Angle,tempStr_Radius,sita,du,banjing;
			sita = "θ=";
			du = "°";
			banjing = "R=";
			tempStr_Angle.Format(_T("%.1f"),Angle);
			tempStr_Angle = sita+tempStr_Angle+du;
			tempStr_Radius.Format(_T("%.1f"),Radius);
			tempStr_Radius = banjing + tempStr_Radius;
			tempStr_Radius = tempStr_Angle+" "+tempStr_Radius;
			LineInfo_List.push_back(tempStr_Radius);
		}
	}
}
Exemplo n.º 18
0
CString Additional_Class::Get_Xdata(AcDbObjectId EntID, CString Xdata_Ref )
{
	AcDbEntity *pEnt;
	acdbOpenAcDbEntity(pEnt, EntID, AcDb::kForRead);
	struct resbuf *pRb;
	pRb = pEnt->xData(Xdata_Ref);
	if (pRb != NULL)
	{
		struct resbuf *pTemp;
		pTemp = pRb;
		pTemp = pTemp->rbnext;
		pEnt->close();
		return pTemp->resval.rstring;
	}
	acutRelRb(pRb);
	pEnt->close();
	return "";
}
Exemplo n.º 19
0
AcGePoint3d Additional_Class::Get_CenterPt( AcDbObjectId ObjID )
{
	AcDbEntity *pEnt = NULL;
	AcGePoint3d ptMax, ptMin, ptRes;
	ptRes.set(0,0,0);
	if	(Acad::eOk == acdbOpenAcDbEntity(pEnt, ObjID, AcDb::kForWrite))
	{
		AcDbExtents pEntExtent;
		pEnt->getGeomExtents(pEntExtent);
		ptMax = pEntExtent.maxPoint();
		ptMin = pEntExtent.minPoint();
		ptRes.x = (ptMax.x + ptMin.x)/2;
		ptRes.y = (ptMax.y + ptMin.y)/2;
		ptRes.z = (ptMax.z + ptMin.z)/2;
	}
	pEnt->close();
	return ptRes;
}
Acad::ErrorStatus
ArxDbgUtils::cloneAndXformObjects(AcDbDatabase* db, const AcDbObjectIdArray& entsToClone,
                        const AcDbObjectId& ownerBlockId,
                        const AcGeMatrix3d& xformMat, bool debugSpeak)
{
	ASSERT(db != NULL);

    AcDbIdMapping idMap;
    Acad::ErrorStatus es = db->deepCloneObjects(
                const_cast<AcDbObjectIdArray&>(entsToClone),
                const_cast<AcDbObjectId&>(ownerBlockId), idMap);

    if (es != Acad::eOk) {
        ArxDbgUtils::rxErrorMsg(es);
        return es;
    }

    AcDbEntity* clonedEnt;
    AcDbIdPair idPair;
    AcDbIdMappingIter iter(idMap);
    for (iter.start(); !iter.done(); iter.next()) {
        if (!iter.getMap(idPair))
            return Acad::eInvalidInput;

        if (idPair.isCloned()) {
            es = acdbOpenAcDbEntity(clonedEnt, idPair.value(), AcDb::kForWrite);
            if (es == Acad::eOk) {
                if (idPair.isPrimary()) {
                    if (debugSpeak)
                        acutPrintf(_T("\nCloned And Transformed: %s"), ArxDbgUtils::objToClassStr(clonedEnt));

                    clonedEnt->transformBy(xformMat);
                }
                else if (debugSpeak)
                    acutPrintf(_T("\nCloned: %s"), ArxDbgUtils::objToClassStr(clonedEnt));

                clonedEnt->close();
            }
            else
                ArxDbgUtils::rxErrorMsg(es);
        }
    }
    return Acad::eOk;
}
Exemplo n.º 21
0
void DrawHelper::LinkedGEJunctionClosure2( const AcDbObjectId& objId )
{
    AcDbEntity* pEnt;
    if( Acad::eOk != acdbOpenAcDbEntity( pEnt, objId, AcDb::kForRead ) ) return;

    LinkedGE* pEdge = LinkedGE::cast( pEnt );
    if( pEdge == 0 )
    {
        pEdge->close();
        return;
    }
    pEdge->close();

    AcGePoint3d startPt, endPt;
    pEdge->getSEPoint( startPt, endPt );

    LinkedGEJunctionClosure( startPt );
    LinkedGEJunctionClosure( endPt );
}
Exemplo n.º 22
0
Acad::ErrorStatus
AsdkBody::dwgInFields(AcDbDwgFiler* filer)
{
    assertWriteEnabled();
    Acad::ErrorStatus es;

    if ((es = AcDbEntity::dwgInFields(filer)) != Acad::eOk)
        return es;

    switch (filer->filerType()) 
    {
    case AcDb::kCopyFiler:    
    case AcDb::kDeepCloneFiler:
    case AcDb::kWblockCloneFiler:
        {
        void *i, *j;
        
        filer->readAddress(&i);
        filer->readAddress(&j);
        
        AcDbStub*   stub = (AcDbStub*)i;
        AcDbEntity* ent  = (AsdkBody*)j;
        
        if (NULL != stub) 
            acdbOpenAcDbEntity(ent, AcDbObjectId(stub), AcDb::kForRead, Adesk::kTrue);
        m_3dGeom = ((AsdkBody*)ent)->m_3dGeom.copy();
        if (NULL != stub)
            ent->close();
        }
        break;
        
    case AcDb::kFileFiler:     
    case AcDb::kUndoFiler:
    case AcDb::kPageFiler:

        m_3dGeom = Body::restore( &DwgFilerCallBack( filer ) );
        break;
        
    default:
        break;
    }
    return filer->filerStatus();
}
void
ArxDbgUiTdcPersistentReactors::detachSelectedObjs(const AcDbObjectIdArray& objIds) 
{
	Acad::ErrorStatus es;
	AcDbEntity* ent;
	ArxDbgPersistentObjReactor* peReactor;
	AcDbObjectId prId;

	ArxDbgDocLockWrite docLock;	// these potentially came from other documents

	int len = objIds.length();
	for (int i=0; i<len; i++) {
		es = docLock.lock(objIds[i].database());	// lock the document associated with this database
		if (es == Acad::eOk) {
			es = acdbOpenAcDbEntity(ent, objIds[i], AcDb::kForWrite, true);
			if (es == Acad::eOk) {
				prId = getPersistentObjReactor(objIds[i].database(), true);

				ent->removePersistentReactor(prId);

				es = acdbOpenObject(peReactor, prId, AcDb::kForWrite);
				if (es == Acad::eOk) {
					peReactor->detachFrom(ent->objectId());
					peReactor->close();
				}
				else {
					CString str;
					str.Format(_T("ERROR: Could not update backward reference in reactor: (%s)"), ArxDbgUtils::rxErrorStr(es));
					ArxDbgUtils::stopAlertBox(str);
				}

				ent->close();
			}
			else {
				ArxDbgUtils::rxErrorAlert(es);
			}
		}
		else {
			ArxDbgUtils::rxErrorAlert(es);
		}
	}
}
void
ArxDbgDbAdeskLogo::drawRefLine(AcGiCommonDraw* drawContext)
{
	AcDbEntity* ent;
	Acad::ErrorStatus es = acdbOpenAcDbEntity(ent, m_arbitraryRefEnt, AcDb::kForRead);
	if (es == Acad::eOk) {
		AcGePoint3d toPt;
		getReferenceAttachmentPoint(ent, toPt);
		ent->close();

		AcGePoint3d pts[2];
		pts[0] = location();
		pts[1] = toPt;

		Adesk::UInt16 curColor = drawContext->subEntityTraits().color();
		drawContext->subEntityTraits().setColor(1);
		drawContext->rawGeometry()->polyline(2, pts);
		drawContext->subEntityTraits().setColor(curColor);
	}
}
Exemplo n.º 25
0
void Additional_Class::Change_TextPosition(AcDbObjectId TextID, AcGePoint3d ptText )
{
	AcDbEntity *pEnt_Temp;
	if (acdbOpenAcDbEntity(pEnt_Temp, TextID, AcDb::kForWrite) != Acad::eOk)
	{
		acutPrintf(_T("\nOPEN TEXT ERROR"));
		return;
	}
	if (!pEnt_Temp->isKindOf(AcDbText::desc()))
	{
		acutPrintf(_T("\nENTITY IS NOT TEXT"));
		return;
	}
	AcDbText *pTextUpChange;
	pTextUpChange = AcDbText::cast(pEnt_Temp);
	pTextUpChange->setPosition(ptText);
	pEnt_Temp->close();
	pTextUpChange->close();
	return;
}
Exemplo n.º 26
0
void Additional_Class::Change_TablePoint( AcDbObjectId TableID,AcGePoint3d newPt )
{
	AcDbEntity *pEnt_Temp;
	if (acdbOpenAcDbEntity(pEnt_Temp, TableID, AcDb::kForWrite)!= Acad::eOk)
	{
		acutPrintf(_T("\nOPEN TABLE ERROR"));
		return;
	}
	if (!pEnt_Temp->isKindOf(AcDbTable::desc()))
	{
		acutPrintf(_T("\nENTITY NOT TABLE"));
		return;
	}
	AcDbTable *pTableChange;
	pTableChange = AcDbTable::cast(pEnt_Temp);
	pTableChange->setPosition(newPt);
	pEnt_Temp->close();
	pTableChange->close();
	return;
}
Exemplo n.º 27
0
void Additional_Class::Get_PolyLine_Length( AcDbObjectId PolyLineId, AcGeDoubleArray &LengthArray )
{
	double PI=3.1415926535897932384626433832795;
	AcDbEntity *pEnt_Temp = NULL;
	Acad::ErrorStatus es = acdbOpenAcDbEntity(pEnt_Temp, PolyLineId, AcDb::kForRead);
	if (es != Acad::eOk)
	{
		acutPrintf(_T("\nOPEN POLYLINE ERROR"));
		return;
	}
	if (!pEnt_Temp->isKindOf(AcDbPolyline::desc()))
	{
		acutPrintf(_T("\nENTITY NOT POLYLINE"));
		return;
	}
	AcDbPolyline *pPolyLine = AcDbPolyline::cast(pEnt_Temp);
	int num = pPolyLine->numVerts();
	for (int index=0; index<num; index++)
	{
		if (pPolyLine->segType(index) == AcDbPolyline::kLine)
		{
			AcGeLineSeg3d tempLine;
			pPolyLine->getLineSegAt(index,tempLine);
			double LineLength = tempLine.length();
			LengthArray.append(LineLength);
		}
		else if (pPolyLine->segType(index) == AcDbPolyline::kArc)
		{
			AcGeCircArc2d tempArc;
			pPolyLine->getArcSegAt(index,tempArc);
			double StartAngle = tempArc.startAng();
			double EndAngle = tempArc.endAng();
			double Angle = EndAngle-StartAngle;
			//Angle = (180/PI)*Angle;
			double Radius = tempArc.radius();
			double ArcLength = Radius*Angle;
			LengthArray.append(ArcLength);
		}
	}
	LengthArray.insertAt(0,0);
}
Exemplo n.º 28
0
void Additional_Class::Set_ObjectColor( AcDbObjectId ObID, int ColorIndex )
{
	AcDbEntity *pEnt_Temp;
	if (acdbOpenAcDbEntity(pEnt_Temp, ObID, AcDb::kForWrite) != Acad::eOk)
	{
		acutPrintf(_T("\nOPEN ERROR"));
		return;
	}
// 	ZcGeMatrix3d tt;
// 	tt.setToRotation(PI)
// 	pEnt_Temp->transformBy()
	//if (!pEnt_Temp->isKindOf(AcDbText::desc()))
	//{
	//	acutPrintf(_T("\nENTITY IS NOT TEXT"));
	//	return;
	//}
	pEnt_Temp->setColorIndex(ColorIndex);

	pEnt_Temp->close();
	return;
}
Exemplo n.º 29
0
void Additional_Class::Change_Line(AcDbObjectId LineID, AcGePoint3d ptStart, AcGePoint3d ptEnd )
{
	AcDbEntity *pEnt_Temp;
	if (acdbOpenAcDbEntity(pEnt_Temp, LineID, AcDb::kForWrite)!= Acad::eOk)
	{
		acutPrintf(_T("\nOPEN ENETITY ERROR"));
		return;
	}
	if (!pEnt_Temp->isKindOf(AcDbLine::desc()))
	{
		acutPrintf(_T("\nENTITY IS NOT LINE"));
		return;
	}
	AcDbLine *pLineChange;
	pLineChange = AcDbLine::cast(pEnt_Temp);
	AcGePoint3d pLineE;
	pLineChange->setStartPoint(ptStart);
	pLineChange->setEndPoint(ptEnd);
	pEnt_Temp->close();
	pLineChange->close();
	return;
}
Exemplo n.º 30
0
void CMyDlg::OnDelLine() 
{
	// TODO: Add your control notification handler code here
	int nItem;
	long lId;
	CString str;
	AcDbObjectId LineId;
	AcDbEntity *pEnt = NULL;
	AcDbLine *pLine = NULL;
	Acad::ErrorStatus es;

	acDocManager->lockDocument(curDoc());
	//在列表中删除选定行
	while(m_ListCtr.GetNextItem(-1, (LVNI_ALL | LVNI_SELECTED)) != -1)
	{
		nItem = m_ListCtr.GetNextItem(-1, (LVNI_ALL | LVNI_SELECTED));
		str = m_ListCtr.GetItemText(nItem, 0);
		//acutPrintf("%s\n", str);
		lId = atol(str);
		LineId.setFromOldId(lId);
		//获得指针
		es = acdbOpenAcDbEntity(pEnt, LineId, AcDb::kForWrite);
		//在模型空间删除相应实体
		pLine = AcDbLine::cast(pEnt);
		if (pLine)
		{
			pLine->erase();
			pLine->close();
			m_ListCtr.DeleteItem(nItem);
			--m_Row;
		}	
	}
	UpdateData(FALSE);
	
	acDocManager->unlockDocument(curDoc());	
}