public Guid AddSurface(Surface srf, Color color = default(Color)) { if (!IS_ENABLED) { return(Guid.Empty); } //color = DefColor(color); if (color == default(Color)) { color = Color.Coral; } var newSrf = (Surface)srf.Duplicate(); var attr = new ObjectAttributes { LayerIndex = LayerIndex, //Mode = ObjectMode.Locked, - this option will force color to be Gray ObjectColor = color, ColorSource = ObjectColorSource.ColorFromObject }; // Ovveride display mode to color surface http://developer.rhino3d.com/samples/rhinocommon/objectdisplaymode/ DisplayModesManager.ObjectAttributes_SetDisplayModeOverride(attr, DisplayModeType.TopologyColoredSurfaces); //var newBrep = newSrf.ToBrep(); //Guid id = Doc.Objects.AddBrep(newBrep, attr, null, true); Guid id = Doc.Objects.AddSurface(newSrf, attr, null, true); CreateMesh(id); return(id); }
public Guid AddFace(BrepFace face, Color color = default(Color)) // , int displayOrder = 0 { if (!IS_ENABLED) { return(Guid.Empty); } //color = DefColor(color); if (color == default(Color)) { color = Color.Coral; } var newBrep = face.DuplicateFace(true); var attr = new ObjectAttributes { LayerIndex = LayerIndex, //Mode = ObjectMode.Locked, - this option will force color to be Gray //DisplayOrder = displayOrder, doesnt work - why? no clue! ObjectColor = color, ColorSource = ObjectColorSource.ColorFromObject }; // Ovveride display mode to color surface http://developer.rhino3d.com/samples/rhinocommon/objectdisplaymode/ DisplayModesManager.ObjectAttributes_SetDisplayModeOverride(attr, DisplayModeType.TopologyColoredSurfaces); Guid id = Doc.Objects.AddBrep(newBrep, attr, null, true); // create mesh if it not created yet var facemesh = face.GetMesh(MeshType.Any); if (facemesh == null || facemesh.Faces.Count == 0) { CreateMesh(id); } return(id); }