Selecting the edges?
Here is the command - I demarked what every section does with comments. It is the last command, the replace one that is currently commented out, that I can’t seem to get to work.
Thanks you for looking at it:
//Select SubD Edges
var go = new GetObject();
go.SetCommandPrompt(“Select SubD edges”);
go.GeometryFilter = ObjectType.EdgeFilter;
go.SubObjectSelect = true;
go.EnablePreSelect(true, true);
go.DeselectAllBeforePostSelect = false;
// Limit to SubD
go.SetCustomGeometryFilter((rhinoObject, geometry, componentIndex) =>
{
return rhinoObject.ObjectType == ObjectType.SubD &&
componentIndex.ComponentIndexType == ComponentIndexType.SubdEdge;
});
go.GetMultiple(1, 0);
if (go.CommandResult() != Result.Success)
return go.CommandResult();
// Iterate through selected edges and add them to the edges list
RhinoList edges = new RhinoList();
for (int i = 0; i < go.ObjectCount; i++)
{
var objRef = go.Object(i);
var subdEdge = objRef.SubDEdge();
if (subdEdge != null)
{
edges.Add(subdEdge);
}
}
//Identify and set the parent SubD
SubD mama = new SubD();
if (edges.Count < 1) return Result.Failure;
else { mama = edges[0].ParentSubD;}
//get the curve to extend to:
go.SetCommandPrompt(“Select Curve to extend to”);
go.GeometryFilter = ObjectType.Curve;
go.SubObjectSelect = false;
go.SetCustomGeometryFilter((obj, geom, compIdx) =>
{
return geom.ObjectType == ObjectType.Curve;
});
go.GetMultiple(1, 1);
if (go.CommandResult() != Result.Success)
return go.CommandResult();
Curve c1 = go.Object(0).Curve();
//Create the SubDs by iterating and calling the function
SubD subdz = new SubD[edges.Count];
for (int i = 0; i < edges.Count; i++)
{
subdz[i] = SupportFunctions.CreateSubdFromEdgeToCurve(edges[i], c1);
}
//Join it all
List subD2join = new List();
subD2join.Add(mama);
for (int i = 0; i < subdz.Length; i++)
{
subD2join.Add(subdz[i]);
}
SubD joined = SubD.JoinSubDs(subD2join, doc.ModelAbsoluteTolerance, false);
doc.Objects.AddSubD(joined[0]);
//doc.Objects.Replace
return Result.Success;