Hello everyone,
I am developing a new plugin for Grasshopper. The object has a number of properties, and the issue that I am facing is that when you change the properties and then copy and paste the object, the properties of the new one are the default properties instead of those of the copied object. I would be very thankful if someone could help me fix this as I havent been able to find a solution yet.
These are the properties, and a set of defaults are set in SetDefault():
using System.Drawing;
namespace Grasshopper.Kernel.Special
{
public struct SD_FenceProperties
{
public void SetDefault()
{
this.Width = 3f;
this.Colour = Color.Black;
this.Pattern = "Continuous";
}
public float Width { get; set; }
public Color Colour { get; set; }
public string Pattern { get; set; }
}
}
I imagine here I would need to add some check to only run SetDefaul() if there are no existing properties but I am not sure how to implement this.
public class FenceAttributes : SD_ResizableAttributes<Fence>
{
private GH_Document ghDocument;
public FenceAttributes(Fence owner) : base(owner)
{
// set value to ghDocument
ghDocument = this.Owner.OnPingDocument();
SD_FenceProperties fenceProperties = new SD_FenceProperties();
fenceProperties.SetDefault();
this.Properties = fenceProperties;
}
}
Thanks!