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;
}
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;
}
Beispiel #3
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;
}
Beispiel #4
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);
}
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);
}
Beispiel #6
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;
}
frgExtractTopologicalEntsFromLinesAlgm::frgExtractTopologicalEntsFromLinesAlgm()
	: _topologies(new rlTopologicalEnt2dSet())
	, _filter(acutBuildList(-4, _T("<AND"), 8, _T("fmk_lines"), RTDXF0, _T("LINE"), -4, _T("AND>"), RTNONE))
{
}
frgExtractTopologicalEntsFromLinesAlgm::frgExtractTopologicalEntsFromLinesAlgm(const AcDbObjectIdArray &line_ids)
	: _topologies(new rlTopologicalEnt2dSet())
	, _lines(line_ids)
	, _filter(acutBuildList(-4, _T("<AND"), 8, _T("fmk_lines"), RTDXF0, _T("LINE"), -4, _T("AND>"), RTNONE))
{
}