Hi Dale
Trying this, but not winning, please have a peek at my code and see what it is I am missing, must be pretty obvious, but im a tad flummoxed. the goal is to make a tapered pipe that updates when you move control points on the origin curve, but is just the beginnings of a longer routine that will end sphere on either end etc and constants will be replaced with rhino command line options
using System;
using System.Collections.Generic;
using Rhino;
using Rhino.Commands;
using Rhino.Geometry;
using Rhino.Input;
using Rhino.Input.Custom;
namespace SupportHistory
{
public class SupportHistoryCommand : Command
{
public SupportHistoryCommand(){Instance = this;}
static int historyver = 20081237;
public static SupportHistoryCommand Instance{get; private set; }
public override string EnglishName{get { return "SupportHistoryCommand"; }}
protected override Result RunCommand(RhinoDoc doc, RunMode mode)
{
const Rhino.DocObjects.ObjectType filter = Rhino.DocObjects.ObjectType.Curve;
Rhino.DocObjects.ObjRef objref;
Result rc = RhinoGet.GetOneObject("Select curve to process", false, filter, out objref);
if (rc != Result.Success || objref == null)
return rc;
Curve curve = objref.Curve();
RhinoApp.WriteLine("got here 1");
double Start = 1.1, End = 0.8;int Break = 47;
RhinoApp.WriteLine("got here 2");
List<double> Radii = new List<double>(); List<double> offsets = new List<double>();
Radii.Add(Start); Radii.Add(End);
offsets.Add(0); offsets.Add(1);
var support = Brep.CreatePipe(curve, offsets, Radii, false, PipeCapMode.Flat, false, 0.1, RhinoMath.ToRadians(1));
RhinoApp.WriteLine("got here 3");
var aa = doc.Objects.AddBrep(support[0]);
RhinoApp.WriteLine("got here 4");
Rhino.DocObjects.HistoryRecord history = new Rhino.DocObjects.HistoryRecord(this, historyver);
WriteHistory(history, objref,aa, Start,End,Break);
doc.Views.Redraw();
return Result.Success;
}
protected override bool ReplayHistory(Rhino.DocObjects.ReplayHistoryData replay)
{
Rhino.DocObjects.ObjRef objref = null;double Start = 0, End = 0;int Break = 0;Guid guid = Guid.Empty;
if (!ReadHistory(replay, ref objref, ref guid, ref Start, ref End, ref Break))
return false;
Curve curve = objref.Curve();if (null == curve) return false;
List<double> Radii = new List<double>(); List<double> offsets = new List<double>();
Radii.Add(Start); Radii.Add(End);
offsets.Add(0); offsets.Add(1);
var support = Brep.CreatePipe(curve, offsets, Radii, false, PipeCapMode.Flat, false, 0.1, RhinoMath.ToRadians(1));
RhinoDoc.ActiveDoc.Objects.Replace(guid, support[0]);
RhinoDoc.ActiveDoc.Views.Redraw();
return true;
}
private bool ReadHistory(Rhino.DocObjects.ReplayHistoryData replay, ref Rhino.DocObjects.ObjRef objref, ref Guid aa, ref double Start, ref double End, ref int Break)
{
if (historyver != replay.HistoryVersion)
return false;
objref = replay.GetRhinoObjRef(0);if (null == objref)return false;
if (!replay.TryGetGuid(1, out aa)) return false;
if(!replay.TryGetDouble(2, out Start))return false;
if(!replay.TryGetDouble(3, out End)) return false;
if(!replay.TryGetInt(4, out Break)) return false;
return true;
}
private bool WriteHistory(Rhino.DocObjects.HistoryRecord history, Rhino.DocObjects.ObjRef objref,Guid aa, double Start, double End, int Break)
{
if (!history.SetObjRef(0, objref))return false;
if (!history.SetGuid(1, aa)) return false;
if (!history.SetDouble(2, Start))return false;
if (!history.SetDouble(3, End)) return false;
if (!history.SetInt(4, Break)) return false;
return true;
}
}
}