We value your input!
Please participate in Archicad 28 Home Screen and Tooltips/Quick Tutorials survey

Archicad C++ API
About Archicad add-on development using the C++ API.

Getting openings from marquee selection

Anonymous
Not applicable
I am trying to get only openings(windows/doors) from the Marquee Selection, using function
ACAPI_​Selection_​Get
the problem is that it only retrieves walls that are owners of those winows/doors. It is possible to get such selection from archicad when you have Window/Door tool selected and then click Ctrl+A. I have tried to change ToolBoxItem using ACAPI_Environment before getting selection but it gives the same result retrieving only walls.

Hope anyone know the solution.
5 REPLIES 5
Regina Judak
Graphisoft Alumni
Graphisoft Alumni
Hi,

I checked the problem, but if I am doing right what you mentioned I didn’t experience that kind of behavior. I tested it on AC20 and on the upcoming new version with some walls and some windows and doors. I used the Marquee Tool to select the area where the walls are located, and then I selected the door and window tools and pressed Ctrl+A to select all the openings. Than I checked the behavior of the ACAPI_Selection_Get function with the Element_Test example addon (Do_RotateRenovationStatus or Do_CreateDrawingFromSelected2Delems). It retrevied me only all the windows and doors. Please check your code and the code in the test addon. If I didn’t understand well the problem than feel free to ask again. In that case a more detailed code and the version of your AC could be useful for us.

Best, Regina
Anonymous
Not applicable
I have tried but it is not working for me, maybe you can tell me what is wrong with this code?
	API_SelectionInfo	selectionInfo;
	API_Region			region;
	API_ElemTypeID		typeID;
	API_Guid			elemGuid;
	API_Coord3D			c3;
	GSErrCode			err = NoError;

	if (!ClickAnElem("Click a window / door.", API_WindowID, NULL, &typeID, &elemGuid, &c3)) {
		return;
	}

	API_ToolBoxItem		tbi;
	BNZeroMemory(&tbi, sizeof(tbi));
	tbi.typeID = API_WindowID;
	err = ACAPI_Environment(APIEnv_SetToolBoxModeID, &tbi, NULL);
	if (err) {
		WriteReport_Err("Set Toolbox err", err);
	}
	

	selectionInfo.typeID = API_MarqueeRotBox;
	selectionInfo.multiStory = false;

	API_Box			marqueeBox;
	marqueeBox.xMin = c3.x - 0.5;
	marqueeBox.xMax = c3.x + 0.5;
	marqueeBox.yMin = c3.y - 0.5;
	marqueeBox.yMax = c3.y + 0.5;
	
	region.box = marqueeBox;
	region.boxRotAngle = 0.0;
	selectionInfo.marquee = region;
	err = ACAPI_Selection_SetMarquee(&selectionInfo);

	if (err) {
		WriteReport_Err("MarqueErr", err);
	}

	API_SelectionInfo    selectionInfo;
	API_Neig             **selNeigs;
	
	status = ACAPI_Selection_Get(&selectionInfo, &selNeigs, false, false);
	selected = selectionInfo.sel_nElem;
	if (status == APIERR_NOSEL || selectionInfo.typeID == API_SelEmpty) {
		if (warnIfEmpty)
			WriteReport_Alert("Please select an element.");
	}

	if(status == NoError ) {
		UInt32 nSel = BMGetHandleSize((GSHandle)selNeigs) / sizeof(API_Neig);
		for (UInt32 i = 0; i < nSel; ++i) 
			guidArray.Push((*selNeigs).guid);
	}

	BMKillHandle((GSHandle *)&selectionInfo.marquee.coords);
	BMKillHandle((GSHandle *)&selNeigs);
	
Regina Judak
Graphisoft Alumni
Graphisoft Alumni
Hi,
Thanks for the code, now I understand better what is the problem and what you would like to do. Unfortunately it seems that the ACAPI_Selection_Get function doesn’t retrieve the windows and doors from the Marquee area. First I tried to marquee an area and than select all the doors and windows. In this case ACAPI_Selection_Get retrived only the selected elements, in this case the doors and windows. I didn’t find any option to select all the windows/doors from the marquee, but I will check it again.
Do I think well that the important thing is for you that somehow marquee an area and then reach all of the doors and windows on it? Could you describe exactly how you would like to do it? Maybe if I understand better what you would like to do, then I can offer a different solution to you. (Just in case if really there is no method to select the specified elements from the marquee.)

Regina
Anonymous
Not applicable
I have already found the way to select Windows and doors from area I am intrested without using marquee selection. But still thanks for your effort.
Regina Judak
Graphisoft Alumni
Graphisoft Alumni
So is there any question in what you need help, or you've solved the original problem and it works now?