algorithmic modeling for Rhino
I am just a newbies in grasshopper component with c# and also using Grasshopper Tekla Live link (GTlink). I found from forum so can read output parameter from a GTlink component. But I have problem with my output parameter. Can not set correct data to another GTlink component input parameter. Please help. The error is here:
Below is my code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Grasshopper.Kernel;
using Grasshopper.Kernel.Types;
using Rhino.Geometry;
namespace ReadTeklaLivelink
{
public class PositionGoo : GH_Goo<Tekla.Structures.Model.Position>
{
public override bool IsValid
{
get
{
return true;
}
}
public override string TypeDescription
{
get
{
return "Tekla part position";
}
}
public override string TypeName
{
get
{
return typeof(Tekla.Structures.Model.Position).ToString();
}
}
public PositionGoo()
{
}
public PositionGoo(Tekla.Structures.Model.Position pos) : base(pos)
{
}
public override IGH_Goo Duplicate()
{
throw new System.NotImplementedException();
}
public override string ToString()
{
return this.Value.ToString();
}
}
public class PositionParam : GH_Param<PositionGoo>
{
public override System.Guid ComponentGuid
{
get
{
return new System.Guid("4be8ead2-02a7-45e6-900f-859ea43f6b49");
}
}
protected override System.Drawing.Bitmap Icon
{
get
{
return null; //Todo, provide an icon.
}
}
public PositionParam()
: base(new GH_InstanceDescription("Cozy Tekla Postion", "Tpos", "Maintains a collection of Boat Shell data.", "WIP", "Boat"))
{
}
}
public class ReadTeklaLivelinkComponent : GH_Component
{
public ReadTeklaLivelinkComponent()
: base("ReadTeklaLivelink", "Read Data",
"Description",
"Category", "Subcategory")
{
}
protected override void RegisterInputParams(GH_Component.GH_InputParamManager pManager)
{
pManager.AddGenericParameter("GT_Beam", "GTB", "GH Live link beam", GH_ParamAccess.item);
}
protected override void RegisterOutputParams(GH_Component.GH_OutputParamManager pManager)
{
pManager.AddParameter(new PositionParam());
}
protected override void SolveInstance(IGH_DataAccess DA)
{
object beam = null;
if (!DA.GetData(0, ref beam)) { return; }
if (beam == null) { return; }
GH_Goo<Tekla.Structures.Model.ModelObject> gr_beam = beam as GH_Goo<Tekla.Structures.Model.ModelObject>;
Tekla.Structures.Model.ModelObject be_model = gr_beam.Value;
Tekla.Structures.Model.Beam be = be_model as Tekla.Structures.Model.Beam;
PositionGoo pos = new PositionGoo(be.Position);
DA.SetData(0, pos);
}
public override GH_Exposure Exposure
{
get
{
return GH_Exposure.primary;
}
}
protected override System.Drawing.Bitmap Icon
{
get
{
return null;
}
}
public override Guid ComponentGuid
{
get { return new Guid("{bed8c051-7fe8-4b3c-81ec-428550f6f9c0}"); }
}
}
}
Thanks so much!
Tags:
Do you not also have a specific class which implements GH_Goo<Tekla.Structures.Model.ModelObject>, just like PositionGoo? GH_Goo<T> is an abstract class which means it cannot be constructed, this in turn will wreak havoc with the type conversion logic.
You are either going to have to write a specific GH_Goo<Tekla.Structures.Model.ModelObject> implementation, or you'll have to put your ModelObject instance into a GH_ObjectWrapper to pass it around.
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
I follow your instructions but still can not fix. The problem is the Beam Component (in red color) was not mine.
Thanks