Beispiel #1
0
BOOL TWBlockRefenceTool::Insert( IN const CString& strBlockName, IN const AcGePoint3d& PtIns, IN double dScale, IN double dRat, AcDbDatabase* pDb /*= NULL */ )
{
	/*
		使用简单的实现方法
	*/
	ads_name entPre = { 0, 0 };
	ads_entlast( entPre );

	resbuf rbOld;
	resbuf rbNew;
	rbNew.restype = RTSHORT;
	rbNew.resval.rint = 0;
	acedGetVar( _T("ATTREQ"), &rbOld );
	acedSetVar( _T("ATTREQ"), &rbNew );

	ads_command( RTSTR, _T("insert"), RTSTR, strBlockName, RT3DPOINT, asDblArray(PtIns), RTREAL, 1.0, RTSTR, _T(""), RTREAL, 0.0, 0 );

	acedSetVar( _T("ATTREQ"), &rbOld );

	ads_name ent = { 0 ,0 };
	ads_entlast( ent );

	//判定是否正确生成块参照
	if( ads_name_equal(ent, entPre) )
		return FALSE;

	acdbGetObjectId( m_IdblockRef, ent );
	return IsValid();
}
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
//-----------------------------------------------------------------------------
// Uses acedSetvar() to set the sysvars.
//
bool setIntSysVar(char* pszVarName, int val)
{   
    struct resbuf rb;

    rb.restype = RTSHORT;
    rb.resval.rint = val;

    return (acedSetVar(pszVarName,&rb) == RTNORM);
}
void Additional_Class::Close_ORTHOMODE( void )
{
	resbuf var;
	if(RTNORM == acedGetVar(_T("ORTHOMODE"), &var))
	{
		if( var.resval.rint == 1)
		{
			var.resval.rint = 0;
			acedSetVar(_T("ORTHOMODE"), &var);
			return;
		}
		else
		{
			return;
		}
	}
	return;
}
void
aFunction()
{
    acutPrintf(_T("This is AsdkProfileSample Test Application...\n"));

    // Attach the reactor for the duration of this command. Normally
    // this would likely be added upon application initialization.
    //
    AsdkProfileManagerReactor *pProfileRector = 
        new AsdkProfileManagerReactor();
    
    acProfileManagerPtr()->addReactor(pProfileRector);

    // Obtain the path for the registry keys and print it out.
    //
    TCHAR *pstrKey;
    acProfileManagerPtr()->ProfileRegistryKey(pstrKey, NULL);

    if (pstrKey != NULL) {
        acutPrintf(_T("\nThe profiles registry key is: %s"), pstrKey);
        acutDelString(pstrKey);
    }

    // Get the list of all profiles in the users configuration
    // and print them out.
    //
    AcApProfileNameArray arrNameList;
    int nProfiles = 
        acProfileManagerPtr()->ProfileListNames(arrNameList);

    acutPrintf(_T("\nNumber of profiles currently ")
        _T("in the user profile list is: %d"), nProfiles);
    for (int i = 0; i < nProfiles; i++)
        acutPrintf(_T("\nProfile name is: %s"), arrNameList[i]);
    
    // Copy the unnamed profile to the AsdkTestProfile
    //
    acProfileManagerPtr()->ProfileCopy(_T("AsdkTestProfile"), 
                                       _T("<<Unnamed Profile>>"), 
                                       _T("This is a test"));

    // Reset the newly copied profile to AutoCAD defualts.
    //
    acProfileManagerPtr()->ProfileReset(_T("AsdkTestProfile"));

    // Make this new profile current.
    //
    acProfileManagerPtr()->ProfileSetCurrent(_T("AsdkTestProfile"));
    
    // Change a value in the profile. We'll just make the 
    // cursor big.
    //
    struct resbuf rbCursorSize;
    rbCursorSize.restype = RTSHORT;
    rbCursorSize.resval.rint = 100;
    acedSetVar(_T("CURSORSIZE"), &rbCursorSize);

    // Rename the profile to a new name.
    //
    acProfileManagerPtr()->ProfileRename(_T("AsdkTestProfile2"), 
                                         _T("AsdkTestProfile"), 
                                         _T("This is another test"));

    // Export the profile.
    //
    acProfileManagerPtr()->ProfileExport(_T("AsdkTestProfile2"), 
                                         _T("./AsdkTestProfile2.arg"));

    // Import the profile.
    // 
    acProfileManagerPtr()->ProfileImport(_T("AsdkTestProfile3"), 
                                         _T("./AsdkTestProfile2.arg"), 
                                         _T("This is a copy of AsdkTestProfile2")
                                         _T("by Exporting/Importing"), 
                                         Adesk::kTrue);

    // Remove the reactor.
    //
    acProfileManagerPtr()->removeReactor(pProfileRector);

}
Beispiel #6
0
Acad::ErrorStatus
selectEntity(const AcDb::SubentType& subType,
			 AcDbFullSubentPath&     subPath)
{
	Acad::ErrorStatus acadReturnValue = Acad::eOk;

	int errStat = RTERROR;
	ads_name sset;
	AcGePoint3d pickPnt;

	struct resbuf org_osnap;
	acedGetVar(ACRX_T("OSMODE"), &org_osnap);
	struct resbuf new_osnap = org_osnap;
	new_osnap.resval.rint = 0;
	acedSetVar(ACRX_T("OSMODE"), &new_osnap);

    while ((errStat != RTNORM) && (errStat != RTCAN) && (errStat != RTREJ)
        && (errStat != RTNONE)) {
        ads_name ent_name;
        switch(subType) {
		case AcDb::kNullSubentType:
			errStat = acedEntSel(ACRX_T("\n Pick a solid\n"), ent_name, asDblArray(pickPnt));
			break;
		case AcDb::kFaceSubentType:
			errStat = acedEntSel(ACRX_T("\n Pick a face\n"), ent_name, asDblArray(pickPnt));
			break;
		case AcDb::kEdgeSubentType:
			errStat = acedEntSel(ACRX_T("\n Pick an edge\n"), ent_name, asDblArray(pickPnt));
			break;
		default:
			acutPrintf(ACRX_T("\n getPath: unsupported subentity type: %d\n"), subType);
			return Acad::eInvalidInput;
		}

        if (errStat == RTERROR) {
            struct resbuf buf_errno;
			acedGetVar(ACRX_T("ERRNO"), &buf_errno);
	        if (buf_errno.resval.rint == OL_ENTSELNULL) errStat = RTNONE;
        }
    }

	if (errStat == RTNORM) {
	    errStat = acedSSGet(NULL, asDblArray(pickPnt), NULL, NULL, sset);
	}
    acedSetVar(ACRX_T("OSMODE"), &org_osnap);

	if (errStat != RTNORM) return Acad::eAmbiguousInput;

	// Get the entity name
	struct resbuf* rb;
	errStat = acedSSNameX(&rb, sset, 0L);
    if (errStat != RTNORM) {
		acedSSFree(sset);
		return Acad::eAmbiguousInput;
    }  

	// Free the selection set
    acedSSFree(sset);

	// The selected entity is the final entry in the resbuf
	int i;
    struct resbuf* pTemp;
	for (i=1, pTemp=rb; i<3; i++, pTemp=pTemp->rbnext)
		;
	ads_name ename;
	ads_name_set(pTemp->resval.rlname, ename);

	// Get the GsMarker
	pTemp = pTemp->rbnext;
	short marker = pTemp->resval.rint;

	// Free the rb resbuf entity
	acutRelRb(rb);


	// Get the object ID of the selected entity
	AcDbObjectId objId;
	acadReturnValue = acdbGetObjectId(objId, ename);
    if (acadReturnValue != Acad::eOk) {
		acutPrintf(ACRX_T("\n acdbGetObjectId failed\n"));
		return acadReturnValue;
	}

    // Use an existing transaction if there is one;
	// else open a new one
	Adesk::Boolean ownTransaction = Adesk::kFalse;
	acadReturnValue = dbOpenTransaction(ownTransaction);
	if (acadReturnValue != Acad::eOk) {
		acutPrintf(ACRX_T("\n Error in dbOpenTransaction:"));
		errorReport((AcBr::ErrorStatus)acadReturnValue);
		return acadReturnValue;
	}
	
	// Open the object for read-only
	AcDbObject* pObj = NULL;
	acadReturnValue = actrTransactionManager->getObject(
		pObj, objId, AcDb::kForRead);
	if (acadReturnValue != Acad::eOk) {
		dbAbortTransaction(ownTransaction);
		acutPrintf(ACRX_T("\n Error in getPath:"));
		errorReport((AcBr::ErrorStatus)acadReturnValue);
		return acadReturnValue;
	}

	if (AcDbBlockReference::cast(pObj) != NULL) {
		acadReturnValue = extractSolidFromBlock(ename, subType, marker, pickPnt, subPath);
		if (acadReturnValue != Acad::eOk) {
			dbCloseTransaction(ownTransaction);
			acutPrintf(ACRX_T("\n extractSolidFromBlock failed\n"));
			return acadReturnValue;
		}
	} else {
		AcDbObjectIdArray objIdList;
		objIdList.append(objId);
		acadReturnValue = makeSubentPath(pObj, objIdList, subType, marker, pickPnt, subPath);
		if (acadReturnValue != Acad::eOk) {
			dbCloseTransaction(ownTransaction);
			acutPrintf(ACRX_T("\n makeSubentPath failed\n"));
			return acadReturnValue;
		}
	}

	// Close the transaction
	dbCloseTransaction(ownTransaction);
	
	return acadReturnValue;
}