コード例 #1
2
ファイル: XData.cpp プロジェクト: kevinzhwl/ZRXSDKMod
void addXData()
{
	// Get an Entity.
	ads_name mnEnt;
    ads_point ptSel;
    int nRet = acedEntSel(_T("\nSelect an Entity: "), mnEnt, ptSel);
	if (nRet != RTNORM)
		return;
	AcDbObjectId oid;
	
    Acad::ErrorStatus retStat;
    retStat = acdbGetObjectId(oid, mnEnt);
    if (retStat != Acad::eOk)
		return;

    AcDbObject* pObj = NULL;

    if ((retStat = acdbOpenObject(pObj, oid, AcDb::kForRead)) != Acad::eOk)
    {
        return;
    }
	// Get new XData.
	TCHAR appName[132] = {0};
	TCHAR resString[200] = {0};

    acedGetString(NULL, _T("\nEnter application name: "), appName);
    acedGetString(NULL, _T("\nEnter string to be added: "), resString);

    // XData
    resbuf *pRb = NULL;
	resbuf *pTemp = NULL;
    
    pRb = pObj->xData(appName);

    if (pRb != NULL)
	{
        for (pTemp = pRb; pTemp->rbnext != NULL; pTemp = pTemp->rbnext);
    }
	else
	{
        acdbRegApp(appName);
        pRb = acutNewRb(AcDb::kDxfRegAppName);
        pTemp = pRb;
        pTemp->resval.rstring = (TCHAR*)malloc((_tcslen(appName) + 1) * sizeof(TCHAR));
        _tcscpy(pTemp->resval.rstring, appName);
    }

    pTemp->rbnext = acutNewRb(AcDb::kDxfXdAsciiString);
    pTemp = pTemp->rbnext;
    pTemp->resval.rstring = (TCHAR*)malloc((_tcslen(resString) + 1) * sizeof(TCHAR));
    _tcscpy(pTemp->resval.rstring, resString);

	// Set XData.
    pObj->upgradeOpen();
    pObj->setXData(pRb);
    
    pObj->close();
    acutRelRb(pRb);
}
コード例 #2
1
void
ArxDbgUtils::collectVertices(const AcDb3dPolyline* pline, AcGePoint3dArray& pts)
{
    ASSERT(pline != NULL);
    ASSERT(pts.isEmpty());

    AcDbObjectIterator* vertexIter = pline->vertexIterator();
    ASSERT(vertexIter != NULL);
    if (vertexIter == NULL)
        return;

    AcDb3dPolylineVertex* vertex;
    for (; !vertexIter->done(); vertexIter->step()) {
        if (acdbOpenObject(vertex, vertexIter->objectId(), AcDb::kForRead) == Acad::eOk) {
            if (vertex->vertexType() != AcDb::k3dControlVertex)
                pts.append(vertex->position());
            vertex->close();
        }
    }
    delete vertexIter;

    ASSERT(pts.isEmpty() == false);

    if (pline->isClosed()) {
        AcGePoint3d tmpPt = pts[0];        // used to be a bug in dynamic arrays (not sure if its still there??)
        pts.append(tmpPt);
    }
}
コード例 #3
0
// Accepts the object ID of an AcDb2dPolyline, opens it, and gets
// a vertex iterator. It then iterates through the vertices,
// printing out the vertex location.
// 
void
iterate(AcDbObjectId plineId)
{
    AcDb2dPolyline *pPline;
    acdbOpenObject(pPline, plineId, AcDb::kForRead);

    AcDbObjectIterator *pVertIter= pPline->vertexIterator();
    pPline->close();  // Finished with the pline header.

    AcDb2dVertex *pVertex;
    AcGePoint3d location;
    AcDbObjectId vertexObjId;
    for (int vertexNumber = 0; !pVertIter->done();
        vertexNumber++, pVertIter->step())
    {
        vertexObjId = pVertIter->objectId();
        acdbOpenObject(pVertex, vertexObjId,
            AcDb::kForRead);
        location = pVertex->position();
        pVertex->close();

        acutPrintf(_T("\nVertex #%d's location is")
            _T(" : %0.3f, %0.3f, %0.3f"), vertexNumber,
            location[X], location[Y], location[Z]);
    }
    delete pVertIter;
}
コード例 #4
0
ファイル: acrxEntryPoint.cpp プロジェクト: guchanghai/Cut
    //-------------------------------------------------------------------------------------------
    //
    //  功能: 将从AcDbObject派生数据库对象保存到实体的扩展词典中
    //
    //  作者:Qin H.X.
    //
    // 日期:200709
    //
    //  历史:
    //          2007.10.08 修改 by Qin H.X.
    //
    //----------------------------------------------------------------------------------------------
    // - CSCH081.AddAttribute command (do not rename)
    static void CSCH081AddAttribute(void)
    {
        AcDbObjectId dictObjId,eId, attId;
        AcDbDictionary* pDict;
        //选择管道(多义线)
        ads_name en;
        ads_point pt;
        if (  acedEntSel(_T("\n选择管道(多义线): "), en, pt)!= RTNORM)
        {
            acutPrintf(_T("\n选择失败,退出: "));
            return ;
        }
        // 打开对象
        acdbGetObjectId(eId, en);
        AcDbEntity * pEnt;
        acdbOpenObject(pEnt, eId,  AcDb::kForWrite);
        if(!pEnt->isKindOf (AcDbPolyline::desc ()))
        {
            acutPrintf(_T("\n选择的不是管道(多义线),退出: " ));
            return ;
        }

        // 判断实体的扩展词典是否创建,如果没有则创建
        dictObjId = pEnt->extensionDictionary();
        if(	dictObjId ==  AcDbObjectId::kNull )
        {
            pEnt->createExtensionDictionary();
        }

        // 获取实体的扩展词典
        dictObjId = pEnt->extensionDictionary();
        pEnt->close();

        // 	判断词典中的属性是否创建
        CPipeAttribute* pAttribute;
        acdbOpenObject(pDict, dictObjId, AcDb::kForWrite);
        pDict->getAt (_T("属性"),attId);
        if(attId!= AcDbObjectId::kNull )//如果已经创建则输出数据
        {
            acdbOpenObject(pAttribute, attId, AcDb::kForRead);
            acutPrintf(_T("\n管径:%4.2f " ),pAttribute->m_dRadius);
            acutPrintf(_T("\n壁厚:%4.2f " ),pAttribute->m_dThickness );
            acutPrintf(_T("\n埋深:%4.2f " ),pAttribute->m_dDeep );
            acutPrintf(_T("\n材质:%s " ),pAttribute->m_cMaterial  );
        }
        else
        {
            //没有则创建属性
            pAttribute = new CPipeAttribute();
            pDict->setAt(_T("属性"), pAttribute, attId);
        }
        //关闭对象
        pDict->close();
        pAttribute->close();

    }
コード例 #5
0
// This is the main function of this app.  It allows the
// user to select an entity.  It then checks to see if the
// entity is a 2d-polyline.  If so, then it calls iterate
// passing in the objectId of the pline.
// 
void
listPline()
{
    int rc;
    ads_name en;
    AcGePoint3d pt;
    rc = acedEntSel(_T("\nSelect a polyline: "), en,
        asDblArray(pt));

    if (rc != RTNORM) {
        acutPrintf(_T("\nError during object selection"));
        return;
    }

    AcDbObjectId eId;
    acdbGetObjectId(eId, en);

    AcDbObject *pObj;
    acdbOpenObject(pObj, eId, AcDb::kForRead);
    if (pObj->isKindOf(AcDb2dPolyline::desc())) {
        pObj->close();
        iterate(eId);
    } else {
        pObj->close();
        acutPrintf(_T("\nSelected entity is not an AcDb2dPolyline. \nMake sure the setvar PLINETYPE is set to 0 before createing a polyline"));
    }
}
コード例 #6
0
void
ArxDbgUiTdcPersistentReactors::getAttachedEntities(AcDbObjectIdArray& objIds)
{
	AcDbVoidPtrArray dbPtrs;
	ArxDbgUtils::getAllDatabases(dbPtrs);

	AcDbObjectId prId;
	ArxDbgPersistentEntReactor* peReactor;
	Acad::ErrorStatus es;
	AcDbObjectIdArray tmpIds;

	int len = dbPtrs.length();
	for (int i=0; i<len; i++) {
		prId = getPersistentEntReactor(static_cast<AcDbDatabase*>(dbPtrs[i]), false);

		es = acdbOpenObject(peReactor, prId, AcDb::kForRead);
		if (es == Acad::eOk) {
			tmpIds.setLogicalLength(0);	// reusing array for each database

			peReactor->getAttachedToObjs(tmpIds);
			peReactor->close();

			objIds.append(tmpIds);
		}
	}
}
コード例 #7
0
ファイル: TWArxTool.cpp プロジェクト: jiangnanemail/WorkingDB
Acad::ErrorStatus CTwArxDictionary::CreateSubDictionaryID( IN const AcDbObjectId& IdRoot, IN const CString& strKey, OUT AcDbObjectId& IdSubDic, IN AcRxClass* pRxObjType /*= AcDbDictionary::desc() */ ) const
{
	if( pRxObjType == NULL ) return Acad::eNullObjectPointer;

	Acad::ErrorStatus es = Acad::eOk;
	AcDbDictionary* pDicRoot = NULL;
	AcDbDatabase* pWdb = acdbCurDwg();

	if( IdRoot.isNull() )
		es = pWdb->getNamedObjectsDictionary( pDicRoot, AcDb::kForRead );
	else
		es = acdbOpenObject( pDicRoot, IdRoot, AcDb::kForRead );

	if( es != Acad::eOk ) return es;

	if( pDicRoot->has(strKey) )
	{
		pDicRoot->getAt( strKey, IdSubDic );
		pDicRoot->close();
		return es;
	}

	pDicRoot->upgradeOpen();
	AcDbObject* pObj = (AcDbObject*)pRxObjType->create();
	es = pDicRoot->setAt( strKey, pObj, IdSubDic );
	pObj->close();
	pDicRoot->close();

	return es;
}
コード例 #8
0
Acad::ErrorStatus
ArxDbgUtils::symbolIdToName(const AcDbObjectId& symbolId, CString& name)
{
        // shouldn't happen usually, but some debugging routines
        // want to print out this info
    if (symbolId == AcDbObjectId::kNull) {
        name = _T("AcDbObjectId::kNull");
        return Acad::eNullObjectId;
    }
        // get symbol name from symbol table record
    AcDbSymbolTableRecord* tblRec;
    Acad::ErrorStatus es;
    es = acdbOpenObject(tblRec, symbolId, AcDb::kForRead);
    if (es == Acad::eOk) {
        const TCHAR* locName;
        tblRec->getName(locName);
        name = locName;
        tblRec->close();
    }
    else {
        ArxDbgUtils::rxErrorMsg(es);
        es = Acad::eInvalidInput;
    }

    return es;
}
コード例 #9
0
ファイル: ArxHelper2.cpp プロジェクト: ninuo/ArxWorkspace
//把一层设置为OFF or ON
void CArxHelper::SetOneLayer(const TCHAR *name,int flag,bool YN)
	//flag 1:isoff 2:isfrozen 3:islocked
{
	AcDbLayerTable *pLayerTable;
	acdbCurDwg()->getLayerTable(pLayerTable,AcDb::kForRead);

	if(!pLayerTable->has(name))
	{
		pLayerTable->close();
		return;
	}

	AcDbObjectId id;
	pLayerTable->getAt(name,id);
	AcDbLayerTableRecord *pLayerTableRecord;
	acdbOpenObject(pLayerTableRecord,id,AcDb::kForWrite);

	switch(flag)
	{
	case 1:
		pLayerTableRecord->setIsOff(YN);
		break;
	case 2:
		pLayerTableRecord->setIsFrozen(YN);
		break;
	case 3:
		pLayerTableRecord->setIsLocked(YN);
		break;
	}

	pLayerTableRecord->close();
	pLayerTable->close();
}
コード例 #10
0
ファイル: MyFunctions.cpp プロジェクト: billmuell/GeoMap
String GetSelectedExtent() {
  ads_name selection;
  int returnValue = acedSSGet(_T("I"), NULL, NULL, NULL, selection);
  if (returnValue == RTCAN) return 0;
  if (returnValue != RTNORM) {
    return L"";
  }

  if (acedSSSetFirst(selection, NULL) != RTNORM) {
    acedSSFree(selection);
    return L"";
  }
  ads_name element;
  acedSSName(selection, 0, element);
  acedSSFree(selection);
  
  AcDbObjectId idEntity;
  if (acdbGetObjectId(idEntity, element) != Acad::eOk) {
    acedSSFree(element);
    return L"";
  }
  
  AcDbEntity * entity;
  if ((acdbGetObjectId(idEntity, element) != Acad::eOk) || 
      (acdbOpenObject(entity, idEntity, AcDb::kForRead) != Acad::eOk)) {
    
    acedSSFree(element);
    return L"";
  }
  
  acedSSFree(element);
  
  if (!entity->isKindOf(AcDbPolyline::desc())) return L"";
  
  AcDbPolyline * poly = static_cast<AcDbPolyline*>(entity);
  if (!poly->isClosed()) return 0;
  
  String extent = L"POLYGON((";
  AcGePoint2d start;
  AcGePoint2d current;
  for (int i = 0; i < poly->numVerts(); i++) {
    poly->getPointAt(i, current);
    
    if (i > 0) {
      extent += L", ";
    } else {
      start = current;
    }
    extent += Round(current.x, 0) + L" " + Round(current.y, 0);
  }
  if (!start.isEqualTo(current)) {
    extent += L", " + Round(start.x, 0) + L" " + Round(start.y, 0);
  }
  
  extent += L"))";
  
  poly->close();
  
  return extent;
}
コード例 #11
0
void
ArxDbgUiTdcObjects::displayCurrent(int index)
{
    // remove any previous entries
    m_fieldStrList.RemoveAll();
    m_valueStrList.RemoveAll();

    ASSERT((index >= 0) && (index < m_objList.length()));
    if(m_objList.length()==0)
        return;//done


    m_currentObjId = m_objList[index];

    CString str;

    AcDbObject* obj = NULL;
    Acad::ErrorStatus es = acdbOpenObject(obj, m_currentObjId, AcDb::kForRead, true);	// might want to show erased
    setExtensionButtons(obj);

    if (es == Acad::eOk) {
        display(obj);

        // hide or show the erased entity message
        if (obj->isErased())
            m_txtErased.ShowWindow(SW_SHOW);
        else
            m_txtErased.ShowWindow(SW_HIDE);

        obj->close();
    }

    drawPropsList(m_dataList);
}
コード例 #12
0
void
ArxDbgDbAdeskLogo::commonDraw(AcGiCommonDraw* drawContext)
{
    if (drawContext->regenAbort())
        return;

    AcGeMatrix3d scaleMat;
    m_scale.getMatrix(scaleMat);

    AcGeMatrix3d mat;
    getEcs(mat);   // push ECS of this Logo
    mat *= scaleMat;

    drawContext->rawGeometry()->pushModelTransform(mat);

    ArxDbgDbAdeskLogoStyle* lStyle = NULL;
    Acad::ErrorStatus es = acdbOpenObject(lStyle, m_logoStyleId, AcDb::kForRead);

    drawLogo(drawContext, lStyle);
    drawLabel(drawContext, lStyle);
    drawBorder(drawContext, lStyle);

    if (es == Acad::eOk)
        lStyle->close();

    drawContext->rawGeometry()->popModelTransform();

	drawRefLine(drawContext);
}
コード例 #13
0
void
ArxDbgAppEditorReactor::verifyClonedReferences(AcDbIdMapping& idMap)
{
    ArxDbgDbEntity* ent;
    AcDbObject* obj;
    Acad::ErrorStatus es;
    int numErrorsFixed;

    AcDbIdPair idPair;
    AcDbIdMappingIter mapIter(idMap);
    for (mapIter.start(); !mapIter.done(); mapIter.next()) {
        if (mapIter.getMap(idPair)) {
            es = acdbOpenObject(obj, idPair.value(), AcDb::kForWrite);
            if (es == Acad::eOk) {
                ent = ArxDbgDbEntity::cast(obj);
				if (ent != NULL) {
					es = ent->verifyReferences(numErrorsFixed, true);
					if (es != Acad::eOk) {
						ASSERT(0);
						ArxDbgUtils::rxErrorMsg(es);
						obj->erase();   // don't know what else to do but erase screwed up entity
					}
				}
                obj->close();
            }
            else {
                ASSERT(0);
                ArxDbgUtils::rxErrorMsg(es);
            }
        }
        else {
            ASSERT(0);
        }
    }
}
コード例 #14
0
ファイル: xtsndict.cpp プロジェクト: kevinzhwl/ObjectARXMod
// The listxrecord() functions gets the xrecord associated with the 
// key "ASDK_XREC1" and lists out its contents by passing the resbuf 
// list to the function printList().
// 
void
listXrecord()
{
    AcDbObject *pObj;
    AcDbXrecord *pXrec;
    AcDbObjectId dictObjId;
    AcDbDictionary *pDict;

    pObj = selectObject(AcDb::kForRead);
    if (pObj == NULL) {
        return;
    }
    // Get the object ID of the object's extension dictionary.
    //
    dictObjId = pObj->extensionDictionary();
    pObj->close();

    // Open the extension dictionary and get the xrecord
    // associated with the key ASDK_XREC1.
    // 
    acdbOpenObject(pDict, dictObjId, AcDb::kForRead);
    pDict->getAt("ASDK_XREC1", (AcDbObject*&)pXrec,
        AcDb::kForRead);
    pDict->close();

    // Get the xrecord's data list and then close the xrecord.
    //
    struct resbuf *pRbList;
    pXrec->rbChain(&pRbList);
    pXrec->close();

    printList(pRbList);
    acutRelRb(pRbList);
}
コード例 #15
0
void
ArxDbgUtils::collectVertices(const AcDbPolyFaceMesh* pface, AcDbObjectIdArray& vfaces, AcGePoint3dArray& pts)
{
    AcDbObjectIterator*  vertexIter = pface->vertexIterator();
    if (vertexIter == NULL)
        return;

    AcDbFaceRecord* vface;
    AcDbPolyFaceMeshVertex* pfaceVertex;
    AcDbObject* obj;

        // walk through and seperate vfaces and vertices into two
        // seperate arrays
    Acad::ErrorStatus es;
    for (; !vertexIter->done(); vertexIter->step()) {
        es = acdbOpenObject(obj, vertexIter->objectId(), AcDb::kForRead);
        if (es == Acad::eOk) {
            if ((vface = AcDbFaceRecord::cast(obj)) != NULL)
                vfaces.append(obj->objectId());
            else if ((pfaceVertex = AcDbPolyFaceMeshVertex::cast(obj)) != NULL)
                pts.append(pfaceVertex->position());
            else {
                ASSERT(0);
            }
            obj->close();
        }
        else
            ArxDbgUtils::rxErrorMsg(es);
    }
    delete vertexIter;
}
コード例 #16
0
void
ArxDbgUtils::collectVertices(const AcDb2dPolyline* pline, AcGePoint3dArray& pts,
            AcGeDoubleArray& bulges, bool asWcsPts)
{
    ASSERT(pline != NULL);
    ASSERT(pts.isEmpty() && bulges.isEmpty());

    AcDbObjectIterator* vertexIter = pline->vertexIterator();
    ASSERT(vertexIter != NULL);
    if (vertexIter == NULL)
        return;

    AcDb2dVertex* vertex;
    for (; !vertexIter->done(); vertexIter->step()) {
        if (acdbOpenObject(vertex, vertexIter->objectId(), AcDb::kForRead) == Acad::eOk) {
            if (vertex->vertexType() != AcDb::k2dSplineCtlVertex) {
                if (asWcsPts)
                    pts.append(pline->vertexPosition(*vertex));        // returns WCS
                else
                    pts.append(vertex->position());                    // returns ECS
                bulges.append(vertex->bulge());
            }
            vertex->close();
        }
    }
    delete vertexIter;

    ASSERT(pts.isEmpty() == Adesk::kFalse);

    if (pline->isClosed()) {
        AcGePoint3d tmpPt = pts[0];        // used to be a bug in dynamic arrays (not sure if its still there??)
        pts.append(tmpPt);
        bulges.append(0.0);
    }
}
コード例 #17
0
bool
ArxDbgUtils::plineHasWidth(const AcDb2dPolyline* pline)
{
    ASSERT(pline != NULL);

    AcDbObjectIterator* vertexIter = pline->vertexIterator();
    ASSERT(vertexIter != NULL);
    if (vertexIter == NULL)
        return false;

    AcDb2dVertex* vertex;
    for (; !vertexIter->done(); vertexIter->step()) {
        if (acdbOpenObject(vertex, vertexIter->objectId(), AcDb::kForRead) == Acad::eOk) {
            if (vertex->vertexType() != AcDb::k2dSplineCtlVertex) {
                if ((vertex->startWidth() != 0.0) || (vertex->endWidth() != 0.0)) {
                    vertex->close();
                    delete vertexIter;
                    return true;        // bail out, we found what we needed
                }
            }
            vertex->close();
        }
    }
    delete vertexIter;
    return false;
}
コード例 #18
0
AcDbObject* ZcEntityReactor::selectObject(AcDb::OpenMode openMode)
{
	int nRet = 0;
	ads_name en;
	ads_point pt;

	nRet = acedEntSel(_T("\nSelect an entity:"), en, pt);
	if (nRet != RTNORM)
	{
		return NULL;
	}

	AcDbObjectId eId;
	Acad::ErrorStatus retStat;
	retStat = acdbGetObjectId(eId, en);
	if (retStat != Acad::eOk)
	{
		acutPrintf(_T("\nacdbGetObjectId failed!"));
		return NULL;
	}

	AcDbObject* obj = NULL;
	if ((retStat = acdbOpenObject(obj, eId, openMode)) != Acad::eOk)
	{
		acutPrintf(_T("\nOpen Failed!"));
		return NULL;
	}

	return obj;
}
void
ArxDbgUiDlgGenericDefId::fillList()
{
    ArxDbgDbDictRecord* rec;
    CString nameStr;
    AcDbObjectId objId;
    Acad::ErrorStatus es;

    SdStrObjIdListIterator iter(m_entries);
    for (int row=0; !iter.done(); iter.next(), row++) {
        iter.item(nameStr, objId);
        if (objId == AcDbObjectId::kNull) {     // *VARIES* or *NONE* case
            m_lcDefIds.InsertItem(row, nameStr);
            m_lcDefIds.SetItemText(row, 1, _T(""));
        }
        else {
                // if we can open it as a dict record, display the description
            es = acdbOpenObject(rec, objId, AcDb::kForRead);
            if (es == Acad::eOk) {
                m_lcDefIds.InsertItem(row, nameStr);
                m_lcDefIds.SetItemText(row, 1, rec->description());
                rec->close();
            }
            else {
                m_lcDefIds.InsertItem(row, nameStr);        // Acad object, no description
                m_lcDefIds.SetItemText(row, 1, _T(""));
            }
        }
    }
}
コード例 #20
0
void
ArxDbgDbAdeskLogo::subList() const
{
	ArxDbgDbEntity::subList();

	CString str;

	AcGeScale3d sc = scale();
	printForListCmd(_T("Scale X"), ArxDbgUtils::doubleToStr(sc.sx, str));
	printForListCmd(_T("Scale Y"), ArxDbgUtils::doubleToStr(sc.sy, str));
	printForListCmd(_T("Scale Z"), ArxDbgUtils::doubleToStr(sc.sz, str));

	ArxDbgDbAdeskLogoStyle* style;
	Acad::ErrorStatus es = acdbOpenObject(style, logoStyleId(), AcDb::kForRead);
	if (es == Acad::eOk) {
		es = style->getName(str);
		if (es != Acad::eOk)
			str = ArxDbgUtils::rxErrorStr(es);

		style->close();
	}
	else
		str = ArxDbgUtils::rxErrorStr(es);

	printForListCmd(_T("Style"), str);

	printForListCmd(_T("Arbitrary Reference"), ArxDbgUtils::objToClassAndHandleStr(m_arbitraryRefEnt, str));
}
コード例 #21
0
ファイル: xtsndict.cpp プロジェクト: kevinzhwl/ObjectARXMod
// The selectObject() function prompts the user to select an 
// entity or enter an object's handle.  It then proceeds to 
// open the object/entity and return a pointer to it.
// 
AcDbObject*
selectObject(AcDb::OpenMode openMode)
{
    ads_name en;
    ads_point pt;
    char handleStr[132];
    AcDbObjectId eId;

    Acad::ErrorStatus retStat;
    int ss;

    // Allow user to either pick an entity,
    // or type in the object handle.
    //
    acedInitGet(RSG_OTHER, "_Handle Handle");
    ss = acedEntSel("\nSelect an Entity or enter"
        " 'H' to enter its handle:  ", en, pt);

    switch (ss) {
    case RTNORM:   // got it!
        break;
    case RTKWORD:
        if ((acedGetString(Adesk::kFalse,
            "Enter Valid Object Handle: ",
            handleStr) == RTNORM)
            && (acdbHandEnt(handleStr, en) == RTNORM))
        {
            break;
        }
    // Fall-through intentional
    //
    default:
        acutPrintf("Nothing Selected, Return Code==%d\n",
            ss);
        return NULL;
    }

    // Now, exchange the ads_name for the object Id...
    //
    retStat = acdbGetObjectId(eId, en);
    if (retStat != Acad::eOk) {
        acutPrintf("\nacdbGetObjectId failed");
        acutPrintf("\nen==(%lx,%lx), retStat==%d\n",
            en[0], en[1], eId);
        return NULL;
    }

    AcDbObject* pObj;

    if ((retStat = acdbOpenObject(pObj, eId, openMode))
        != Acad::eOk)
    {
        acutPrintf("acdbOpenEntity failed: ename:"
            "(%lx,%lx), mode:%d retStat:%d", en[0],
            en[1], openMode, retStat);
        return NULL;
    }
    return pObj;
}
コード例 #22
0
ファイル: ArxEntityHelper.cpp プロジェクト: kanbang/TIDS
// 使用常规的Open/Close机制
static void UpdateEntity2( const AcDbObjectId& objId )
{
    AcDbEntity* pEnt;
    if( Acad::eOk != acdbOpenObject( pEnt, objId, AcDb::kForWrite ) ) return;

    pEnt->recordGraphicsModified( true ); // 标签图元状态已修改,需要更新图形
    pEnt->close();
}
コード例 #23
0
    // ----- AsdkSelectionFilterUI.SubentSel command (do not rename)
    static void AsdkSelectionFilterUI_SubentSel(void)
    {
        // we have to allow duplicates; otherwise, the xref would be selectable
        // only once (because the main entity is the one that counts).

        setAllowDuplicateSelection(curDoc(), true);
        ads_name sset, eName;
        AcDbObjectId id;

        // "_:n" gives us nested entities
        //
        if (RTNORM == acedSSGet("_:n", NULL, NULL, NULL, sset))
        {
            acutPrintf("\n");
            long len = 0;
            acedSSLength(sset, &len);
            for (long i = 0; i < len; i++)// For each entity in sset
            {

                resbuf *rb = NULL;
                // We use ssnamex() here, because the regular ssname()
                // would give only the main entity (the xref)
                //
                if (RTNORM == acedSSNameX(&rb, sset, i))//Get the sub entity
                {
                    resbuf *rbWalk = rb;
                    while (NULL != rbWalk)
                    {
                        if (RTENAME == rbWalk->restype)
                        {
                            eName[0] = rbWalk->resval.rlname[0];
                            eName[1] = rbWalk->resval.rlname[1];
                            if(Acad::eOk == acdbGetObjectId(id, eName))
                            {
                                acutPrintf("Entity %d: <%x>", i, id.asOldId());
                                AcDbEntity *pEnt;
                                if (Acad::eOk == acdbOpenObject(pEnt, id, AcDb::kForRead))
                                {
                                    acutPrintf("(%s)\n", pEnt->isA()->name());
                                    pEnt->close();
                                }
                                else
                                    acutPrintf("\nCouldn't open object");
                            }
                            rbWalk = NULL; //force quit out of loop
                        }
                        else
                            rbWalk = rbWalk->rbnext;
                    }
                    acutRelRb(rb);
                }
            }
            acedSSFree(sset);
        }

        setAllowDuplicateSelection(curDoc(), false);
    }
コード例 #24
0
bool
ArxDbgUtils::collectVertices(const AcDbPolygonMesh* pmesh, AcGePoint3dArray& pts,
                            int& mSize, int& nSize)
{
    AcDbObjectIterator*  vertexIter = pmesh->vertexIterator();
    if (vertexIter == NULL)
        return false;

    Acad::ErrorStatus es;
    AcDbPolygonMeshVertex* pVertex;
    AcGePoint3d tmpPt;

    if (pmesh->polyMeshType() == AcDb::kSimpleMesh) {
        mSize = pmesh->mSize();
        nSize = pmesh->nSize();
    }
    else {
        mSize = pmesh->mSurfaceDensity();
        nSize = pmesh->nSurfaceDensity();
    }

    int nCount = 0;
    int totalCount = 0;
    for (; !vertexIter->done(); vertexIter->step()) {
        es = acdbOpenObject(pVertex, vertexIter->objectId(), AcDb::kForRead);
        if (es != Acad::eOk) {
            ArxDbgUtils::rxErrorMsg(es);
            delete vertexIter;
            return false;
        }
        pts.append(pVertex->position());
        nCount++;
        totalCount++;
        if (nCount == nSize) {
            if (pmesh->isNClosed()) {
                tmpPt = pts[totalCount - nSize];        // work around bug by making temp copy (not sure if still a bug??)
                pts.append(tmpPt);
                totalCount++;
            }
            nCount = 0;
        }
    }
    delete vertexIter;

    if (pmesh->isNClosed())
        nSize++;
    if (pmesh->isMClosed()) {
        mSize++;
        for (int i=0; i<nSize; i++) {
            tmpPt = pts[i];        // see note above
            pts.append(tmpPt);    
        }
    }

    return true;
}
コード例 #25
0
ファイル: TWArxTool.cpp プロジェクト: jiangnanemail/WorkingDB
Acad::ErrorStatus CTwArxDictionary::OpenSubObject( IN const AcDbObjectId& IdRoot, IN const CString& strKey, AcDbObject*& pObj, AcDb::OpenMode os ) const
{
	AcDbObjectId Id;
	Acad::ErrorStatus es = GetSubDictionaryID( IdRoot, strKey, Id );
	if( es != eOk) return es;

	pObj = NULL;
	es = acdbOpenObject( pObj, Id, os );
	return es;
}
コード例 #26
0
ファイル: RqAirflowCacul.cpp プロジェクト: kanbang/TIDS
LinkedGE* VentCaculate::getLinkedGE(AcDbObjectId objId)
{
	AcDbObject* pObj;
	acdbOpenObject( pObj, objId, AcDb::kForRead );

	LinkedGE* pEdge = LinkedGE::cast( pObj );
	pObj->close();

	return pEdge;
}
コード例 #27
0
ファイル: CadEntityFactory.cpp プロジェクト: billmuell/GeoMap
CCadEntity * CCadEntityFactory::GetCadEntity(AcDbObjectId & idEntity)
{
  AcDbEntity * entity = 0;
  if (acdbOpenObject(entity, idEntity, AcDb::kForRead) != Acad::eOk) return 0;
  
  CCadEntity * cadEntity = CCadEntityFactory::GetCadEntity(entity);
  entity->close();
  
  return cadEntity;
}
コード例 #28
0
ファイル: LayerState.cpp プロジェクト: vuonganh1993/arxlss
bool CLayerState::unlock(void)
{
	AcDbLayerTableRecord* pLayer = NULL;
	if (acdbOpenObject(pLayer, m_idLayer, AcDb::kForWrite) != Acad::eOk)
		return false;

	pLayer->setIsLocked(false);
	pLayer->close();
	return true;
}
コード例 #29
0
ファイル: GoafDragJig.cpp プロジェクト: kanbang/myexercise
static AcDbEntity* CloneEntity( const AcDbObjectId& objId )
{
    AcDbEntity* pEnt;
    acdbOpenObject( pEnt, objId, AcDb::kForRead );

    AcDbEntity* pClone = AcDbEntity::cast( pEnt->clone() );

    pEnt->close();

    return pClone;
}
コード例 #30
-7
ファイル: tempapp.cpp プロジェクト: kevinzhwl/ObjectARXMod
// This function has the user select an entity and then
// calls the reflectedEnergy() function in the protocol
// extension class attached to that entity's class.
// 
void
energy()
{
    AcDbEntity *pEnt;
    AcDbObjectId pEntId;
    ads_name en;
    ads_point pt;

    if (acedEntSel("\nSelect an Entity:  ", en, pt)
        != RTNORM)
    {
        acutPrintf("Nothing Selected\n");
        return;
    }
    acdbGetObjectId(pEntId, en);
    acdbOpenObject(pEnt, pEntId, AcDb::kForRead);

    // call the protocol extension class's method
    //
    double eTemp = ACRX_X_CALL(pEnt,
        AsdkEntTemperature)->reflectedEnergy(pEnt);

    acutPrintf("\nEnergy == %f\n", eTemp);
    pEnt->close();
}