コード例 #1
0
void getColumns(){
	API_Element element;
	GSErrCode err;
	char buffer[256];
	columnrepeated columnMsg;
	API_StoryInfo		storyInfo;
	storyinfo* storyInfoMsg;

	err = ACAPI_Environment(APIEnv_GetStorySettingsID, &storyInfo, NULL);
	if (err != NoError) {
		ErrorBeep("APIEnv_GetStorySettingsID", err);
		return;
	}

	GS::Array<API_Guid> elemList;
	ACAPI_Element_GetElemList(API_ColumnID, &elemList);
	for (GS::Array<API_Guid>::ConstIterator it = elemList.Enumerate(); it != NULL; ++it) {

		BNZeroMemory(&element, sizeof(API_Element));
		element.header.guid = *it;
		err = ACAPI_Element_Get(&element);
		if (err == NoError) {
			columnMsg.add_px(element.column.origoPos.x);
			columnMsg.add_py(element.column.origoPos.y);

			storyInfoMsg = columnMsg.add_bottomlevel();
			storyInfoMsg->set_exists(true);
			storyInfoMsg->set_index(element.header.floorInd);
			storyInfoMsg->set_level((*storyInfo.data)[element.header.floorInd - storyInfo.firstStory].level);
			storyInfoMsg->set_name((*storyInfo.data)[element.header.floorInd - storyInfo.firstStory].name);

			storyInfoMsg = columnMsg.add_toplevel();
			storyInfoMsg->set_exists(true);
			storyInfoMsg->set_index(element.header.floorInd + 1);
			storyInfoMsg->set_level((*storyInfo.data)[element.header.floorInd + 1 - storyInfo.firstStory].level);
			storyInfoMsg->set_name((*storyInfo.data)[element.header.floorInd + 1 - storyInfo.firstStory].name);

			columnMsg.add_circular(element.column.circleBased);
			columnMsg.add_angle(element.column.angle);
			columnMsg.add_depth(element.column.coreDepth);
			columnMsg.add_width(element.column.coreWidth);
			columnMsg.add_slantangle(element.column.slantAngle);
			columnMsg.add_slantdirection(element.column.slantDirectionAngle);

			char s[64];
			APIGuid2GSGuid(element.header.guid).ConvertToString(s);
			columnMsg.add_guid(s);

		}
		else{
			sprintf(buffer, ErrID_To_Name(err));
			ACAPI_WriteReport(buffer, true);
		}
	}
	//writeDelimitedTo(wallInfo, raw_out);
	writeDelimitedTo(getClientSocket(), columnMsg);
	BMKillHandle(reinterpret_cast<GSHandle *> (&storyInfo.data));
}
コード例 #2
0
// -----------------------------------------------------------------------------
// Do_ElementEdit
//	edit the linked elements
// -----------------------------------------------------------------------------
static GSErrCode Do_ElementEdit (API_Elem_Head *header)
{
	API_Guid		elemGuid = APINULLGuid;
	Int32			nLinks = 0;
	API_Guid**		linkToList = NULL;
	API_ActTranPars actTranPars;
	API_EditPars	editPars;
	GSErrCode		err;


	BNZeroMemory (&actTranPars, sizeof (API_ActTranPars));
	BNZeroMemory (&editPars, sizeof (API_EditPars));
	ACAPI_Notify_GetTranParams (&actTranPars);
	ActTranPars_To_EditPars (&actTranPars, &editPars);

	elemGuid = header->guid;
	err = ACAPI_Element_GetLinks (elemGuid, &linkToList, &nLinks);
	if (linkToList == NULL || nLinks == 0)
		return NoError;

	if (err == NoError) {
		if (err == NoError) {
			API_Neig**	neigHdl = reinterpret_cast<API_Neig**> (BMAllocateHandle (nLinks * sizeof (API_Neig), ALLOCATE_CLEAR, 0));
			if (neigHdl == NULL)
				return APIERR_MEMFULL;

			for (GSIndex index = 0; index < nLinks; index++) {
				API_Elem_Head elemHead;
				BNZeroMemory (&elemHead, sizeof (API_Elem_Head));
				elemHead.guid = (*linkToList)[index];
				ACAPI_Element_GetHeader (&elemHead);
				ElemHead_To_Neig (&(*neigHdl)[index], &elemHead);
			}

			err = ACAPI_Element_Edit (neigHdl, nLinks, &editPars);
			BMKillHandle (reinterpret_cast<GSHandle*> (&neigHdl));
		}
	}
	BMKillHandle (reinterpret_cast<GSHandle*> (&linkToList));

	return err;
}	// Do_ElementEdit
コード例 #3
0
void Do_ElemSet_Create (void)
{
	GS::Array<API_Guid>  guids;

	// get the guids of a Wall, Column, Beam and Window
	GS::Array<API_Guid>  wallList;
	ACAPI_Element_GetElemList (API_WallID, &wallList);
	if (!wallList.IsEmpty ())
		guids.Push (wallList[0]);
	else
		guids.Push (APINULLGuid);

	GS::Array<API_Guid>  columnList;
	ACAPI_Element_GetElemList (API_ColumnID, &columnList);
	if (!columnList.IsEmpty ())
		guids.Push (columnList[0]);
	else
		guids.Push (APINULLGuid);

	GS::Array<API_Guid>  beamList;
	ACAPI_Element_GetElemList (API_BeamID, &beamList);
	if (!beamList.IsEmpty ())
		guids.Push (beamList[0]);
	else
		guids.Push (APINULLGuid);

	GS::Array<API_Guid>  windowList;
	ACAPI_Element_GetElemList (API_WindowID, &windowList);
	if (!windowList.IsEmpty ())
		guids.Push (windowList[0]);
	else
		guids.Push (APINULLGuid);

	// write a note into the user data
	API_UserData userData;
	BNZeroMemory (&userData, sizeof (userData));
	userData.dataVersion  = 4;
	userData.platformSign = GS::Act_Platform_Sign;
	userData.dataHdl      = BMAllocateHandle (1024, ALLOCATE_CLEAR, 0);
	if (userData.dataHdl != NULL)
		sprintf (*userData.dataHdl, "Original element count: 4, guids [%s,%s,%s,%s]", APIGuidToString (guids[0]).ToCStr ().Get (), APIGuidToString (guids[1]).ToCStr ().Get (), APIGuidToString (guids[2]).ToCStr ().Get (), APIGuidToString (guids[3]).ToCStr ().Get ());

	API_Guid setGuid;
	GSErrCode err = ACAPI_ElementSet_Create (&guids, &userData, &setGuid);
	if (err != NoError) {
		DBPrintf ("Create Element Set error: %d\n", err);
	} else {
		DBPrintf ("Created Element Set (%s)\n", APIGuidToString (setGuid).ToCStr ().Get ());
	}

	BMKillHandle (&userData.dataHdl);
}		/* ElemSet_Create */
コード例 #4
0
// ============================================================================
// Do_ListMonitoredElements
//
//	list observed elements
// ============================================================================
void	Do_ListMonitoredElements (void)
{
	API_Elem_Head**	ppHeads;
	Int32			nElems;
	GSErrCode		err = ACAPI_Element_GetObservedElements (&ppHeads, &nElems);
	if (err != NoError) {
		ErrorBeep ("ACAPI_Element_GetObservedElements", err);
		return;
	}

	for (Int32 i = 0; i < nElems; i++) {
		const API_Elem_Head& refHead = (*ppHeads)[i];
		WriteReport ("%s guid=%s", ElemID_To_Name (refHead.typeID), APIGuidToString (refHead.guid).ToCStr ().Get ());
	}

	BMKillHandle ((GSHandle *) &ppHeads);
}	// Do_ListMonitoredElements
コード例 #5
0
void		Do_UngroupElems (bool	withInput)
{
	API_Elem_Head	**elemHeads;
	Int32			nItem;
	GSErrCode		err;

	if (withInput) {
		elemHeads = ClickElements_ElemHead ("Click groups to ungroup", API_ZombieElemID, &nItem);
	} else {
		nItem = 0;
		elemHeads = NULL;
	}

	err = ACAPI_Element_Tool (elemHeads, nItem, APITool_Ungroup, NULL);
	if (err != NoError)
		ErrorBeep ("ACAPI_Element_Tool (ungroup)", err);

	if (elemHeads != NULL)
		BMKillHandle ((GSHandle *) &elemHeads);

	return;
}		// Do_UngroupElems
コード例 #6
0
void		Do_BackwardElems (bool withInput)
{
	API_Elem_Head	**elemHeads;
	Int32			nItem;
	GSErrCode		err;

	if (withInput) {
		elemHeads = ClickElements_ElemHead ("Click elements to send backward", API_ZombieElemID, &nItem);
	} else {
		nItem = 0;
		elemHeads = NULL;
	}

	err = ACAPI_Element_Tool (elemHeads, nItem, APITool_SendBackward, NULL);
	if (err != NoError)
		ErrorBeep ("ACAPI_Element_Tool (send backward)", err);

	if (elemHeads != NULL)
		BMKillHandle ((GSHandle *) &elemHeads);

	return;
}		// Do_BackwardElems
コード例 #7
0
void getPolyLines(){
	API_Element element;
	API_ElementMemo memo;
	API_StoryInfo storyInfo;
	GSErrCode err;
	char buffer[256];
	getpolylinesmsg msg;
	polylinemsg* polylineMsg;
	pointsmessage* pts;
	polyarcsmessage* arcs;

	err = ACAPI_Environment(APIEnv_GetStorySettingsID, &storyInfo, NULL);
	if (err != NoError) {
		ErrorBeep("APIEnv_GetStorySettingsID", err);
		return;
	}

	GS::Array<API_Guid> elemList;
	ACAPI_Element_GetElemList(API_PolyLineID, &elemList);

	for (GS::Array<API_Guid>::ConstIterator it = elemList.Enumerate(); it != NULL; ++it) {
		BNZeroMemory(&element, sizeof(API_Element));
		element.header.guid = *it;
		err = ACAPI_Element_Get(&element);
		if (hasError(err)){
			quit();
			return;
		}
		err = ACAPI_Element_GetMemo(element.header.guid, &memo);
		if (hasError(err)){
			quit();
			return;
		}

		char s[64];
		APIGuid2GSGuid(element.header.guid).ConvertToString(s);
		msg.add_guids(s);

		polylineMsg = msg.add_polylines();

		pts = new pointsmessage();
		for (int i = 1; i <= element.polyLine.poly.nCoords; i++){
			pts->add_px((*memo.coords)[i].x);
			pts->add_py((*memo.coords)[i].y);
			pts->add_pz((*storyInfo.data)[element.header.floorInd - storyInfo.firstStory].level);
		}
		polylineMsg->set_allocated_pts(pts);
		
		arcs = new polyarcsmessage();
		int arcscounter = 1;
		for (int i = 0; i < element.polyLine.poly.nArcs; i++){
			for (; arcscounter < (*memo.parcs)[i].begIndex; arcscounter++){
				arcs->add_arcangle(0);
				arcs->add_begindex(arcscounter);
				arcs->add_endindex(arcscounter + 1);
			}
			arcs->add_arcangle((*memo.parcs)[i].arcAngle);
			arcs->add_begindex((*memo.parcs)[i].begIndex);
			arcs->add_endindex((*memo.parcs)[i].endIndex);
			arcscounter++;
		}
		polylineMsg->set_allocated_arcs(arcs);
	}

	writeDelimitedTo(getClientSocket(), msg);
	BMKillHandle(reinterpret_cast<GSHandle *> (&storyInfo.data));
}
コード例 #8
0
void getRoofs(){
	API_Element element;
	API_ElementMemo memo;
	GSErrCode err;
	char buffer[256];
	roofrepeated roofMsg;
	API_StoryInfo storyInfo;
	storyinfo* storyInfoMsg;
	pointsmessage* points;
	intlistmsg* subpolygons;

	err = ACAPI_Environment(APIEnv_GetStorySettingsID, &storyInfo, NULL);
	if (err != NoError) {
		ErrorBeep("APIEnv_GetStorySettingsID", err);
		return;
	}

	GS::Array<API_Guid> elemList;
	ACAPI_Element_GetElemList(API_RoofID, &elemList);
	for (GS::Array<API_Guid>::ConstIterator it = elemList.Enumerate(); it != NULL; ++it) {

		BNZeroMemory(&element, sizeof(API_Element));
		element.header.guid = *it;
		err = ACAPI_Element_Get(&element);
		if (err == NoError) {
			err = ACAPI_Element_GetMemo(element.header.guid, &memo);
			if (err == NoError){
				points = roofMsg.add_points();
				subpolygons = roofMsg.add_subpolygons();
				for (int i = 1; i <= element.roof.u.planeRoof.poly.nCoords; i++){
					points->add_px((*memo.coords)[i].x);
					points->add_py((*memo.coords)[i].y);
					points->add_pz((*storyInfo.data)[element.header.floorInd - storyInfo.firstStory].level);
				}

				for (int i = 1; i <= element.roof.u.planeRoof.poly.nSubPolys; i++){
					subpolygons->add_ilist((*memo.pends)[i]);
				}

				storyInfoMsg = roofMsg.add_bottomlevel();
				storyInfoMsg->set_exists(true);
				storyInfoMsg->set_index(element.header.floorInd);
				storyInfoMsg->set_level((*storyInfo.data)[element.header.floorInd - storyInfo.firstStory].level);
				storyInfoMsg->set_name((*storyInfo.data)[element.header.floorInd - storyInfo.firstStory].name);

				roofMsg.add_height(element.roof.shellBase.level);
				roofMsg.add_thickness(element.slab.thickness);

				std::string materialName;

				if (element.roof.shellBase.modelElemStructureType == API_BasicStructure){
					materialName = searchBuildingMaterialsValue(element.roof.shellBase.buildingMaterial);
					roofMsg.add_type("Basic");
				}
				else{
					materialName = searchCompositeMaterialsValue(element.roof.shellBase.composite);
					roofMsg.add_type("Composite");
				}
				if (materialName == "Not Found"){
					sprintf(buffer, "Found no material");
					ACAPI_WriteReport(buffer, true);
				}
				else{
					roofMsg.add_material(materialName);
				}
				char s[64];
				APIGuid2GSGuid(element.header.guid).ConvertToString(s);
				roofMsg.add_guid(s);

			}
		}
		else{
			sprintf(buffer, ErrID_To_Name(err));
			ACAPI_WriteReport(buffer, true);
		}
	}
	writeDelimitedTo(getClientSocket(), roofMsg);
	BMKillHandle(reinterpret_cast<GSHandle *> (&storyInfo.data));
}
コード例 #9
0
void getObjects(){
	API_Element element;
	GSErrCode err;
	char buffer[256];
	objectrepeated objectMsg;
	API_StoryInfo		storyInfo;
	storyinfo* storyInfoMsg;

	err = ACAPI_Environment(APIEnv_GetStorySettingsID, &storyInfo, NULL);
	if (err != NoError) {
		ErrorBeep("APIEnv_GetStorySettingsID", err);
		return;
	}

	GS::Array<API_Guid> elemList;
	ACAPI_Element_GetElemList(API_ObjectID, &elemList);
	for (GS::Array<API_Guid>::ConstIterator it = elemList.Enumerate(); it != NULL; ++it) {

		BNZeroMemory(&element, sizeof(API_Element));
		element.header.guid = *it;
		err = ACAPI_Element_Get(&element);
		if (err == NoError) {

			std::string objectName = searchObjectsValue(element.object.libInd);

			if (objectName == "Not Found"){
				sprintf(buffer, "Found no material");
				ACAPI_WriteReport(buffer, true);
			}
			else{
				objectMsg.add_name(objectName);
			}


			objectMsg.add_px(element.object.pos.x);
			objectMsg.add_py(element.object.pos.y);

			storyInfoMsg = objectMsg.add_bottomlevel();
			storyInfoMsg->set_exists(true);
			storyInfoMsg->set_index(element.header.floorInd);
			storyInfoMsg->set_level((*storyInfo.data)[element.header.floorInd - storyInfo.firstStory].level);
			storyInfoMsg->set_name((*storyInfo.data)[element.header.floorInd - storyInfo.firstStory].name);

			objectMsg.add_angle(element.object.angle);
			objectMsg.add_xratio(element.object.xRatio);
			objectMsg.add_yratio(element.object.yRatio);
			objectMsg.add_bottomoffset(element.object.level);
			if (element.header.variationID == APIVarId_SymbStair){
				objectMsg.add_stairs(true);
			}
			else{
				objectMsg.add_stairs(false);
			}

			objectMsg.add_usexyfixsize(element.object.useXYFixSize);

			char s[64];
			APIGuid2GSGuid(element.header.guid).ConvertToString(s);
			objectMsg.add_guid(s);

		}
		else{
			sprintf(buffer, ErrID_To_Name(err));
			ACAPI_WriteReport(buffer, true);
		}
	}
	writeDelimitedTo(getClientSocket(), objectMsg);
	BMKillHandle(reinterpret_cast<GSHandle *> (&storyInfo.data));
}
コード例 #10
0
// -----------------------------------------------------------------------------
// ElementEventHandlerProc
//
// -----------------------------------------------------------------------------
GSErrCode __ACENV_CALL	ElementEventHandlerProc (const API_NotifyElementType *elemType)
{
	GSErrCode		err = NoError;
	char			msgStr[256];
	char			elemStr[32];

	if (elemType->notifID == APINotifyElement_BeginEvents || elemType->notifID == APINotifyElement_EndEvents) {
		API_DatabaseInfo api_dbPars;
		BNZeroMemory (&api_dbPars, sizeof (API_DatabaseInfo));
		api_dbPars.databaseUnId = elemType->databaseId;
		ACAPI_Database (APIDb_GetDatabaseInfoID, &api_dbPars, NULL);
		sprintf (msgStr, "### Element_Manager: %s notification on database \"%s\"",
				(elemType->notifID == APINotifyElement_BeginEvents) ? "Begin Events" : "End Events",
				(const char *) GS::UniString (api_dbPars.title).ToCStr ());

	} else if (GetElementTypeString (elemType->elemHead.typeID, elemStr)) {
		char				elemGuidStr[64];
		char				parentElemGuidStr[64];
		API_Element			parentElement;
		API_ElementUserData	parentUserData;

		BNZeroMemory (&parentElement, sizeof (API_Element));
		BNZeroMemory (&parentUserData, sizeof (API_ElementUserData));
		ACAPI_Notify_GetParentElement (&parentElement, NULL, 0, &parentUserData);
		BMKillHandle (&parentUserData.dataHdl);

		CHTruncate (APIGuid2GSGuid (elemType->elemHead.guid).ToUniString ().ToCStr (), elemGuidStr, sizeof (elemGuidStr));
		CHTruncate (APIGuid2GSGuid (parentElement.header.guid).ToUniString ().ToCStr (), parentElemGuidStr, sizeof (parentElemGuidStr));

		switch (elemType->notifID) {
			case APINotifyElement_New:
						if (!allNewElements)
							break;

						if (parentElement.header.guid != APINULLGuid)
							sprintf (msgStr, "### Element_Manager: <%s> created {%s} as a copy of {%s}", elemStr, elemGuidStr, parentElemGuidStr);
						else
							sprintf (msgStr, "### Element_Manager: <%s> created {%s}", elemStr, elemGuidStr);

						err = ACAPI_Element_AttachObserver (const_cast<API_Elem_Head*> (&elemType->elemHead), 0);
						if (err == APIERR_LINKEXIST)
							err = NoError;
						break;

			case APINotifyElement_Copy:
						if (!allNewElements)
							break;

						if (parentElement.header.guid != APINULLGuid) {
							sprintf (msgStr, "### Element_Manager: <%s> copied {%s} from {%s}", elemStr, elemGuidStr, parentElemGuidStr);

							err = ACAPI_Element_AttachObserver (const_cast<API_Elem_Head*> (&elemType->elemHead), 0);
							if (err == APIERR_LINKEXIST)
								err = NoError;
						}
						break;

			case APINotifyElement_Change:
						if (parentElement.header.guid != APINULLGuid)
							sprintf (msgStr, "### Element_Manager: <%s> changed {%s} -> {%s}", elemStr, parentElemGuidStr, elemGuidStr);
						else
							sprintf (msgStr, "### Element_Manager: <%s> window/door changed {%s}", elemStr, elemGuidStr);
						break;

			case APINotifyElement_Edit:
						if (parentElement.header.guid != APINULLGuid)
							sprintf (msgStr, "### Element_Manager: <%s> edited {%s} -> {%s}", elemStr, parentElemGuidStr, elemGuidStr);
						else
							sprintf (msgStr, "### Element_Manager: <%s> edited in place {%s}", elemStr, elemGuidStr);

						err = Do_ElementEdit (&parentElement.header);
						break;

			case APINotifyElement_Delete:
						sprintf (msgStr, "### Element_Manager: <%s> deleted {%s}", elemStr, elemGuidStr);
						break;

			case APINotifyElement_Undo_Created:
						sprintf (msgStr, "### Element_Manager: undone <%s> created {%s} ", elemStr, elemGuidStr);
						break;

			case APINotifyElement_Undo_Modified:
						sprintf (msgStr, "### Element_Manager: undone <%s> modified {%s}", elemStr, elemGuidStr);
						break;

			case APINotifyElement_Undo_Deleted:
						sprintf (msgStr, "### Element_Manager: undone <%s> deleted {%s}", elemStr, elemGuidStr);
						break;

			case APINotifyElement_Redo_Created:
						sprintf (msgStr, "### Element_Manager: redone <%s> created {%s}", elemStr, elemGuidStr);
						break;

			case APINotifyElement_Redo_Modified:
						sprintf (msgStr, "### Element_Manager: redone <%s> modified {%s}", elemStr, elemGuidStr);
						break;

			case APINotifyElement_Redo_Deleted:
						sprintf (msgStr, "### Element_Manager: redone <%s> deleted {%s}", elemStr, elemGuidStr);
						break;

			default:
						break;
		}
	}

	ACAPI_WriteReport (msgStr, false);

	return err;
}	// ElementEventHandlerProc