2015-03-27
	
		
		08:55 AM
	
	
	
	
	
	
	
	
	
	
	
	
	
	
 - last edited on 
    
	
		
		
		2023-08-01
	
		
		01:28 PM
	
	
	
	
	
	
	
	
	
	
	
	
	
	
 by 
				
		
		
			Doreena Deng
		
		
		
		
		
		
		
		
	
			
		
API_LockableStatus lockableStatus = ACAPI_TeamworkControl_GetLockableStatus (attrib.header.guid);Thanks
2015-04-07 02:35 AM
 
					
				
		
2015-04-08 09:28 AM
// ---------------------------------- Types ------------------------------------ 
 
#define CitiesGuid				(APIGuidFromString ("5D8068E2-7430-4871-9D67-E06001F256A1")) 
#define CompositesGuid			(APIGuidFromString ("A36401CC-77B1-4410-BCEB-A7684706A17F")) 
#define FavoritesGuid			(APIGuidFromString ("F97013BD-662E-42a1-A749-9C73CD2D0790")) 
#define FillTypesGuid			(APIGuidFromString ("4C036A66-C2FF-4c3b-9FF4-F45A810B5F84")) 
#define LayerSettingsGuid		(ACAPI_TeamworkControl_FindLockableObjectSet ("LayerSettingsDialog")) 
#define LineTypesGuid			(APIGuidFromString ("702A8569-EA8F-4de8-900C-696980FB13D6")) 
#define MarkupStylesGuid		(APIGuidFromString ("156BCF98-CFA6-4be0-BC2C-8252D640A9FB")) 
#define SurfacesGuid			(APIGuidFromString ("5B6A4F99-C72D-4811-90A5-6D696E1AB51F")) 
#define MEPSystemsGuid			(APIGuidFromString ("258B2630-3098-48ea-8923-F712214FBDAE")) 
#define ModelViewOptionsGuid	(APIGuidFromString ("13E263C8-692B-494b-84E3-2B4BD0A77332")) 
#define OperationProfilesGuid	(APIGuidFromString ("0E6DC7E2-5AFC-4309-AB31-2A790CF57A53")) 
#define PenTablesGuid			(APIGuidFromString ("08B4B9BB-3DD6-4ea1-A084-80D80B8B7742")) 
#define ProfilesGuid			(APIGuidFromString ("4779D92D-ACFB-429d-91E5-1D585B9D2CE5")) 
#define ProjectInfoGuid			(APIGuidFromString ("D13F8A89-2AEC-4c32-B04E-85A5393F9C47")) 
#define ProjectPreferencesGuid	(ACAPI_TeamworkControl_FindLockableObjectSet ("PreferencesDialog")) 
#define ZoneCategoriesGuid		(APIGuidFromString ("B83F2FD1-0AD4-4c41-A8EB-6D7558B0A120")) 
#define BuildingMaterialsGuid	(APIGuidFromString ("50477294-5E20-4349-920B-EFC18BF54A0C")) 
 
 
// ============================================================================= 
// 
// Teamwork Reservation function for Attribute sets 
// 
// ============================================================================= 
 
void	ReserveOrRelease_Attributes (const API_Guid& objectSetGuid, const GS::UniString& objectSetName, bool showAlert = true) 
{ 
	bool hasCreateRight = ACAPI_TeamworkControl_HasCreateRight (objectSetGuid); 
	bool hasDeleteModifyRight = ACAPI_TeamworkControl_HasDeleteModifyRight (objectSetGuid); 
	if (!hasCreateRight && !hasDeleteModifyRight) { 
		GS::UniString reportString ("You have insufficient privileges to modify "); 
		reportString.Append (objectSetName); 
		ACAPI_WriteReport (reportString.ToCStr ().Get (), true); 
		return; 
	} 
 
	GS::UniString reportString (objectSetName); 
	GS::PagedArray<GS::UniString> conflicts; 
	API_LockableStatus lockableStatus = ACAPI_TeamworkControl_GetLockableStatus (objectSetGuid, &conflicts); 
 
	if (lockableStatus == APILockableStatus_Free) {					// Free for Reservation - let's reserve it 
		GSErrCode errCode = ACAPI_TeamworkControl_ReserveLockable (objectSetGuid, &conflicts); 
		if (errCode == NoError) 
			reportString.Append (" - Reservation succeeded"); 
		else 
			reportString.Append (" - Reservation failed"); 
 
		lockableStatus = ACAPI_TeamworkControl_GetLockableStatus (objectSetGuid, &conflicts); 
 
	} else if (lockableStatus == APILockableStatus_Editable) {		// Editable - let's release it 
		GSErrCode errCode = ACAPI_TeamworkControl_ReleaseLockable (objectSetGuid); 
		if (errCode == NoError) 
			reportString.Append (" - Release succeeded"); 
		else 
			reportString.Append (" - Release failed"); 
 
		lockableStatus = ACAPI_TeamworkControl_GetLockableStatus (objectSetGuid, &conflicts); 
	} 
 
	reportString.Append ("\n  Teamwork status: "); 
	switch (lockableStatus) { 
		case APILockableStatus_Free:			reportString.Append ("Free for Reservation"); 
												break; 
 
		case APILockableStatus_Editable:		reportString.Append ("Editable"); 
												break; 
 
		case APILockableStatus_Locked:			if (conflicts.IsEmpty ()) { 
													reportString.Append ("Locked by other member"); 
												} else { 
													reportString.Append ("Locked by "); 
													reportString.Append (conflicts[0]); 
												} 
												break; 
 
		case APILockableStatus_NotAvailable:	reportString.Append ("Not available"); 
												break; 
 
		case APILockableStatus_NotExist:		reportString.Append ("Not exist"); 
												break; 
	} 
 
	ACAPI_WriteReport (reportString.ToCStr ().Get (), showAlert); 
}		// ReserveOrRelease_Attributes 
 
 
// ----------------------------------------------------------------------------- 
// 
// Few examples to use: 
// 
// ----------------------------------------------------------------------------- 
 
ReserveOrRelease_Attributes (LayerSettingsGuid,		"Layer Settings"); 
ReserveOrRelease_Attributes (LineTypesGuid,			"Line Types"); 
ReserveOrRelease_Attributes (FillTypesGuid,			"Fill Types"); 
ReserveOrRelease_Attributes (CompositesGuid,		"Composites"); 
ReserveOrRelease_Attributes (SurfacesGuid,			"Surfaces"); 2015-04-08 12:39 PM
 
					
				
		
2015-04-08 12:48 PM
paulk wrote:Reservation status belongs to an Attribute set, not a specific attribute.
How can ACAPI_TeamworkControl_GetLockableStatus () be used for a specific surface pls?
2015-04-08 01:40 PM
Reservation status belongs to an Attribute set, not a specific attribute.Yes, you are right. My understanding of how reserving worked was wrong. Thank you for resolving this.
So it's not possible to lock only one specific attribute. Instead of that you should lock the related attribute set.
You can't lock only one specific surface on the ArchiCAD UserInterface also, can you?