algorithmic modeling for Rhino
Hi,
I get strange behavior when passing custom class through components.
(This custom class does not implement Goo and I unwrap it using GH_ObjectWrapper and then use CastTo)
But what is happening:
I have a custom class in component A and I pass it to component B.
Component B receives it and does something.
But when I move a slider and change some value in component B, component B does not receive anything from component A. It does stuff only in once.
What is a correct way to pass custom class around in gh and is it possible get an example?
Tags:
I provided a sort of minimal implementation of Tile, TileGoo, and TileParameter. It doesn't preview or bake, but the conversion and serialization methods are operational. At least I hope they are, I didn't test any of it.
You just need to make sure that you duplicate your Tile class if you want to change an existing tile. Otherwise the changes will percolate outwards to other parameters that share the same instances.
ps. putting the code below into CastFrom allows you to convert meshes into tiles:
Mesh mesh = null;
GH_Convert.ToMesh(source, ref mesh, GH_Conversion.Both);
if (mesh != null)
{
Value = new Tile(mesh.DuplicateMesh(), null);
return true;
}
When I create the component with tile paramater is this correct as output?
protected override void RegisterOutputParams(GH_Component.GH_OutputParamManager pManager)
{
pManager.AddParameter(new Aggregations_Core.Types.TileParameter());
}
protected override void SolveInstance(IGH_DataAccess DA)
{
DA.SetData(0, new TileGoo(new Aggregations_Core.Types.Tile(obj, plAll.ToArray())) );
}
And probably this is not possible but:
I have a tile object is it possible to use transformation (scale, move orient) components of native grasshopper? Or they must be geometry only. I know I asked this question before how groups in grasshoper does this thing and if it is possible to do the same thing with custom parameter if all the datatypes inside are geometry.
If you derive from GH_GeometricGoo instead of GH_Goo, then you can participate in transformations as well. Also previewing and baking. See my comments in the C# file I posted yesterday.
Hi,
I managed to work apply transformations.
Once I tried to return Mesh after transformation. But I get an error when I want to return a tile:
public override IGH_GeometricGoo Transform(Transform xform)
{
//Transform mesh
if (Value == null) { return null; }
if (Value.Geometry == null) { return null; }
Mesh meshTransformed = Value.Geometry.DuplicateMesh();
meshTransformed.Transform(xform);
//Transform planes
Plane[] planesTransformed = Value.Planes;
for (int i = 0; i < planesTransformed.Length; i++)
planesTransformed[i].Transform(xform);
This gives me error:
return new Tile(meshTransformed, planesTransformed);
But if I return GH type it works, but Is it possible to return the whole tile (planes and mesh?)
return new GH_Mesh(meshTransformed);
}
Thanks I managed to make it work:)
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