Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to get all MaterialGroups of a model ? #347

Open
gsohler opened this issue Feb 23, 2024 · 0 comments
Open

How to get all MaterialGroups of a model ? #347

gsohler opened this issue Feb 23, 2024 · 0 comments

Comments

@gsohler
Copy link

gsohler commented Feb 23, 2024

I tried to read all BaseMaterialGroups when importing a 3MF Model

I tried this:

Lib3MF::PBaseMaterialGroupIterator basematerial_it = model->GetBaseMaterialGroups();
while (true) {
  if(!basematerial_it->MoveNext()) break;
  std::shared_ptr<Lib3MF::CResource> cr = basematerial_it->GetCurrent();
  std::shared_ptr<Lib3MF::CBaseMaterialGroup> mat = std::dynamic_pointer_cast<Lib3MF::CBaseMaterialGroup>(cr);
  if(mat != nullptr) {
      cout << "worked\n";
  } else cout << "Pointer cast not working\n";
}  

However, the dynamic_pointer_cast does not work even though, reading the header file, CBaseMaterialGroup
is derived from CResource ?

So whats wrong in my strategy ?
How can I get all MaterialGroups ?

class CBaseMaterialGroup : public CResource

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant