Esempio n. 1
0
 /// <summary>
 /// Returns grips for this object If grips are enabled. If grips are not
 /// enabled, returns null.
 /// </summary>
 /// <returns>An array of grip objects; or null if there are no grips.</returns>
 public GripObject[] GetGrips()
 {
   IntPtr pThis = ConstPointer();
   IntPtr pGripList = UnsafeNativeMethods.ON_GripList_New();
   int count = UnsafeNativeMethods.CRhinoObject_GetGrips(pThis, pGripList);
   GripObject[] rc = null;
   if (count > 0)
   {
     System.Collections.Generic.List<GripObject> grips = new System.Collections.Generic.List<GripObject>();
     for (int i = 0; i < count; i++)
     {
       IntPtr pGrip = UnsafeNativeMethods.ON_GripList_Get(pGripList, i);
       uint sn = UnsafeNativeMethods.CRhinoObject_RuntimeSN(pGrip);
       if (IntPtr.Zero != pGrip && sn > 0)
       {
         GripObject g = new GripObject(sn);
         grips.Add(g);
       }
     }
     if (grips.Count > 0)
       rc = grips.ToArray();
   }
   UnsafeNativeMethods.ON_GripList_Delete(pGripList);
   return rc;
 }
Esempio n. 2
0
    internal static RhinoObject CreateRhinoObjectHelper(IntPtr pRhinoObject)
    {
      if (IntPtr.Zero == pRhinoObject)
        return null;

      uint sn = UnsafeNativeMethods.CRhinoObject_RuntimeSN(pRhinoObject);
      if (sn < 1)
        return null;

      int type = UnsafeNativeMethods.CRhinoRhinoObject_GetRhinoObjectType(pRhinoObject);
      if (type < 0)
        return null;
      RhinoObject rc;
      switch (type)
      {
        case idxCRhinoPointObject: //1
          rc = new PointObject(sn);
          break;
        case idxCRhinoCurveObject: //2
          rc = new CurveObject(sn);
          break;
        case idxCRhinoMeshObject: //3
          rc = new MeshObject(sn);
          break;
        case idxCRhinoBrepObject: //4
          rc = new BrepObject(sn);
          break;
        case idxCRhinoPointCloudObject: //5
          rc = new PointCloudObject(sn);
          break;
        case idxCRhinoAnnotationTextObject: //6
          rc = new TextObject(sn);
          break;
        case idxCRhinoSurfaceObject: //7
          rc = new SurfaceObject(sn);
          break;
        case idxCRhinoInstanceObject: //8
          rc = new InstanceObject(sn);
          break;
        case idxCRhinoHatchObject: //9
          rc = new HatchObject(sn);
          break;
        case idxCRhinoDetailViewObject: //10
          rc = new DetailViewObject(sn);
          break;
        case idxCRhinoClippingPlaneObject: //11
          rc = new ClippingPlaneObject(sn);
          break;
        case idxCRhinoTextDot: //12
          rc = new TextDotObject(sn);
          break;
        case idxCRhinoGripObject: //13
          rc = new GripObject(sn);
          break;
#if USING_V5_SDK
        case idxCRhinoExtrusionObject: //14
          rc = new ExtrusionObject(sn);
          break;
#endif
        case idxCRhinoLinearDimension: //15
          rc = new LinearDimensionObject(sn);
          break;
        case idxCRhinoAnnotationObject: //16
          rc = new AnnotationObjectBase(sn);
          break;
        case idxCRhinoLight: //17
          rc = new LightObject(sn);
          break;
        case idxCRhinoMorphControl: //18
          rc = new MorphControlObject(sn);
          break;
        case idxCRhinoRadialDimension: //19
          rc = new RadialDimensionObject(sn);
          break;
        case idxCRhinoAngularDimension: //20
          rc = new AngularDimensionObject(sn);
          break;
        default:
          rc = new RhinoObject(sn);
          break;
      }
      return rc;
    }