Immigration questions in opennurbs 6.0


Hi guys. I am immigrating an opennurbs 5 application to 6. However, I found that the ONX_Model_Object class is entirely gone. Could I ask is there an replacement for this class in opennurbs 6? Thanks very much!

I may solve this problem. I used the component iterator to get components from model now.


I am using modelObject->Attributes(&ON_3dmObjectAttributes::DefaultAttributes) to get attributes like visibility, mode etc. However, I am not confident with this way. Is there more straightforward way to access attributes like visibility or layers of an object? Thanks for any reply in advance!

I thinks this one is fine now

(Dale Fugier) #3

Hi @sirian_ye,

The replacement ONX_Model_Object, found in earlier version of openNURBS is ON_ModelComponent. And yes, using a ONX_ModelComponentIterator iterator is the correct way for getting components.

If you need a model geometry component’s attributes, use ON_ModelGeometryComponent::Attributes.

For example:

ONX_ModelComponentIterator it(model, ON_ModelComponent::Type::ModelGeometry);
const ON_ModelComponent* model_component = nullptr;
for (model_component = it.FirstComponent(); nullptr != model_component; model_component = it.NextComponent())
  const ON_ModelGeometryComponent* model_geometry = ON_ModelGeometryComponent::Cast(model_component);
  if (nullptr != model_geometry)
    const ON_Geometry* geometry = model_geometry->Geometry(nullptr);
    const ON_3dmObjectAttributes* attributes = model_geometry->Attributes(nullptr);
    if (nullptr != geometry && nullptr != attributes)
      // TODO...

– Dale


thanks very much Dale! Helps a lot.

Could I ask one more question? I am trying to access geometryList in instanceDefinition by using InstanceGeometryIdList from InstanceDefinition. However, it always return me a zero length list no matter what model i am using. Is there any better way to traverse the scene tree via instanceDefinition?

(Dale Fugier) #5

Hi @sirian_ye,

Attached is an example of traversing all of the instance definitions in a 3dm file. Note, this sample is in Rhino SDK command form, but you’ll get the idea.

cmdTestSirian.cpp (6.0 KB)

Let me know if you have any questions.

– Dale


thanks very much Dale. I think I am doing the right thing, my code is generally the same idea of yours. The only problem is the InstanceGeometryIdList always contains no ids. I will give it another try.

Again thanks very much for your helpfully reply!