There is not API to know whether the object or geometry is hidden In C SDK?

there is not API to know whether the object or geometry is hidden In C SDK?


I have try API " SUModelIsDrawingElementVisible"、“SUDrawingElementGetHidden”、“SUSceneGetDrawingElementHidden” ,which are all not effect…

The functions should be working.

Show a C snippet of how you are attempting to determine the selected group’s hidden flag state.

Also, …

  • What API version are you using?
  • What SketchUp version are you testing with?
  • What SketchUp version was the model drawn with?

This function will take into account the rendering options “DrawHiddenGeometry” and “DrawHiddenObjects” which in your screen snip is shown as enabled. So, this function will return true when these rendering options are set true.

1 Like

SimpleSample.skp (1.1 MB)
this is the skp file ,which contains hidden group
skp file version is sketchup pro 2021

and it is the code to get the hidden state of group

(1) Please post code, not images of code.

(2) The code looks correct for the sample model you attached. Ie, all the groups are visible. Only the edges inside the groups are hidden.

the code below is only run for the skp file “SimpleSample.skp” uploaded above; this skp model contains only group which contains some edges;

CString GetIDStr(SUEntityRef* pEnt)
{
	int64_t entity_id;
	SUResult result = SUEntityGetPersistentID(*pEnt, &entity_id);
	CString strID;
	strID.Format(_T("%lld"), entity_id);
	return strID;
}
bool IsHidden(SUDrawingElementRef& pDrawing,const CString& strID)
{
	bool hidden = false;
	SUResult result = SUDrawingElementGetHidden(pDrawing, &hidden);
	if (SU_ERROR_NONE != result || hidden)
	{
		return true;//can't analyse hidden
	}
	std::string str = CW2A(strID.GetString());
	SUStringRef pid_ref = SU_INVALID;
	SUResult result = SUStringCreateFromUTF8(&pid_ref, str.c_str());
	SUInstancePathRef instance_path_ref = SU_INVALID;
	SUInstancePathCreate(&instance_path_ref);
	result = SUModelGetInstancePathByPid(m_currentSumodel, pid_ref, &instance_path_ref);
	if (SU_ERROR_NONE != result)
	{
		assert(false);
		return true;
	}
	bool bvisible = false;
	result = SUModelIsDrawingElementVisible(m_currentSumodel, instance_path_ref, &bvisible);
	SUInstancePathRelease(&instance_path_ref);
	if (SU_ERROR_NONE != result)
	{
		assert(false);
		return true;
	}
	if (bvisible)
	{
		return false;//can't analyse hidden
	}
	return true;//
}
int main() {
	// Always initialize the API before using it
	SUInitialize();

	// Load the model from a file
	SUModelRef model = SU_INVALID;
	SUModelLoadStatus status;
	SUResult res = SUModelCreateFromFileWithStatus(&model, "SimpleSample.skp", &status);

	if (res != SU_ERROR_NONE) {
		std::cout << "Failed creating model from a file" << std::endl;
		return 1;
	}

	// Get the entity container of the model.
	SUEntitiesRef entities = SU_INVALID;
	SUModelGetEntities(model, &entities);

	size_t numOfGroup = 0;
	SU_CALL(SUEntitiesGetNumGroups(entities_ref, &numOfGroup));
	if (numOfGroup > 0)
	{
		std::vector<SUGroupRef> groupList;
		groupList.resize(numOfGroup);
		size_t numOfGetGroup = 0;
		SUResult result = SUEntitiesGetGroups(entities_ref, numOfGroup, &groupList[0], &numOfGetGroup);
		for (int i = 0; i < numOfGetGroup; ++i)//括历群组
		{
			SUDrawingElementRef element = SUGroupToDrawingElement(groupList[i]);
			CString strGroupID = GetIDStr(&SUGroupToEntity(groupList[i]));
			if (IsHidden(element, strGroupID))
			{
				continue;////analyse group's status 
			}
			SUEntitiesRef group_entities = SU_INVALID;
			result = SUGroupGetEntities(groupList[i], &group_entities);
			if (SU_ERROR_NONE != result)
			{
				continue;
			}
			
			size_t num_edges = 0;
			SU_CALL(SUEntitiesGetNumEdges(entities_ref, false, &num_edges));//SUEdgeGetCurve 获取关联曲线
			if (num_edges > 0)
			{
				std::vector<SUEdgeRef> edges(num_edges);
				SU_CALL(SUEntitiesGetEdges(entities_ref, false, num_edges, &edges[0], &num_edges));
				std::vector<SUEdgeRef>::iterator it = edges.begin();
				std::vector<SUEdgeRef>::iterator itEnd = edges.end();
				for (; it != itEnd; ++it)
				{
					SUDrawingElementRef elementEdge = SUEdgeToDrawingElement(*it);
					CString strEdgeID = GetIDStr(&SUEdgeToEntity(*it));
					if (IsHidden(elementEdge, strGroupID + _T(".") + strEdgeID))
					{
						continue;//analyse edge's status 
					}
				}
			}
		}
	}
	// Must release the model or there will be memory leaks
	SUResult result = SUModelRelease(&model);
	SUTerminate();
}

:grinning:is my code error?

As I said before