本文整理汇总了C#中RhinoDoc类的典型用法代码示例。如果您正苦于以下问题:C# RhinoDoc类的具体用法?C# RhinoDoc怎么用?C# RhinoDoc使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
RhinoDoc类属于命名空间,在下文中一共展示了RhinoDoc类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RunCommand
protected override Result RunCommand(RhinoDoc doc, RunMode mode)
{
m_doc = doc;
m_window = new Window {Title = "Object ID and Thread ID", Width = 500, Height = 75};
m_label = new Label();
m_window.Content = m_label;
new System.Windows.Interop.WindowInteropHelper(m_window).Owner = Rhino.RhinoApp.MainWindowHandle();
m_window.Show();
// register the rhinoObjectAdded method with the AddRhinoObject event
RhinoDoc.AddRhinoObject += RhinoObjectAdded;
// add a sphere from the main UI thread. All is good
AddSphere(new Point3d(0,0,0));
// add a sphere from a secondary thread. Not good: the rhinoObjectAdded method
// doesn't work well when called from another thread
var add_sphere_delegate = new Action<Point3d>(AddSphere);
add_sphere_delegate.BeginInvoke(new Point3d(0, 10, 0), null, null);
// handle the AddRhinoObject event with rhinoObjectAddedSafe which is
// desgined to work no matter which thread the call is comming from.
RhinoDoc.AddRhinoObject -= RhinoObjectAdded;
RhinoDoc.AddRhinoObject += RhinoObjectAddedSafe;
// try again adding a sphere from a secondary thread. All is good!
add_sphere_delegate.BeginInvoke(new Point3d(0, 20, 0), null, null);
doc.Views.Redraw();
return Result.Success;
}
示例2: SelByUserText
public static Rhino.Commands.Result SelByUserText(RhinoDoc doc)
{
// You don't have to override RunCommand if you don't need any user input. In
// this case we want to get a key from the user. If you return something other
// than Success, the selection is canceled
return Rhino.Input.RhinoGet.GetString("key", true, ref m_key);
}
示例3: ReplaceHatchPattern
public static Result ReplaceHatchPattern(RhinoDoc doc)
{
ObjRef[] obj_refs;
var rc = RhinoGet.GetMultipleObjects("Select hatches to replace", false, ObjectType.Hatch, out obj_refs);
if (rc != Result.Success || obj_refs == null)
return rc;
var gs = new GetString();
gs.SetCommandPrompt("Name of replacement hatch pattern");
gs.AcceptNothing(false);
gs.Get();
if (gs.CommandResult() != Result.Success)
return gs.CommandResult();
var hatch_name = gs.StringResult();
var pattern_index = doc.HatchPatterns.Find(hatch_name, true);
if (pattern_index < 0)
{
RhinoApp.WriteLine("The hatch pattern \"{0}\" not found in the document.", hatch_name);
return Result.Nothing;
}
foreach (var obj_ref in obj_refs)
{
var hatch_object = obj_ref.Object() as HatchObject;
if (hatch_object.HatchGeometry.PatternIndex != pattern_index)
{
hatch_object.HatchGeometry.PatternIndex = pattern_index;
hatch_object.CommitChanges();
}
}
doc.Views.Redraw();
return Result.Success;
}
示例4: SetActiveView
public static Result SetActiveView(RhinoDoc doc)
{
// view and view names
var active_view_name = doc.Views.ActiveView.ActiveViewport.Name;
var non_active_views =
doc.Views
.Where(v => v.ActiveViewport.Name != active_view_name)
.ToDictionary(v => v.ActiveViewport.Name, v => v);
// get name of view to set active
var gs = new GetString();
gs.SetCommandPrompt("Name of view to set active");
gs.AcceptNothing(true);
gs.SetDefaultString(active_view_name);
foreach (var view_name in non_active_views.Keys)
gs.AddOption(view_name);
var result = gs.Get();
if (gs.CommandResult() != Result.Success)
return gs.CommandResult();
var selected_view_name =
result == GetResult.Option ? gs.Option().EnglishName : gs.StringResult();
if (selected_view_name != active_view_name)
if (non_active_views.ContainsKey(selected_view_name))
doc.Views.ActiveView = non_active_views[selected_view_name];
else
RhinoApp.WriteLine("\"{0}\" is not a view name", selected_view_name);
return Rhino.Commands.Result.Success;
}
示例5: RunCommand
protected override Result RunCommand(RhinoDoc doc, RunMode mode)
{
Loop loop = new Loop();
loop.Run(doc);
return Result.Success;
}
示例6: DrawMesh
public static Result DrawMesh(RhinoDoc doc)
{
var gs = new GetObject();
gs.SetCommandPrompt("select sphere");
gs.GeometryFilter = ObjectType.Surface;
gs.DisablePreSelect();
gs.SubObjectSelect = false;
gs.Get();
if (gs.CommandResult() != Result.Success)
return gs.CommandResult();
Sphere sphere;
gs.Object(0).Surface().TryGetSphere(out sphere);
if (sphere.IsValid)
{
var mesh = Mesh.CreateFromSphere(sphere, 10, 10);
if (mesh == null)
return Result.Failure;
var conduit = new DrawBlueMeshConduit(mesh) {Enabled = true};
doc.Views.Redraw();
var in_str = "";
Rhino.Input.RhinoGet.GetString("press <Enter> to continue", true, ref in_str);
conduit.Enabled = false;
doc.Views.Redraw();
return Result.Success;
}
else
return Result.Failure;
}
示例7: ViewportResolution
public static Result ViewportResolution(RhinoDoc doc)
{
var active_viewport = doc.Views.ActiveView.ActiveViewport;
RhinoApp.WriteLine("Name = {0}: Width = {1}, Height = {2}",
active_viewport.Name, active_viewport.Size.Width, active_viewport.Size.Height);
return Result.Success;
}
示例8: BakeGeometry
public void BakeGeometry(RhinoDoc doc, ObjectAttributes att, List<Guid> obj_ids)
{
List<Text3d>.Enumerator tag;
if (att == null)
{
att = doc.CreateDefaultAttributes();
}
try
{
tag = this.m_tags.GetEnumerator();
while (tag.MoveNext())
{
Text3d tag3d = tag.Current;
Guid id = doc.Objects.AddText(tag3d, att);
if (!(id == Guid.Empty))
{
obj_ids.Add(id);
}
}
}
finally
{
tag.Dispose();
}
}
示例9: SelectObjectsInObjectGroups
public static Result SelectObjectsInObjectGroups(RhinoDoc doc)
{
ObjRef obj_ref;
var rs = RhinoGet.GetOneObject(
"Select object", false, ObjectType.AnyObject, out obj_ref);
if (rs != Result.Success)
return rs;
var rhino_object = obj_ref.Object();
if (rhino_object == null)
return Result.Failure;
var rhino_object_groups = rhino_object.Attributes.GetGroupList().DefaultIfEmpty(-1);
var selectable_objects= from obj in doc.Objects.GetObjectList(ObjectType.AnyObject)
where obj.IsSelectable(true, false, false, false)
select obj;
foreach (var selectable_object in selectable_objects)
{
foreach (var group in selectable_object.Attributes.GetGroupList())
{
if (rhino_object_groups.Contains(group))
{
selectable_object.Select(true);
continue;
}
}
}
doc.Views.Redraw();
return Result.Success;
}
示例10: CreateMeshFromBrep
public static Result CreateMeshFromBrep(RhinoDoc doc)
{
ObjRef obj_ref;
var rc = RhinoGet.GetOneObject("Select surface or polysurface to mesh", true, ObjectType.Surface | ObjectType.PolysrfFilter, out obj_ref);
if (rc != Result.Success)
return rc;
var brep = obj_ref.Brep();
if (null == brep)
return Result.Failure;
// you could choose anyone of these for example
var jagged_and_faster = MeshingParameters.Coarse;
var smooth_and_slower = MeshingParameters.Smooth;
var default_mesh_params = MeshingParameters.Default;
var minimal = MeshingParameters.Minimal;
var meshes = Mesh.CreateFromBrep(brep, smooth_and_slower);
if (meshes == null || meshes.Length == 0)
return Result.Failure;
var brep_mesh = new Mesh();
foreach (var mesh in meshes)
brep_mesh.Append(mesh);
doc.Objects.AddMesh(brep_mesh);
doc.Views.Redraw();
return Result.Success;
}
示例11: RunCommand
protected override Result RunCommand(RhinoDoc doc, RunMode mode)
{
RcCore.It.EngineSettings.SaveDebugImages = !RcCore.It.EngineSettings.SaveDebugImages;
var saving = RcCore.It.EngineSettings.SaveDebugImages ? "Saving" : "Not saving";
RhinoApp.WriteLine($"{saving} debug images");
return Result.Success;
}
示例12: RunCommand
protected override Result RunCommand(RhinoDoc doc, RunMode mode)
{
Plugin.InitialiseCSycles();
if (doc.Views.ActiveView.ActiveViewport.DisplayMode.Id == Guid.Parse("69E0C7A5-1C6A-46C8-B98B-8779686CD181"))
{
var rvp = doc.Views.ActiveView.RealtimeDisplayMode as RenderedViewport;
if (rvp != null)
{
var getNumber = new GetInteger();
getNumber.SetLowerLimit(1, true);
getNumber.SetDefaultInteger(rvp.HudMaximumPasses()+100);
getNumber.SetCommandPrompt("Set new sample count");
var getRc = getNumber.Get();
if (getNumber.CommandResult() != Result.Success) return getNumber.CommandResult();
if (getRc == GetResult.Number)
{
var nr = getNumber.Number();
RhinoApp.WriteLine($"User changes samples to {nr}");
rvp.ChangeSamples(nr);
return Result.Success;
}
}
}
RhinoApp.WriteLine("Active view isn't rendering with Cycles");
return Result.Nothing;
}
示例13: Leader
public static Result Leader(RhinoDoc doc)
{
var points = new Point3d[]
{
new Point3d(1, 1, 0),
new Point3d(5, 1, 0),
new Point3d(5, 5, 0),
new Point3d(9, 5, 0)
};
var xy_plane = Plane.WorldXY;
var points2d = new List<Point2d>();
foreach (var point3d in points)
{
double x, y;
if (xy_plane.ClosestParameter(point3d, out x, out y))
{
var point2d = new Point2d(x, y);
if (points2d.Count < 1 || point2d.DistanceTo(points2d.Last<Point2d>()) > RhinoMath.SqrtEpsilon)
points2d.Add(point2d);
}
}
doc.Objects.AddLeader(xy_plane, points2d);
doc.Views.Redraw();
return Result.Success;
}
示例14: RunCommand
protected override Result RunCommand(RhinoDoc doc, RunMode mode)
{
// Get the name of the instance definition to rename
string instance_definition_name = "";
var rc = RhinoGet.GetString("Name of block to delete", true, ref instance_definition_name);
if (rc != Result.Success)
return rc;
if (string.IsNullOrWhiteSpace(instance_definition_name))
return Result.Nothing;
// Verify instance definition exists
var instance_definition = doc.InstanceDefinitions.Find(instance_definition_name, true);
if (instance_definition == null) {
RhinoApp.WriteLine("Block \"{0}\" not found.", instance_definition_name);
return Result.Nothing;
}
// Verify instance definition can be deleted
if (instance_definition.IsReference) {
RhinoApp.WriteLine("Unable to delete block \"{0}\".", instance_definition_name);
return Result.Nothing;
}
// delete block and all references
if (!doc.InstanceDefinitions.Delete(instance_definition.Index, true, true)) {
RhinoApp.WriteLine("Could not delete {0} block", instance_definition.Name);
return Result.Failure;
}
return Result.Success;
}
示例15: RunCommand
protected override Result RunCommand(RhinoDoc doc, RunMode mode)
{
var points = new List<Point3d>
{
new Point3d(0, 0, 0),
new Point3d(0, 0, 1),
new Point3d(0, 1, 0),
new Point3d(0, 1, 1),
new Point3d(1, 0, 0),
new Point3d(1, 0, 1),
new Point3d(1, 1, 0),
new Point3d(1, 1, 1)
};
RhinoApp.WriteLine("Before sort ...");
foreach (var point in points)
RhinoApp.WriteLine("point: {0}", point);
var sorted_points = Point3d.SortAndCullPointList(points, doc.ModelAbsoluteTolerance);
RhinoApp.WriteLine("After sort ...");
foreach (var point in sorted_points)
RhinoApp.WriteLine("point: {0}", point);
doc.Objects.AddPoints(sorted_points);
doc.Views.Redraw();
return Result.Success;
}