algorithmic modeling for Rhino
Hi all,
I have this chunk of code to put an icon in a GH component with C#...
protected override Bitmap Internal_Icon_24x24
{
get
{
return Resources.ico_numbers;
}
}
but, Visual Studio 2010 says...
Member 'Generex.Class1.Internal_Icon_24x24' invalids obsolete member 'Grasshopper.Kernel.GH_DocumentObject.Internal_Icon_24x24'. Insert the atribute Obsolete to 'Generex.Class1.Internal_Icon_24x24'.
how could I solve this mess?
thanks!!!!
Tags:
Use the Icon property instead of the Icon_24x24 property.
--
David Rutten
david@mcneel.com
Barcelona, Spain
thanks for replying so fast!
but...with this code:
protected override Bitmap Icon
{
get
{
return Resources.ico_numbers;
}
}
the component does not appear in the tab!
I'm using these libraries:
using System;
using System.Drawing;
using Grasshopper.Kernel;
using Grasshopper.GUI;
using Generex.Properties;
So if you use Icon instead of Icon_24x24 it compiles without problems but it refuses to load in Grasshopper? Are you sure you're compiling and testing the same version of Grasshopper?
--
David Rutten
david@mcneel.com
Barcelona, Spain
hummmm
I'm using Rhino SR9 + GH 51 + VB2010 and compiling the project with .NET Framework 4
should I check anything else?
thanks!
Same problem here. Same setup. No errors/warnings on build. The component does not show up.
Ignoring any of my other newby blunders below.
using System;
using Grasshopper.Kernel;
using Rhino.Geometry;
using System.Drawing;
using MyComponentLibrary.Properties;
namespace MyComponentLibrary
{
public class centerRectangle : GH_Component
{
public centerRectangle()
: base("centerRectagle", "CRect", "Make a rectagle from a center point", "Curve", "Primitive")
{
}
protected override void RegisterInputParams(GH_Component.GH_InputParamManager pManager)
{
pManager.Register_PlaneParam("Plane","P", "The Plane of the rectagle.");
pManager.Register_DoubleParam("X", "X", "Width of Rectangle");
pManager.Register_DoubleParam("Y", "Y", "Height of Rectagle");
//pManager.Register_DoubleParam("R", "R", "Corner Radius");
}
protected override void RegisterOutputParams(GH_Component.GH_OutputParamManager pManager)
{
pManager.Register_RectangleParam("Rectangle", "R", "Rectangle");
pManager.Register_DoubleParam("Length", "L", "Length of Rectangule");
}
protected override void SolveInstance(IGH_DataAccess DA)
{
// declare placeholder variables and assign initial default data.
Rhino.Geometry.Rectangle3d rect = Rhino.Geometry.Rectangle3d.Unset;
Rhino.Geometry.Plane plane = Rhino.Geometry.Plane.WorldXY;
double x = 10.0;
double y = 5.0;
//double r = double.NaN;
// errorcheck
if (!DA.GetData(0, ref plane)) { return; }
if (!DA.GetData(1, ref x)) { return; }
if (!DA.GetData(2, ref y)) { return; }
// offset the origin of the rectangle
double sx = -x / 2;
double sy = -y / 2;
double ex = x / 2;
double ey = y / 2;
//set up intervals for width and height
Rhino.Geometry.Interval ix = new Interval(sx,ex);
Rhino.Geometry.Interval iy = new Interval(sy,ey);
rect.Plane = plane;
rect.X = ix;
rect.Y = iy;
// Assign outputs
DA.SetData(0, new Rhino.Geometry.Rectangle3d(plane, ix, iy));
DA.SetData(1, rect.Circumference);
}
public override Guid ComponentGuid
{
get { return new Guid("306f3b83-b551-4be1-a156-0fe9a505bd9a"); }
}
protected override Bitmap Icon
{
get
{
return Resources.CenterRect;
}
}
}
}
You shouldn't use .NET 4.0. Grasshopper is compiled against 3.5 as it needs to run in Rhino4. I don't know if that's the cause of the problem though.
--
David Rutten
david@mcneel.com
Poprad, Slovakia
Welcome to
Grasshopper
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
© 2024 Created by Scott Davidson. Powered by