示例#1
2
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);
}
void Additional_Class::addXdata( AcDbObjectId entID, CString xdataStr )
{
	AcDbEntity * pEnt;
	struct resbuf * pRb;

	if(Acad::eOk != acdbOpenAcDbEntity(pEnt, entID, AcDb::kForWrite))
	{
		pEnt->close();
		return;
	}
	

	TCHAR strAppName[] = _T("JMBraring");
	acdbRegApp(strAppName);
	
	TCHAR  * typeName = CString2TCHAR(xdataStr);

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

	pRb = acutBuildList(AcDb::kDxfRegAppName, strAppName,
		AcDb::kDxfXdAsciiString, typeName, 
		RTNONE);
	
	pEnt->setXData(pRb);
	
	acutRelRb(pRb);
	acutRelRb(pTemp);
	pEnt->close();
	
	return;
}
示例#3
0
void
ArxDbgRbList::remove(resbuf* nodeToDel)
{
    resbuf* rb = detach(nodeToDel);
    if (rb)
        acutRelRb(rb);
}
BOOL CLayerTreeDlg::SetCurrentLayer(CString strCADLayer)
{
	acDocManager->lockDocument(curDoc());

	struct resbuf *Value = acutBuildList(RTSTR,strCADLayer,0); 

	int err = acedSetVar("clayer", Value);

	acutRelRb(Value);

	if( err != RTNORM)
	{
		acDocManager->unlockDocument(curDoc());

		acutPrintf("\n切换当前图层至 %s 的时候发生错误,请稍后再试。\n",strCADLayer);

		return FALSE;
	}

	acDocManager->unlockDocument(curDoc());

	acutPrintf("\n当前图层切换为 %s\n", strCADLayer);

	return TRUE;
}
示例#5
0
// 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);
}
void
ArxDbgUiDlgXdata::OnAppNameSelected() 
{
    resbuf* tmpXdata;
    int index = m_appPopUp.GetCurSel();

    if (index == CB_ERR)
        index = 0;

    if (index == 0) {    // iterate through all apps
        ArxDbgRbList allXdata, singleAppXdata;
        ArxDbgAppXdataListIterator iter(m_xdata);
        for (; !iter.done(); iter.next()) {
            singleAppXdata.adoptData(iter.item()->allocResbufChain());
            allXdata.append(singleAppXdata);
        }
        displayRbChain(allXdata.data());    // display one big list
    }
    else {
            // look up this specific app
        ArxDbgAppXdata* xdPtr = m_xdata.at(index-1);
        tmpXdata = xdPtr->allocResbufChain();
        displayRbChain(tmpXdata);
        acutRelRb(tmpXdata);
    }
}
示例#7
0
// Accesses the xrecord associated with the key XRECADS in
// the dictionary associated the key TEST_DICT.  Then
// lists out the contents of this xrecord using the
// printList function.
// 
int
listXrecord()
{
    struct resbuf *pObj;
    ads_name dictName;

    // Get the entity name of the ASDK_DICT dictionary in
    // the named object dictionary and place it in dictName.
    //
    acdbNamedObjDict(dictName);
    pObj = acdbDictSearch(dictName, "ASDK_DICT", 0);
    if (pObj) {
        // The entity name is always returned in first resbuf.
        //
        ads_name_set(pObj->resval.rlname, dictName);
    }

    // Get the xrecord associated with the key XRECADS.
    //
    pObj = acdbDictSearch(dictName, "XRECADS", 0);

    if (pObj) {
        printList(pObj);
        acutRelRb(pObj);
    }
    acedRetVoid();
    return RTNORM;
}
示例#8
0
// Creates an xrecord,  fills it in with some data,  and
// adds it to the dictionary associated with the key
// "TEST_REC".  If this dictionary doesn't exist,  it's
// created and added to the named objects dictionary.
//
// THE FOLLOWING CODE APPEARS IN THE SDK DOCUMENT.
//
int
createXrecord()
{
    struct resbuf *pXrec, *pDict;
    ads_point testpt = {1.0, 2.0, 0.0};
    ads_name xrecname, namedObj, dictName;

    // Within the named object dictionary, attempt to get
    // the dictionary associated with the key ASDK_DICT.
    // If not present, create it.
    // 
    acdbNamedObjDict(namedObj);
    pDict = acdbDictSearch(namedObj, "ASDK_DICT", 0);
    if (pDict == NULL) {
        pDict = acutBuildList(RTDXF0, "DICTIONARY", 100,
            "AcDbDictionary", 0);
        acdbEntMakeX(pDict, dictName);
        acutRelRb(pDict);
        acdbDictAdd(namedObj, "ASDK_DICT", dictName);
    }
        
    // Create a resbuf list of the xrecord's entity data.
    //
    pXrec = acutBuildList(RTDXF0, "XRECORD",
        100, "AcDbXrecord",
        1, "This is a test Xrecord list", //AcDb::kDxfText
        10, testpt,                       //AcDb::kDxfXCoord
        40, 3.14159,                      //AcDb::kDxfReal
        50, 3.14159,                      //AcDb::kDxfAngle
        60, 1,                            //AcDb::kDxfColor
        70, 180,                          //AcDb::kDxfInt16
        0);

    // Create the xrecord with no owner set.  Place the
    // xrecord's new entity name into the xrecname argument.
    //
    acdbEntMakeX (pXrec, xrecname);
    acutRelRb (pXrec);

    // Set xrecord's owner to be the ASDK_DICT dictionary.
    //
    acdbDictAdd(dictName, "XRECADS", xrecname);

    acedRetVoid();
    return RTNORM;
}
示例#9
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);
    }
示例#10
0
void
ArxDbgRbList::removeAll()
{
    if (m_head)
        acutRelRb(m_head);

    m_head = NULL;
    m_tail = NULL;
}
void GetCoordInventory()
{
	std::map<std::wstring, AcGePoint3d> m_3dPoints;
	u_int startIndex = 1;

	ads_real textHeightResult = 1;
	ads_real pointSizeResult = 0.25;	
	ACHAR stringResult[2];
	ACHAR prompt[100];
	AcDbObjectId pObj;	


	selectObject(pObj);
	if (pObj)
	{
		acedInitGet(RSG_NONULL | RSG_NOZERO | RSG_NONEG, NULL);
		acedGetReal(_T("\nIntroduceti inaltime text: "), &textHeightResult);
		acedGetReal(_T("\nIntroduceti dimensiunea punctului: "), &pointSizeResult);

		extractVertexCoords(pObj, m_3dPoints);
		if (m_3dPoints.size() > 0)
		{
			if (insertPoints(m_3dPoints, 32, pointSizeResult, textHeightResult))
			{
				acedInitGet(RSG_NONULL, _T("Y N"));
				acedGetKword(_T("\nInseram tabel de coordonate? [Yes No]:"), stringResult);
				if (wcscmp(stringResult, _T("N")))
				generateInventarTable(m_3dPoints,textHeightResult);

				//swprintf(prompt, _T("\nExportam fisier de coordonate? [Y/N]<stringResult=%s>: "), stringResult);
				acedInitGet(RSG_NONULL, _T("Y N"));
				acedGetKword(_T("\nExportam fisier de coordonate? [Yes No]: " ), stringResult);
				if (wcscmp(stringResult, _T("N")))
				{
				
				struct resbuf* result = NULL;
				if (acedGetFileNavDialog(_T("Save coordonates file"), NULL, _T("csv;txt"), _T("Save Dialog"), 1, &result) != RTERROR)
				{
					ExportClass* csvExport = new ExportClass(result->resval.rstring);
					csvExport->exportInventarCSV(m_3dPoints, startIndex);

					//*****Release memory area*****/
					acutRelRb(result);
					delete csvExport;
				}
				}
			}
		}
	}

	else
	{
		acutPrintf(_T("\nError nici un obiect selectat!"));
	}

}
示例#12
0
// The createXrecord() functions creates an xrecord object, 
// adds data to it, and then adds the xrecord to the extension 
// dictionary of a user selected object.
// 
// THE FOLLOWING CODE APPEARS IN THE SDK DOCUMENT.
//
void
createXrecord()
{
    AcDbXrecord *pXrec = new AcDbXrecord;
    AcDbObject *pObj;
    AcDbObjectId dictObjId, xrecObjId;
    AcDbDictionary* pDict;

    pObj = selectObject(AcDb::kForWrite);
    if (pObj == NULL) {
        return;
    }

    // Try to create an extension dictionary for this
    // object.  If the extension dictionary already exists,
    // this will be a no-op.
    // 
    pObj->createExtensionDictionary();

    // Get the object ID of the extension dictionary for the
    // selected object.
    // 
    dictObjId = pObj->extensionDictionary();
    pObj->close();

    // Open the extension dictionary and add the new
    // xrecord to it.
    //
    acdbOpenObject(pDict, dictObjId, AcDb::kForWrite);
    pDict->setAt("ASDK_XREC1", pXrec, xrecObjId);
    pDict->close();

    // Create a resbuf list to add to the xrecord.
    //
    struct resbuf* head;
    ads_point testpt = {1.0, 2.0, 0.0};
    head = acutBuildList(AcDb::kDxfText,
        "This is a test Xrecord list",
        AcDb::kDxfXCoord, testpt,
        AcDb::kDxfReal, 3.14159,
        AcDb::kDxfAngle, 3.14159,
        AcDb::kDxfColor, 1,
        AcDb::kDxfInt16, 180,
        0);

    // Add the data list to the xrecord.  Notice that this
    // member function takes a reference to a resbuf NOT a
    // pointer to a resbuf, so you must dereference the
    // pointer before sending it.
    // 
    pXrec->setFromRbChain(*head);
    pXrec->close();
    acutRelRb(head);
}
	static void shYDsysXDataDel()
	{
		ads_name ssName;
		if(RTNORM == acedSSGet(":S", NULL, NULL, NULL, ssName))
		{
			AcDbObjectId tempObjId;
			ads_name ssTemp;
			long nLen=0;
			if(RTNORM != acedSSLength(ssName,&nLen)) return;
			for(int j=0; j<nLen; j++)
			{
				if(RTNORM == acedSSName(ssName,j,ssTemp)) continue;
				if(Acad::eOk != acdbGetObjectId(tempObjId, ssTemp)) continue;
				AcDbEntity* pEnt = NULL;
				if(Acad::eOk == acdbOpenObject(pEnt,tempObjId,AcDb::kForWrite))
				{
					
					resbuf* pHead = pEnt->xData(NULL);
					if(pHead == NULL)
					{
						pEnt->close(); continue;
					}
					resbuf* pNext =pHead->rbnext;
					if(pNext == NULL)
					{
						acutRelRb(pHead); pEnt->close(); continue;
					}
					while(pNext != NULL)
					{
						acutRelRb(pHead);
						pHead = pNext;
						pNext = pNext->rbnext;
					}
					pEnt->setXData(NULL);
					pEnt->close();
				}
			}
			acedSSFree(ssName);
		}
	}
示例#14
0
BOOL
ArxDbgUiDlgDxf::OnInitDialog() 
{
    CAcUiDialog::OnInitDialog();
    
    ads_name ent;
    acdbGetAdsName(ent, m_objPtr->objectId());

        // get entity data the ADS way (as DXF codes)
    resbuf* apps = acutNewRb(RTSTR);
    apps->resval.rstring = static_cast<char*>(malloc(10));
    strcpy(apps->resval.rstring, _T("*"));
    resbuf* entdata = acdbEntGetX(ent, apps);
    acutRelRb(apps);

    buildColumns();
    displayRbChain(entdata);

    acutRelRb(entdata);
    
    return TRUE;
}
void
AsdkTextFileFieldOptionDialog::OnBnClickedBrowse()
{
	struct resbuf *pResBuf;
    int ret = acedGetFileNavDialog ("Select text file", "", "txt", "Browse Text File", 0, &pResBuf);

	if ( ret == 5100 && pResBuf->restype == 5005 )
	{
		SetFilePath(pResBuf->resval.rstring);
		acutRelRb(pResBuf);	
	}
	
}
void frgExtractTopologicalEntsFromLinesAlgm::_search_related_segs(AcDbObjectIdArray &ids, const AcGeLineSeg2d &seg)
{
	double tolerance = rlTolerance::equal_point();
	if (seg.length() < 2 * tolerance)
		return;

	// - 构造反选矩形
	// -- 计算四个点
	AcGePoint2d p1, p2, p3, p4;

	AcGeVector2d dir = seg.direction();
	AcGeVector2d offset = dir;
	offset.rotateBy(rlPi / 2.0);

	p1 = seg.startPoint(); p1.transformBy(-offset * tolerance);
	p2 = seg.endPoint(); p2.transformBy(-offset * tolerance);
	p3 = seg.endPoint(); p3.transformBy(offset * tolerance);
	p4 = seg.startPoint(); p4.transformBy(offset * tolerance);

	// -- 构造矩形
	ads_point _p1, _p2, _p3, _p4;
	_p1[0] = p1.x; _p1[1] = p1.y, _p1[2] = 0;
	_p2[0] = p2.x; _p2[1] = p2.y, _p2[2] = 0;
	_p3[0] = p3.x; _p3[1] = p3.y, _p3[2] = 0;
	_p4[0] = p4.x; _p4[1] = p4.y, _p4[2] = 0;
	resbuf *rect = acutBuildList(RTPOINT, _p1, RTPOINT, _p2, RTPOINT, _p3, RTPOINT, _p4, RTNONE);

	// - 交叉查询
	ads_name ss;
	int ret = acedSSGet(_T("CP"), rect, NULL, _filter, ss);
	acutRelRb(rect);
	if (ret != RTNORM)
		return;

	// - 获取查询结果
	long len = 0;
	acedSSLength(ss, &len);
	for (int i = 0; i < len; i++)
	{
		ads_name name;
		acedSSName(ss, i, name);

		AcDbObjectId id;
		if (acdbGetObjectId(id, name) == Acad::eOk)
			ids.append(id);
	}
	acedSSFree(ss);
}
示例#17
0
void printXData()
{
	// 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 the application name for the xdata.
    //
	TCHAR appname[133] = {0};
    if (acedGetString(NULL, _T("\nEnter the Xdata application name: "), appname) != RTNORM)
    {
        return;
    }

    // Get the xdata for the application name.
    //
    resbuf *pRb = pObj->xData(appname);

    if (pRb != NULL)
	{
        printXDList(pRb);
        acutRelRb(pRb);
    }
	else
	{
        acutPrintf(_T("\nNo xdata for appname: %s."), appname);
    }
    pObj->close();
}
示例#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 "";
}
示例#19
0
void PDFConverter(BOOL bDwg)
{
// 	test();
	resbuf* rb = getFileNameInput();
	resbuf* pRb = rb;
	AcStringArray arrFileName;
	while (pRb)
	{
		arrFileName.append(pRb->resval.rstring);
		pRb = pRb->rbnext;
	}
	acutRelRb(rb);
	rb = NULL;

	int page = 0;
	if (arrFileName.length() == 1)
	{
		acedInitGet(4, NULL);

		// use resource for multi langeage.
		// modify by yhl, 2016/6/29.
		CString strPrompt;
		CAcModuleResourceOverride rs;
		strPrompt.LoadString(IDS_ASKFORPAGENUMBER);
		int rc = acedGetInt(strPrompt, &page);
// 		int rc = acedGetInt(_T("\nPlease input the page number, 0 for all <1>: "), &page);

		if (RTNONE == rc)
		{
			page = 1;
		}
		else if (RTNORM != rc)
		{
			return;
		}
	}

	for (int i=0; i<arrFileName.length(); i++)
	{
		convertFile(arrFileName[i], page, bDwg);
	}
}
示例#20
0
bool printXData()
{
	CLogger::Print(_T("*Call: printxData()"));
	AcDbObject* pObj;
	
	//------------
	// Require to select an entity
	if (!(pObj = selectObject(AcDb::kForRead))) {
		CLogger::Print(_T("*Exit: printxData() - Object have not selected."));
		return false;
	}

	//------------
	// Require to enter xData application name
	ACHAR appname[133];
	if (RTNORM != acedGetString(NULL, ACRX_T("\nEnter the desired Xdata application name: "), appname)) 
	{
		CLogger::Print(_T("*Exit: printxData() - Fail to enter the application name!"));
		return false;
	}

	//------------
	// Read the xData that contained in object.
	// If application name is existing then print out its values.
	struct resbuf* pRb;
	pRb = pObj->xData(appname);
	pObj->close();
	if (pRb) {
		acutPrintf(ACRX_T("Inform: Application name '%s' is existing - The values are: "), appname);
		printList(pRb);
		acutRelRb(pRb); // release xData after using!
	} else {
		acutPrintf(ACRX_T("\n*Exit: printxData() - Application name '%s' is not existing."), appname);
		pObj->close();
		return false;
	}

	pObj->close();
	CLogger::Print(_T("*Exit: printxData()"));
	return true;
}
示例#21
0
////////////////////////////////////////////////////////////////////////////////
// dofun()
//
// This function calls the function in gGunctionTable that is indexed by
// the ADS function code.
//
static int
dofun()
{
    struct resbuf *rb;
    AvErrorCode retval;
    unsigned short func;

    // Reload Render.arx if it has been unloaded
    //
    if (! acrxServiceDictionary->at(RENDER_SERVICES))
    {
        retval = av_loadlib();
        if (retval != AvRetNorm) {
            acdbFail("Library initialization failed.\n");
            return RTERROR;
        }
    }

    func = (unsigned short)ads_getfuncode();
    if (func >= ELEMENTS(gFunctionTable))
    {
        acdbFail("Received nonexistent function code.");
        return RTERROR;
    }

    rb =  acedGetArgs();

    // AVLib: here, we call av_initialize, which issues
    // the "renderupdate" command
    //
    av_initialize();

    retval = (*gFunctionTable[func].fptr)(rb);

    acutRelRb(rb);

    if (retval == AvRetNorm)
        return RTNORM;
    else
        return RTERROR;
}
void XAcDocOp::openDocCallBack(void *pData)
{
	if(pData == NULL || !AfxIsValidAddress(pData , sizeof(_CREATEDOCUMENTINFO)))
		return;

	CString strFilePathName;

	if(pData == NULL || !AfxIsValidAddress(pData , sizeof(_CREATEDOCUMENTINFO)))
		return;

	Acad::ErrorStatus	es;
	try
	{
		_CREATEDOCUMENTINFO	*pCreateInfo;
		pCreateInfo		= (_CREATEDOCUMENTINFO*)pData;
		strFilePathName = pCreateInfo->pszName;
		strFilePathName.Trim();

		//判断当前是否处于SDI模式
		BOOL	bIsSDIMode = FALSE;
		resbuf	*pRb;

		pRb	= acutNewRb(RTSHORT);
		if(acedGetVar("SDI" , pRb) == RTNORM && pRb->resval.rint == 1)	//是SDI模式
		{
			pCreateInfo->bActiveOldDoc	= FALSE;	//不能切换到先前的文档
			if(curDoc() != NULL)
				es = acDocManager->closeDocument(curDoc());	//关闭当前文档
		}
		acutRelRb(pRb);

		es = acDocManager->appContextOpenDocument(strFilePathName);

		if(pCreateInfo->bActiveOldDoc && pCreateInfo->pOldDoc != NULL)
			acDocManager->activateDocument(pCreateInfo->pOldDoc);
	}
	catch (...)
	{
	}
}
// This function calls the
// selectObject() function to allow the user to pick an
// object; then it accesses the xdata of the object and
// sends the list to the printList() function that lists the
// restype and resval values.
// 
void
printXdata()
{
    // Select and open an object.
    //
    AcDbObject *pObj;
    if ((pObj = selectObject(AcDb::kForRead)) == NULL) {
        return;
    }

    // Get the application name for the xdata.
    //
    TCHAR appname[133];
    if (acedGetString(NULL,
        _T("\nEnter the desired Xdata application name: "),
        appname) != RTNORM)
    {
        return;
    }

    // Get the xdata for the application name.
    //
    struct resbuf *pRb;
    pRb = pObj->xData(appname);

    if (pRb != NULL) {

        // Print the existing xdata if any is present.
        // Notice that there is no -3 group, as there is in
        // LISP. This is ONLY the xdata, so
        // the -3 xdata-start marker isn't needed.
        // 
        printList(pRb);
        acutRelRb(pRb);

    } else {
        acutPrintf(_T("\nNo xdata for this appname"));
    }
    pObj->close();
}
示例#24
0
CCadEntity * CCadEntityFactory::GetCadEntity(AcDbEntity * entity)
{
  CCadEntity * cadEntity = 0;
  if (entity->isKindOf(AcDbPoint::desc()) ||
    entity->isKindOf(AcDbText::desc()) ||
    entity->isKindOf(AcDbMText::desc()) ||
    entity->isKindOf(AcDbBlockReference::desc())) {
    
      cadEntity = new CCadPoint(entity);
  
  } else if (entity->isKindOf(AcDbLine::desc()) ||
      entity->isKindOf(AcDbArc::desc()) ||
      entity->isKindOf(AcDbSpline::desc())) {
        
        cadEntity = new CCadLine(entity);
  
  } else if (entity->isKindOf(AcDbEllipse::desc()) ||
    entity->isKindOf(AcDbCircle::desc())) {
      cadEntity = new CCadPolygon(entity);
  
  } else if (entity->isKindOf(AcDb2dPolyline::desc())) {
    
    AcDb2dPolyline * e = AcDb2dPolyline::cast(entity);
    if (e->isClosed()) cadEntity = new CCadPolygon(entity);
    else cadEntity = new CCadLine(entity);
    
  } else if (entity->isKindOf(AcDbPolyline::desc())) {
    
    AcDbPolyline * e = AcDbPolyline::cast(entity);
    if (e->isClosed()) cadEntity = new CCadPolygon(entity);
    else cadEntity = new CCadLine(entity);
  }
  
  resbuf * data = entity->xData(APPNAME);
  if (data != NULL) cadEntity->SetData(CFeatureData(data->rbnext->resval.rstring));
  acutRelRb(data);
  
  return cadEntity;
}
示例#25
0
resbuf*
ptArrayToResbuf(const AcGePoint3dArray& ptArray)
{
    resbuf* ptList = NULL;        // overall list
    resbuf* lastRb = NULL;        // place holder to end of list
    resbuf* rb;
    int len = ptArray.length();
    for (int i=0;i<len;i++) {
        if ((rb = acutNewRb(RT3DPOINT)) == NULL) {
            acutRelRb(ptList);
            return NULL;
        }
        copyAdsPt(rb->resval.rpoint, asDblArray(ptArray.at(i)));
        if (ptList == NULL) {
            ptList = rb;
            lastRb = rb;
        }
        else {
            lastRb->rbnext = rb;
            lastRb = rb;
        }
    }
    return ptList;
}
示例#26
0
void CDlgReadInfo::OnBnClickedBtnSelect()
{
	//交互选择实体
	BeginEditorCommand();

	CString strCadName;
	CComboBox* pCmb = (CComboBox*)GetDlgItem(IDC_COMBO_CADLY);
	pCmb->GetLBText(pCmb->GetCurSel(),strCadName);

	
	ads_name ssName;
	struct resbuf *filter=NULL;
	if(strCadName.CompareNoCase("所有图层") != 0)
	{
		filter=acutNewRb(AcDb::kDxfLayerName);
		filter->restype=AcDb::kDxfLayerName;
		filter->resval.rstring = (char*) malloc((strCadName.GetLength()+1)*sizeof(char));
		strcpy(filter->resval.rstring,strCadName.GetBuffer(0));
		filter->rbnext=NULL;
	}
	
	if (acedSSGet(":S", NULL, NULL, filter, ssName) != RTNORM)
	{
		acutPrintf("\n选择实体有误!");
		acedSSFree(ssName); acutRelRb(filter);
		CompleteEditorCommand();
		return;
	}
	if(filter != NULL) acutRelRb(filter);

	AcDbObjectId tempObjId;
	ads_name ssTemp;
	long nNum = 0;
	int nPos = 0;
	acedSSLength(ssName,&nNum);
	CString strSdeName,strId,strRowId;

	m_wndTree.DeleteAllItems();

	// 清空属性列表
	ResetListItems();

	for(int i=0; i<nNum; i++)
	{
		acedSSName(ssName, i, ssTemp);
		if(Acad::eOk != acdbGetObjectId(tempObjId, ssTemp)) continue;
		strId.Format("%d",tempObjId.asOldId());
		CDistXData tempXData(tempObjId,"ROWID_OBJS");
		if(tempXData.Select("SDELYNAME",strSdeName)==FALSE) continue;
		if(tempXData.Select("OBJECTID",strRowId)==FALSE) continue;
		tempXData.Close();

		HTREEITEM hItem = m_wndTree.InsertItem(strId);

		AcDbEntity *pEnt = NULL;
		if (Acad::eOk != acdbOpenObject(pEnt, tempObjId, AcDb::kForRead))
		{
			return;
		}
		pEnt->close();

		ITEM_DATA xxItemData;
		xxItemData.strID = strId;
		xxItemData.strSdelayerName = strSdeName;
		xxItemData.strCadLayerName = pEnt->layer();
		xxItemData.strRowId = strRowId;

		mapItemData[strId] = xxItemData;

		nPos++;
	}
	
	acedSSFree(ssName);

	CompleteEditorCommand();

	if (m_wndTree.GetCount() <= 0)
	{
		return;
	}

	HTREEITEM hItem = m_wndTree.GetFirstVisibleItem();

	// 显示属性
	OnSelectChanged(hItem);
}
示例#27
0
ArxDbgRbList::~ArxDbgRbList()
{
    if (m_head)
        acutRelRb(m_head);
}
示例#28
0
// Creates an AsdkOwnerDemo object (pObjC) and adds data to
// it.  Next AsdkOwnerDemo pObjC is created and set to be
// the owner of pObjC.  Next AsdkOwnerDemo pObjA is created
// and set to own pObjB.  Finally pObjA is added to a
// dictionary in the named object dictionary.  Technically
// we could just add pObjA to the named object dictionary
// itself,  but that's bad form since it will tend to
// clutter up the named object dictionary.
// 
// THE FOLLOWING CODE APPEARS IN THE SDK DOCUMENT.
//
int 
createObjs()
{
    struct resbuf *pList;
    ads_name enameA, enameB, enameC,
        namedObj, enameTestDict;

    // Create a resbuf list of objC's info and data.  This
    // will include a "dummy" ownership group of 0 since
    // this object won't own any others. The group 70 is the
    // "dummy" integer data value.
    // 
    pList = acutBuildList(RTDXF0, "ASDKOWNERDEMO", 100,
        "AsdkOwnerDemo", 70, 3, 0);

    // Create the object "C" with no owner set.  The
    // object's new entity name will be placed into the
    // objC argument.
    //
    acdbEntMakeX(pList, enameC);
    acutRelRb(pList);

    // Create a resbuf list of objB's info and data.  This
    // will include an ownership group with the entity name
    // of objC.  The group 70 is the "dummy" integer data
    // value.
    // 
    pList = acutBuildList(RTDXF0, "ASDKOWNERDEMO",
        100, "AsdkOwnerDemo", 70, 2, 360, enameC, 0);

    // Create the object "B" with no owner set.  The
    // object's new entity name will be placed into the objC
    // argument
    // 
    acdbEntMakeX(pList, enameB);
    acutRelRb(pList);

    // Create a resbuf list of objA's info and data.  This
    // will include an ownership group with the entity name
    // of objB.  The group 70 is the "dummy" integer data
    // value.
    // 
    pList = acutBuildList(RTDXF0, "ASDKOWNERDEMO",
        100, "AsdkOwnerDemo", 70, 1, 360, enameB, 0);

    // Create the object "A" with no owner set.  The
    // object's new entity name will be placed into the objC
    // argument
    // 
    acdbEntMakeX(pList, enameA);
    acutRelRb(pList);

    // Add object A to a dictionary so it has an owner.

    // Look for the dictionary associated with the key
    // "ASDK_DICT".  If it is not found,  create it and add
    // it to the named object dictionary.
    // 
    acdbNamedObjDict(namedObj);
    if ((pList = acdbDictSearch(namedObj, "ASDK_DICT", 0))
        == NULL)
    {
        pList = acutBuildList(RTDXF0, "DICTIONARY",
            100, "AcDbDictionary", 0);
        acdbEntMakeX (pList, enameTestDict);
        acdbDictAdd(namedObj, "ASDK_DICT", enameTestDict);
    } else {
        // The entity name is always returned in the first resbuf.
        //
        ads_name_set(enameTestDict, pList->resval.rlname);
    }

    // Now add object A to the ASDK_DICT dictionary
    // so it has an owner.
    //
    acdbDictAdd(enameTestDict, "OBJA", enameA);
    acutRelRb(pList);

    acedRetVoid();
    return RTNORM;
}
示例#29
0
bool addXData()
{
	Acad::ErrorStatus es, esTmp;
	CLogger::Print(_T("*Call: addXData()"));

	//------------
	// Require to select an entity.
	AcDbObject* pObj = selectObject(AcDb::kForRead);
	if (!pObj) {
		CLogger::Print(_T("*Exit: addXData() - Khong chon duoc object!"));
		return false;
	}

	//------------
	// Require to enter the application name, then require to enter its string value.
	ACHAR appName[133], resString[133];
	appName[0] = resString[0] = L'\0';
	acedGetString(NULL, ACRX_T("\nEnter application name: "), appName);
	acedGetString(NULL, ACRX_T("\nEnter string to be added: "), resString);

	CLogger::Print(_T("Inform: Found out application name '%s'!"), appName);
	struct resbuf * pRb;
	struct resbuf * pTemp;
	pRb = pObj->xData(appName);

	if (pRb) {
		// If the appname is existing! Seek to the tail of resbuf link list.
		CLogger::Print(_T("Inform: Found out application name '%s' - Seek to the end of resbuf link list."), appName);
		for (pTemp = pRb; pTemp->rbnext; pTemp = pTemp->rbnext) {}
	} else {
		// If the appname is not existing! Register a new application name.
		CLogger::Print(_T("Inform: The application name %s is not existing, register this application name!"), appName);
		acdbRegApp(appName);

		// Then create new resbuf to copy the application name into it.
		pRb = acutNewRb(AcDb::kDxfRegAppName);
		pTemp = pRb;
		pTemp->resval.rstring = (ACHAR*) malloc((lstrlen(appName) + 1) * sizeof(ACHAR));
		lstrcpy(pTemp->resval.rstring, appName);
	}

	//------------
	// Create new resbuf at the tail of the link list, then copy the value string into it.
	pTemp->rbnext = acutNewRb(AcDb::kDxfXdAsciiString);
	pTemp = pTemp->rbnext;
	pTemp->resval.rstring = (ACHAR*) malloc((lstrlen(resString) + 1) * sizeof(ACHAR));
	lstrcpy(pTemp->resval.rstring, resString);

	CLogger::Print(_T("Inform: Upgrade object opening!"));
	if (Acad::eOk != (es = pObj->upgradeOpen())) {
		CLogger::Print(_T("*Exit: addXData() - Fail to upgrade opening object!"));
		pObj->close();
		acutRelRb(pRb);
		return false;
	}

	//------------
	// Set object's xData.
	pObj->setXData(pRb);
	pObj->close();
	acutRelRb(pRb); // remember to release resbuf after using
	CLogger::Print(_T("*Exit: addXData()!"));
	return true;
}
void 
addXdata() 
{
    AcDbObject* pObj = selectObject(AcDb::kForRead);
    if (!pObj) {
        acutPrintf(_T("Error selecting object\n"));
        return;
    }

    
    // Get the application name and string to be added to
    // xdata.
    //
    TCHAR appName[132], resString[200];
    appName[0] = resString[0] = _T('\0');

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

    
    struct  resbuf  *pRb, *pTemp;
    
    pRb = pObj->xData(appName);

    if (pRb != NULL) {

        // If xdata is present, then walk to the
        // end of the list.
        //
        for (pTemp = pRb; pTemp->rbnext != NULL;
                pTemp = pTemp->rbnext)
                { ; }
    } else {
        // If xdata is not present, register the application
        // and add appName to the first resbuf in the list.
        // Notice that there is no -3 group as there is in
        // AutoLISP. This is ONLY the xdata so
        // the -3 xdata-start marker isn't needed.
        // 
        acdbRegApp(appName);

        pRb = acutNewRb(AcDb::kDxfRegAppName);
        pTemp = pRb;
        const size_t nSize = _tcslen(appName) + 1;
        pTemp->resval.rstring
            = (TCHAR*) malloc(nSize * sizeof(TCHAR));
        errno_t err = _tcscpy_s(pTemp->resval.rstring, nSize, appName);
        assert(err == 0);
    }

    // Add user-specified string to the xdata.
    //
    pTemp->rbnext = acutNewRb(AcDb::kDxfXdAsciiString);
    pTemp = pTemp->rbnext;
    const size_t nSize = _tcslen(resString) + 1;
    pTemp->resval.rstring
        = (TCHAR*) malloc(nSize * sizeof(TCHAR));
    errno_t err = _tcscpy_s(pTemp->resval.rstring, nSize, resString);
    assert(err == 0);

    // The following code shows the use of upgradeOpen()
    // to change the entity from read to write.
    //
    pObj->upgradeOpen();
    pObj->setXData(pRb);
    
    pObj->close();
    acutRelRb(pRb);
}