Site Tools


Differences

This shows you the differences between two versions of the page.

Link to this comparison view

developer:rhinocommonsamples:dotnetmovepointobjectsnonuniform [2015/09/14] (current)
Line 1: Line 1:
 +===== Sample: Moving Point Objects (non-uniform) =====
 +a uniform move sample is also available [[developer:​rhinocommonsamples:​dotnetmovepointobjects|here]]
 +===== C# =====
 +<code c#>
 +public class MovePointsNonUniformCommand : Rhino.Commands.Command
 +{
 +  public override string EnglishName
 +  {
 +    get { return "​csMovePointsNonUniform";​ }
 +  }
 +
 +  protected override Result RunCommand(RhinoDoc doc, RunMode mode)
 +  {
 +    ObjRef[] obj_refs;
 +    var rc = RhinoGet.GetMultipleObjects(
 +      "​Select points to move", false, ObjectType.Point,​ out obj_refs);
 +    if (rc != Result.Success || obj_refs == null)
 +      return rc;
 +
 +    foreach (var obj_ref in obj_refs)
 +    {
 +      var point3d = obj_ref.Point().Location;​
 +      // modify the point coordinates in some way ...
 +      point3d.X++;​
 +      point3d.Y++;​
 +      point3d.Z++;​
 +
 +      doc.Objects.Replace(obj_ref,​ point3d);
 +    }
 +
 +    doc.Views.Redraw();​
 +    return Result.Success;​
 +  }
 +}
 +</​code>​
 +===== VB.NET =====
 +<code vb>
 +Public Class MovePointsNonUniformCommand
 +  Inherits Rhino.Commands.Command
 +  Public Overrides ReadOnly Property EnglishName() As String
 +    Get
 +      Return "​vbMovePointsNonUniform"​
 +    End Get
 +  End Property
 +
 +  Protected Overrides Function RunCommand(doc As RhinoDoc, mode As RunMode) As Result
 +    Dim obj_refs As ObjRef()
 +    Dim rc = RhinoGet.GetMultipleObjects(
 +      "​Select points to move", False, ObjectType.Point,​ obj_refs)
 +    If rc <> Result.Success OrElse obj_refs Is Nothing Then
 +      Return rc
 +    End If
 +
 +    For Each obj_ref As ObjRef In obj_refs
 +      Dim point3d = obj_ref.Point().Location
 +      ' modify the point coordinates in some way ...
 +      point3d.X += 1
 +      point3d.Y += 1
 +      point3d.Z += 1
 +
 +      doc.Objects.Replace(obj_ref,​ point3d)
 +    Next
 +
 +    doc.Views.Redraw()
 +    Return Result.Success
 +  End Function
 +End Class
 +d Namespace
 +</​code>​
 +===== Python =====
 +<code python>
 +from Rhino import *
 +from Rhino.DocObjects import *
 +from Rhino.Commands import *
 +from Rhino.Input import *
 +from scriptcontext import doc
 +
 +def RunCommand():​
 +  rc, obj_refs = RhinoGet.GetMultipleObjects(
 +    "​Select points to move", False, ObjectType.Point)
 +  if rc <> Result.Success or obj_refs == None:
 +    return rc
 +
 +  for obj_ref in obj_refs:
 +    point3d = obj_ref.Point().Location
 +    point3d.X += 1
 +    point3d.Y += 1
 +    point3d.Z += 1
 +    doc.Objects.Replace(obj_ref,​ point3d)
 +
 +  doc.Views.Redraw()
 +  return Result.Success
 +  ​
 +if __name__ == "​__main__":​
 +  RunCommand()
 +</​code>​
 +
 +{{tag>​Developer rhinocommon}}
  
developer/rhinocommonsamples/dotnetmovepointobjectsnonuniform.txt ยท Last modified: 2015/09/14 (external edit)