Site Tools


Differences

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

Link to this comparison view

developer:rhinocommonsamples:displayprecision [2015/09/14] (current)
Line 1: Line 1:
 +===== Sample: Changing Display Precision =====
 +
 +===== C# =====
 +<code c#>
 +public class DisplayPrecisionCommand : Command
 +{
 +  public override string EnglishName { get { return "​csDisplayPrecision";​ } }
 +
 +  protected override Result RunCommand(RhinoDoc doc, RunMode mode)
 +  {
 +    var gi = new GetInteger();​
 +    gi.SetCommandPrompt("​New display precision"​);​
 +    gi.SetDefaultInteger(doc.ModelDistanceDisplayPrecision);​
 +    gi.SetLowerLimit(0,​ false);
 +    gi.SetUpperLimit(7,​ false);
 +    gi.Get();
 +    if (gi.CommandResult() != Result.Success)
 +      return gi.CommandResult();​
 +    var distance_display_precision = gi.Number();​
 +
 +    if (distance_display_precision != doc.ModelDistanceDisplayPrecision)
 +      doc.ModelDistanceDisplayPrecision = distance_display_precision;​
 +
 +    return Result.Success;​
 +  }
 +}
 +</​code>​
 +===== VB.NET =====
 +<code vb>
 +Public Class DisplayPrecisionCommand
 +  Inherits Command
 +  Public Overrides ReadOnly Property EnglishName() As String
 +    Get
 +      Return "​vbDisplayPrecision"​
 +    End Get
 +  End Property
 +
 +  Protected Overrides Function RunCommand(doc As RhinoDoc, mode As RunMode) As Result
 +    Dim gi = New GetInteger()
 +    gi.SetCommandPrompt("​New display precision"​)
 +    gi.SetDefaultInteger(doc.ModelDistanceDisplayPrecision)
 +    gi.SetLowerLimit(0,​ False)
 +    gi.SetUpperLimit(7,​ False)
 +    gi.[Get]()
 +    If gi.CommandResult() <> Result.Success Then
 +      Return gi.CommandResult()
 +    End If
 +    Dim distance_display_precision = gi.Number()
 +
 +    If distance_display_precision <> doc.ModelDistanceDisplayPrecision Then
 +      doc.ModelDistanceDisplayPrecision = distance_display_precision
 +    End If
 +
 +    Return Result.Success
 +  End Function
 +End Class
 +d Namespace
 +</​code>​
 +===== Python =====
 +<code python>
 +from Rhino import *
 +from Rhino.Input.Custom import *
 +from Rhino.Commands import *
 +from scriptcontext import doc
 +import rhinoscriptsyntax as rs
 +
 +def RunCommand():​
 +  distance_display_precision = rs.GetInteger("​Display precision",​
 +    doc.ModelDistanceDisplayPrecision,​ 0, 7)
 +  if distance_display_precision == None: return Result.Nothing
 +
 +  if distance_display_precision <> doc.ModelDistanceDisplayPrecision:​
 +    doc.ModelDistanceDisplayPrecision = distance_display_precision
 +
 +  return Result.Success
 +
 +if __name__ ==  "​__main__":​
 +  RunCommand()
 +</​code>​
 +
 +{{tag>​Developer rhinocommon}}
  
developer/rhinocommonsamples/displayprecision.txt ยท Last modified: 2015/09/14 (external edit)