algorithmic modeling for Rhino
Hi,
I am trying to offset a curve from multiple surfaces.
1. I get outlines of surfaces.
2. When I want to offset these curves I get lines instead of curves list.
How to write this in a correct way?
private Curve CreateGlass(Brep glassSrf)
{
Brep glass = glassSrf;
Curve[] wireframe = glass.GetWireframe(0);
PolyCurve outline = new PolyCurve();
for (int i = 0; i < wireframe.Length; i++)
{
outline.Append(wireframe[i]);
outline.Append(outline.Offset(Plane.WorldXY, -1, 0.1, 0);
}
return outline;
}
Error for the marked in red:
cannot convert from 'Rhino.Geometry.Curve[]' to 'Rhino.Geometry.Line'
Thank you,
Petras
Tags:
Replies are closed for this discussion.
Hi Petras!
Why do you use the class polycurve instead of curve? The offset function returns an array of curves.
The code bellow collects the results in a list, was this what you wanted?
Brep glass = glassSrf;
Curve[] wireframe = glass.GetWireframe(0);
List<Curve> outline = new List<Curve>();
for (int i = 0; i < wireframe.Length; i++)
{
outline.Add(wireframe[i]);
outline.AddRange(wireframe[i].Offset(Plane.WorldXY, -1, 0.1, 0));
}
return outline;
Hi Daniel,
Thanks for a reply.
Your code in Visual studio does not make any error. But as long as I build the .dll file I get the error in Grasshopper showing that the output is List'1 but supported type is GH_Curve. (Look at attached image).
A part of code:
//Output
protected override void RegisterOutputParams(GH_Component.GH_OutputParamManager pManager)
{
pManager.AddCurveParameter("Glass", "G", "Glass surfaces", GH_ParamAccess.item);
}
//Input
protected override void SolveInstance(IGH_DataAccess DA)
{
// Input
Brep glassSrf = new Brep();
// When data cannot be extracted from a parameter, we should abort this method.
if (!DA.GetData(0, ref glassSrf)) return;
//Offset function
List<Curve> glass = CreateGlass(glassSrf);
//Output
DA.SetData(0, glass);
}
// Main function
private List<Curve> CreateGlass(Brep glassSrf)
{
Brep glass = glassSrf;
Curve[] wireframe = glass.GetWireframe(0);
List<Curve> outlines = new List<Curve>();
for (int i = 0; i < wireframe.Length; i++)
{
outlines.Add(wireframe[i]);
outlines.AddRange(wireframe[i].Offset(Plane.WorldXY, -1, 0.1, 0));
}
return outlines;
}
I think it is because you set the output parameter as GH_ParamAccess.item, rather than GH_ParamAccess.List.
//Output
protected override void RegisterOutputParams(GH_Component.GH_OutputParamManager pManager)
{
pManager.AddCurveParameter("Glass", "G", "Glass surfaces", GH_ParamAccess.list);
}
Thanks it worked, but I had to joined wireframes curves before.
But now I do not get offset curves. Component output shows only outlines but no offset.
How correctly can I offset these boundary curves?
C#:
private List<Curve> CreateGlass(Brep glassSrf)
{
Brep glass = glassSrf;
Curve[] wireframe = glass.GetWireframe(0);
Curve[] wireframeJoined = Curve.JoinCurves(wireframe);
List<Curve> outlines = new List<Curve>();
for (int i = 0; i < wireframe.Length; i++)
{
// component output is surface outline but not offset of the outline
outlines.AddRange(wireframeJoined[i].Offset(Plane.WorldXY, -1, 0.1, 0));
}
return outlines;
}
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