usingSystem.Collections.Generic;usingRhino.Display;partialclassExamples{// The following example code demonstrates how to modify advanced display settings using// the Rhino SDK. In this example, a display mode's mesh wireframe thickness (in pixels)// will be modified.publicstaticRhino.Commands.ResultAdvancedDisplay(Rhino.RhinoDoc doc){// Use the display attributes manager to build a list of display modes.// Note, these are copies of the originals...DisplayModeDescription[] display_modes =DisplayModeDescription.GetDisplayModes();if( display_modes==null|| display_modes.Length<1)returnRhino.Commands.Result.Failure;// Construct an options picker so the user can pick which// display mode they want modifiedRhino.Input.Custom.GetOption go =newRhino.Input.Custom.GetOption();
go.SetCommandPrompt("Display mode to modify mesh thickness");List<int> opt_list =newList<int>();for(int i=0; i<display_modes.Length; i++){string english_name = display_modes[i].EnglishName;
english_name = english_name.Replace("_","");
english_name = english_name.Replace(" ","");
english_name = english_name.Replace("-","");
english_name = english_name.Replace(",","");
english_name = english_name.Replace(".","");int index = go.AddOption(english_name);
opt_list.Add(index);}// Get the command option
go.Get();if( go.CommandResult()!=Rhino.Commands.Result.Success)return go.CommandResult();int selected_index = go.Option().Index;DisplayModeDescription selected_description =null;for(int i=0; i<opt_list.Count; i++){if( opt_list[i]==selected_index ){
selected_description = display_modes[i];break;}}// Validate...if( selected_description==null)returnRhino.Commands.Result.Failure;// Modify the desired display mode. In this case, we// will just set the mesh wireframe thickness to zero.
selected_description.DisplayAttributes.MeshSpecificAttributes.MeshWireThickness=0;// Use the display attributes manager to update the display mode.DisplayModeDescription.UpdateDisplayMode(selected_description);// Force the document to regenerate.
doc.Views.Redraw();returnRhino.Commands.Result.Success;}}
importRhinoimport scriptcontext
# The following example demonstrates how to modify advanced display settings# using RhinoCommon. In this example, a display mode's mesh wireframe thickness# (in pixels) will be modified.defAdvancedDisplay():# Use the display attributes manager to build a list of display modes.# Note, these are copies of the originals...
display_modes =Rhino.Display.DisplayModeDescription.GetDisplayModes()ifnot display_modes:returnRhino.Commands.Result.Failure# Construct an options picker so the user can pick which# display mode they want modified
go =Rhino.Input.Custom.GetOption()
go.SetCommandPrompt("Display mode to modify mesh thickness")
opt_list =[]for i, mode inenumerate(display_modes):
english_name = mode.EnglishName
english_name = english_name.translate(None,"_ -,.")
opt_list.append( go.AddOption(english_name))# Get the command option
go.Get()if go.CommandResult()!=Rhino.Commands.Result.Success:return go.CommandResult();
selected_index = go.Option().Index
selected_description =Nonefor i,option inenumerate(opt_list):if option==selected_index:
selected_description = display_modes[i]break# Validate...ifnot selected_description:returnRhino.Commands.Result.Failure# Modify the desired display mode. In this case, we# will just set the mesh wireframe thickness to zero.
selected_description.DisplayAttributes.MeshSpecificAttributes.MeshWireThickness=0# Use the display attributes manager to update the display mode.Rhino.Display.DisplayModeDescription.UpdateDisplayMode(selected_description)# Force the document to regenerate.
scriptcontext.doc.Views.Redraw()returnRhino.Commands.Result.Successif __name__=="__main__":AdvancedDisplay()
ImportsSystem.Collections.GenericImportsRhino.DisplayPartialClassExamples' The following example demonstrates how to modify advanced display settings using' RhinoCommon. In this example, a display mode's mesh wireframe thickness (in pixels)' will be modified.PublicSharedFunctionAdvancedDisplay(ByVal doc AsRhino.RhinoDoc)AsRhino.Commands.Result' Use the display attributes manager to build a list of display modes.' Note, these are copies of the originals...Dim display_modes AsDisplayModeDescription()=DisplayModeDescription.GetDisplayModes()If display_modes IsNothingOrElse display_modes.Length<1ThenReturnRhino.Commands.Result.FailureEndIf' Construct an options picker so the user can pick which' display mode they want modifiedDim go AsNewRhino.Input.Custom.GetOption()
go.SetCommandPrompt("Display mode to modify mesh thickness")Dim opt_list AsNewList(OfInteger)()For i AsInteger=0To display_modes.Length-1Dim english_name AsString=display_modes(i).EnglishName
english_name = english_name.Replace("_","")
english_name = english_name.Replace(" ","")
english_name = english_name.Replace("-","")
english_name = english_name.Replace(",","")
english_name = english_name.Replace(".","")Dim index AsInteger= go.AddOption(english_name)
opt_list.Add(index)Next' Get the command option
go.[Get]()If go.CommandResult()<>Rhino.Commands.Result.SuccessThenReturn go.CommandResult()EndIfDim selected_index AsInteger= go.[Option]().IndexDim selected_description AsDisplayModeDescription=NothingFor i AsInteger=0To opt_list.Count-1Ifopt_list(i)= selected_index Then
selected_description =display_modes(i)ExitForEndIfNext' Validate...If selected_description IsNothingThenReturnRhino.Commands.Result.FailureEndIf' Modify the desired display mode. In this case, we' will just set the mesh wireframe thickness to zero.
selected_description.DisplayAttributes.MeshSpecificAttributes.MeshWireThickness=0' Use the display attributes manager to update the display mode.DisplayModeDescription.UpdateDisplayMode(selected_description)' Force the document to regenerate.
doc.Views.Redraw()ReturnRhino.Commands.Result.SuccessEndFunctionEndClass