Create a dimension in C++

Hi guys,

I need help.

I need to create some dimensions between these lines in my plugin with C++, similar to a dimension created by hand.

Hi @Luciano_Luiz_da_Silv,

Here is a simple example:

CRhinoCommand::result CCommandTestMe::RunCommand(
  const CRhinoCommandContext& context
)
{
  ON_Plane plane = ON_Plane::World_xy;
  ON_3dPoint origin = ON_3dPoint::Origin;
  ON_3dPoint offset(0.0, 20.0, 0.0);
  ON_3dPoint point(-3.0, 10.0, 0.0);

  ON_UUID style_id = context.m_doc.m_dimstyle_table.CurrentDimStyleId();

  ON_DimLinear* pDimLinear = ON_DimLinear::CreateAligned(origin, offset, point, plane.Normal(), style_id, nullptr);
  if (nullptr != pDimLinear)
  {
    CRhinoDimLinear* pRhinoDimLinear = new CRhinoDimLinear();
    pRhinoDimLinear->SetDimension(pDimLinear);
    context.m_doc.AddObject(pRhinoDimLinear);
    context.m_doc.Redraw();
  }

  return CRhinoCommand::success;
}

– Dale