public SampleCsGumballCylinderGetPoint(SampleCsGumballCylinder cylinder, GumballDisplayConduit radiusDc, GumballDisplayConduit heightDc) { m_cylinder = cylinder; m_radius_dc = radiusDc; m_height_dc = heightDc; m_base_origin = Point3d.Unset; m_base_point = Point3d.Unset; }
protected override Result RunCommand(RhinoDoc doc, RunMode mode) { GetPoint gp = new GetPoint(); gp.SetCommandPrompt("Base of cylinder"); gp.Get(); if (gp.CommandResult() != Result.Success) { return(gp.CommandResult()); } Point3d center = gp.Point(); Plane plane = Plane.WorldXY; RhinoView view = gp.View(); if (null != view) { plane = view.ActiveViewport.ConstructionPlane(); } plane.Origin = center; var cylinder = new SampleCsGumballCylinder(plane, m_radius, m_height); var radius_go = new GumballObject(); var height_go = new GumballObject(); var radius_dc = new GumballDisplayConduit(); var height_dc = new GumballDisplayConduit(); var radius_gas = RadiusGumballAppearanceSettings(); var height_gas = HeightGumballAppearanceSettings(); while (true) { radius_go.SetFromPlane(cylinder.RadiusPlane); height_go.SetFromPlane(cylinder.HeightPlane); radius_dc.SetBaseGumball(radius_go, radius_gas); height_dc.SetBaseGumball(height_go, height_gas); radius_dc.Enabled = true; height_dc.Enabled = true; var gx = new SampleCsGumballCylinderGetPoint(cylinder, radius_dc, height_dc); gx.SetCommandPrompt("Drag gumball. Press Enter when done"); gx.AcceptNothing(true); gx.MoveGumball(); radius_dc.Enabled = false; height_dc.Enabled = false; if (gx.CommandResult() != Result.Success) { break; } var res = gx.Result(); if (res == GetResult.Point) { var radius = cylinder.Radius; var height = cylinder.Height; cylinder = new SampleCsGumballCylinder(plane, radius, height); continue; } if (res == GetResult.Nothing) { m_radius = cylinder.Radius; m_height = cylinder.Height; cylinder = new SampleCsGumballCylinder(plane, m_radius, m_height); var brep = cylinder.ToBrep; if (null != brep) { doc.Objects.AddBrep(brep); } } break; } doc.Views.Redraw(); return(Result.Success); }