一半君的总结纸

听话只听一半君

#50 如何用MEL改变网格设置 (Grid display settings)?

显然应该要用这个 MEL command :

grid

你可能会觉得 ‘-size’ flag 是用来控制 Grid Spacing 的, 但实际上他对应的是选项面板里的 “Extent” . 而且 “Extent” 只影响非正交视图.

在你用这个命令设置 grid display settings 过后,你会发现 Grid Options 面板里的参数并没有更新, 就算你把这个面板关掉再打开还是一样. 这是因为 options panel 里的值是从 optionVars 里取来的,而不是从实际的 grid settings 里得到的.

因为 ‘performGridOptions.mel’ script 的写法导致了,没有什么简单的办法能用来让这两个地方的数值同步. 你只能在改动过grid settings的值之后,自己去设置相应的 optionVar ,然后运行 gridSetup() function 后面加上某个 UI control 的名字. 因为 gridSetup() 不检查他将要修改的 UI controls 是否存在, 你应该自己事先检查:

Grid Spacing (a.k.a. Grid)

float $gridSpacing = 30.48;
grid -spacing $gridSpacing;
optionVar -fv gridSpacing $gridSpacing;
if ( `floatFieldGrp -q -exists gridSpacingField` )
      gridSetup( "OptionBoxWindow", 0 );

Grid Divisions (a.k.a. Subdivisions)

float $gridDivisions = 2;
grid -size $gridDivisions;
optionVar -fv gridDivisions $gridDivisions;
if ( `intSliderGrp -q -exists gridDivisionsField` )
  gridSetup( "OptionBoxWindow", 0 );

Grid Size (a.k.a. Extent)

float $gridSize = 16;
grid -size $gridSize;
optionVar -fv gridSize $gridSize;
if ( `floatFieldGrp -q -exists gridSizeField` )
  gridSetup( "OptionBoxWindow", 0 );

Grid Style

int $gridStyle = 2;  // "Grid" style
grid -style $gridStyle;
optionVar -fv gridStyle $gridStyle;
if ( `radioButtonGrp -q -exists gridStyleButtonGrp` )
  gridSetup( "OptionBoxWindow", 0 );

Tuesday, December 05, 2000

Advertisements

发表评论

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / 更改 )

Twitter picture

You are commenting using your Twitter account. Log Out / 更改 )

Facebook photo

You are commenting using your Facebook account. Log Out / 更改 )

Google+ photo

You are commenting using your Google+ account. Log Out / 更改 )

Connecting to %s

%d 博主赞过: