developer:sdksamples:isocurvedensity


Adjusting Surface Isocurve Density

Summary: Demonstrates how to modify the isocurve density of a surface.

Question

I am create a new surface from a selected curve, but it always a single isocurve acrossing the surface. I have to adjust isocurve density after the fact from Rhino's Properties window. Can I do this automatically from my plug-in?

Answer

The isocurve density for surface object is stored on the object's attributes. For C++ plug-ins, this would be the CRhinoObjectAttributes and ON_3dmObjectAttributes classes. For .NET plug-ins, this would be the MRhinoObjectAttributes and On3dmObjectAttributes classes. Just set the m_wire_density property. Note, setting this property to zero (0) will disable the display of isocurves for that object.

C++

CRhinoCommand::result CCommandFooBar::RunCommand( const CRhinoCommandContext& context )
{
  CRhinoGetObject go;
  go.SetGeometryFilter( CRhinoGetObject::surface_object );
  go.GetObjects( 1, 1 );
  if( go.CommandResult() == CRhinoCommand::success )
  {
    const CRhinoObjRef& objref = go.Object(0);
    const CRhinoBrepObject* brep_obj = CRhinoBrepObject::Cast( objref.Object() );
    if( brep_obj )
    {
      CRhinoObjectAttributes atts = brep_obj->Attributes();
      atts.m_wire_density = 3; // for example
      context.m_doc.ModifyObjectAttributes( objref, atts );
      context.m_doc.Redraw();
    }
  }
 
  return go.CommandResult();
}

C#

public override IRhinoCommand.result RunCommand(IRhinoCommandContext context)
{
  MRhinoGetObject go = new MRhinoGetObject();
  go.SetGeometryFilter(IRhinoGetObject.GEOMETRY_TYPE_FILTER.surface_object);
  go.GetObjects(1, 1);
  if (go.CommandResult() == IRhinoCommand.result.success)
  {
    MRhinoObjRef objref = go.Object(0);
    IRhinoBrepObject brep_obj = MRhinoBrepObject.ConstCast(objref.Object());
    if (brep_obj != null)
    {
      MRhinoObjectAttributes atts = new MRhinoObjectAttributes() = brep_obj.Attributes();
      atts.m_wire_density = 3; // for example
      context.m_doc.ModifyObjectAttributes(objref, atts);
      context.m_doc.Redraw();
    }
  }
  return go.CommandResult();
 }
developer/sdksamples/isocurvedensity.txt · Last modified: 2010/12/27 13:20 by steve Driven by DokuWiki Recent changes RSS feed

 © 1997-2012 

McNeel North America Europe Latin AmericaAsia