algorithmic modeling for Rhino
It's pretty simple coding.
So you can find fault easily :D
Here's the code.
protected override void RegisterInputParams(GH_Component.GH_InputParamManager pManager)
{
pManager.AddGeometryParameter("Geometry", "G", "Description", GH_ParamAccess.list);
pManager.AddNumberParameter("Factor", "F", "Description", GH_ParamAccess.item);
}
protected override void RegisterOutputParams(GH_Component.GH_OutputParamManager pManager)
{
pManager.AddGeometryParameter("Geometry", "G", "Description", GH_ParamAccess.list);
}
protected override void SolveInstance(IGH_DataAccess DA)
{
List<IGH_GeometricGoo> geometry = new List<IGH_GeometricGoo>();
double factor = double.MaxValue;
if (!DA.GetDataList(0, geometry))
return;
if (!DA.GetData(1, ref factor))
return;
if(factor <=0)
{
AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Factor must be a positive Number");
return;
}
if (geometry.Count == 0)
return;
for(Int32 i=0 ; i<geometry.Count - 1 ; i++)
{
Rhino.Geometry.Point3d pt = Rhino.Geometry.Point3d.Unset;
BoundingBox bbox = geometry[i].Boundingbox;
if (!bbox.IsValid)
continue;
pt = bbox.Center;
geometry[i].Transform(Rhino.Geometry.Transform.Scale(pt, factor));
}
DA.SetDataList(0,geometry);
}
There's no compile error nor runtime error.
but... actually, this component do nothing T^T;;
I need your help :D
Thanks in advance.
Tags:
Moved to the C# forum.
--
David Rutten
david@mcneel.com
geometry[i].Transform(Rhino.Geometry.Transform.Scale(pt, factor));
That's the problem. The Transform() method on IGH_GeometricGoo does not modify the geometry itself,it returns a new instance of IGH_GeometricGoo that is transformed. This was done because not all types of geometry can be reliably transformed by every type of transform (i.e. circles and arcs for example turn into ellipses and ellipse segments when scaled with non-uniform factors).
The code you need is:
geometry[i] = geometry[i].Transform(Transform.Scale(pt, factor));
--
David Rutten
david@mcneel.com
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
© 2024 Created by Scott Davidson. Powered by