Site Tools


Differences

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

Link to this comparison view

developer:rhinocommonsamples:addlineardimension [2015/09/14] (current)
Line 1: Line 1:
 +===== Sample: Add Linear Dimension =====
 +
 +===== C# =====
 +<code c#>
 +public static Rhino.Commands.Result AddLinearDimension(Rhino.RhinoDoc doc)
 +{
 +  Rhino.Geometry.LinearDimension dimension;
 +  Rhino.Commands.Result rc = Rhino.Input.RhinoGet.GetLinearDimension(out dimension);
 +  if (rc == Rhino.Commands.Result.Success && dimension != null)
 +  {
 +    if (doc.Objects.AddLinearDimension(dimension) == Guid.Empty)
 +      rc = Rhino.Commands.Result.Failure;​
 +    else
 +      doc.Views.Redraw();​
 +  }
 +  return rc;
 +}
 +</​code>​
 +===== VB.NET =====
 +<code vb>
 +Public Shared Function AddLinearDimension(ByVal doc As Rhino.RhinoDoc) As Rhino.Commands.Result
 +  Dim dimension As Rhino.Geometry.LinearDimension = Nothing
 +  Dim rc As Rhino.Commands.Result = Rhino.Input.RhinoGet.GetLinearDimension(dimension)
 +  If rc = Rhino.Commands.Result.Success AndAlso dimension IsNot Nothing Then
 +    If doc.Objects.AddLinearDimension(dimension) = Guid.Empty Then
 +      rc = Rhino.Commands.Result.Failure
 +    Else
 +      doc.Views.Redraw()
 +    End If
 +  End If
 +  Return rc
 +End Function
 +</​code>​
 +===== Python =====
 +<code python>
 +import Rhino
 +import scriptcontext
 +import System.Guid
 +
 +def AddLinearDimension():​
 +    rc, dimension = Rhino.Input.RhinoGet.GetLinearDimension()
 +    if rc==Rhino.Commands.Result.Success:​
 +        if scriptcontext.doc.Objects.AddLinearDimension(dimension)==System.Guid.Empty:​
 +            rc = Rhino.Commands.Result.Failure
 +        else:
 +            scriptcontext.doc.Views.Redraw()
 +    return rc
 +
 +
 +if __name__=="​__main__":​
 +    AddLinearDimension()
 +</​code>​
 +
 +{{tag>​Developer rhinocommon}}
  
developer/rhinocommonsamples/addlineardimension.txt ยท Last modified: 2015/09/14 (external edit)