Whats new in openNURBS 6 API's compare to previous versions


(Sandip Ichake) #1

Hi,

Can someone guide me to get the whats new/changes in opennurbs 6 as compare to previous version with API’s perspective. Any documents/link regarding that.

-Thanks


(Dale Fugier) #2

Hi @sandip.ichake,

I’d start here:

Some of the basic samples have been updated.

– Dale


(Sandip Ichake) #3

Hi Dale,

Thanks you for your response!

I am looking at the exact API change list like, now opnenurbs_annotation.cpp & opennurbs_annotation2.cpp files are not present in Rhino 6, new file added opennurbs_annotationbase.cpp. Also found many methods signature/enums/classes are changed and many more…

Are you aware of any documentation related to that?

Thanks,
Sandip


(Dale Fugier) #4

Hi @sandip.ichake,

There isn’t a resource that documents every change.

However, some find this useful (too).

– Dale


(Steve Baer) #5

Do you have a different API that you work with where this change list is provided? Maybe we can pattern something based on an example.


(Sandip Ichake) #6

Hi Dale/Steve,

Thanks you for your response!

In addition to above changes I found that, ONX_Model have many changes like m_font_table, m_group_table, m_material_table, m_linetype_table, m_layer_table,m_hatch_pattern_table etc are not part of this class.

Was getting the font and its Id information for ON_Leader with:

onxModel->m_font_table.At (onLeader->Index ()) //use to return the ON_Font

Now in opennurbs6 these variables are not available, how to fetch information like this?

Thanks,
Sandip


(Dale Fugier) #7

Hi @sandip.ichake,

Use iterators to go through the contents of an ONX_Model. For an example, look at the source code for ONX_Model::DumpComponentList() in opennurbs_extensions.cpp.

ON_ComponentManifest is a manifest of every component in a model or 3DM file. It provides simple ways fo find components by id or name. The function ONX_Model.Manifest() returns the manifest of the ONX_Model. When merging models, ON_ManifestMap can be used to efficiently manage name and id collisions.

Specifically for annotations, such as leaders, you will want to review Annotation Objects guide.

To your specific question, you can obtain as leader’s font by doing something like this:

ONX_Model model = ...

// Create a model geometry interator
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())
{
  // Get the model geometry
  const ON_ModelGeometryComponent* model_geometry = ON_ModelGeometryComponent::Cast(model_component);
  if (nullptr == model_geometry)
    continue;

  // Try getting an annotation leader
  const ON_Leader* leader = ON_Leader::Cast(model_geometry->Geometry(nullptr));
  if (nullptr == leader)
    continue;

  // Get the parent dimension style
  const ON_ModelComponentReference& parent_dim_style_ref = model.DimensionStyleFromId(leader->DimensionStyleId());
  const ON_DimStyle* parent_dim_style = ON_DimStyle::Cast(parent_dim_style_ref.ModelComponent());
  if (nullptr == parent_dim_style)
    continue;
    
  // Get the effective dimension style
  const ON_DimStyle& dim_style = leader->DimensionStyle(*parent_dim_style);

  // Get the font
  const ON_Font& font = dim_style.Font();

  // TODO...
}

– Dale