SUComponentDefinitionGetType always returns SUComponentType_Normal


#1

Having tested a model with groups and components, I have discovered that calling SUComponentDefinitionGetType on any Component Definition always returns SUComponentType_Normal, even if the definition refers to a group.

In ruby the same definitions return true when the method .group? is called on the definition.

Is this a bug, or am I missing something?

[EDIT]
On further investigation, I get the following results (note I am using my C++ wrapper here: https://github.com/TommyKaneko/Sketchup-API-C-Wrapper ).

The method is_group below is the same as function for (SUComponentDefinitionGetType(definition) == SUComponentType_Group)

  SUModelRef model = SU_INVALID;
  SUResult res = SUModelCreateFromFile(&model, "model.skp");
  std::vector<CW::ComponentDefinition> defs = cw_model.definitions();
  std::vector<CW::Group> groups;
  std::cout << defs.size() << " defs\n";
  for (size_t i=0; i < defs.size(); i++) {
    SUComponentType type;
  	SU_RESULT res = SUComponentDefinitionGetType(defs[i].ref(), &type);
  		std::cout << "Definition is Type " << type << "\n";
    if (defs[i].is_group()) {
  		std::cout << "Definition is Group \n";
    	groups.push_back(defs[i].create_group());
    }
    else {
  		std::cout << "Definition is not Group \n";
    }
  }

The above returns only “Definition is not Group”. So when looking through the model’s ComponentDefinitions, the definitions all say they are not definitions of a group.

However, when you access the definitions through the Entities object, a very different result is returned:

  SUModelRef model = SU_INVALID;
  SUResult res = SUModelCreateFromFile(&model, "model.skp");
  std::cout << "Checking Model for Groups\n";
  CW::Model cw_model(model);
  using namespace CW;
  std::vector<Group> groups = cw_model.entities().groups();
  for (size_t i=0; i < groups.size(); i++) {
  	bool is_g = groups[i].definition().is_group();
    if (is_g) {
  		std::cout << "Definition is Group \n";
    }
    else {
  		std::cout << "Definition is not Group \n";
    }
  }

The above does return “Definition is Group”


#2

DARN! I just realised about SUModelGetGroupDefinitions! My error

Is there a way to delete this post?


#3

This topic was automatically closed after 91 days. New replies are no longer allowed.