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

How can I hide or show layers by name?

Linh
Contributor

How to hide or show the ESC layer as shown in the image below

 

Screenshot 2023-10-31 231451.pngScreenshot 2023-12-20 011358.png

1 REPLY 1
Akos Nagy
Graphisoft
Graphisoft

Hi Linh,

You have to change the bit of APILay_Hidden in the attr.header.flags attribute to get the desired result.

If you always want to show or hide the layer then use the proper branch of the commented solution.

		GS::UniString attrName = *attr.header.uniStringNamePtr;

		if (attrName == "Structural - Bearing") {
			/* change the bit to the opposite in case if you need a one-way solution
			const bool isHiddenLayer = attr.header.flags & APILay_Hidden;
			if (isHiddenLayer) {
				attr.header.flags &= ~APILay_Hidden;
			} else {
				attr.header.flags |= APILay_Hidden;
			}
			*/

			// change the bit to the opposite in one line
			attr.header.flags ^= APILay_Hidden;

			ACAPI_Attribute_Modify (&attr, nullptr);
		}

 
Kind Regards,
Ákos