Dear John,
Thank you for your patience.
I heard back from the development team.
Here is there explanation:
Answer A:
May you verify if the following testing code will work for the case? It’s from our existing test code. It looks like the customer missed calling the methods grid2d.GridType, grid2d.BaseGrid.ULayoutMode and grid2d.BaseGrid.UpdateParameters.
grid2d = new LayoutGrid2d();
grid2d.SetToStandard(db);
grid2d.SetDatabaseDefaults(db);
grid2d.GridType = Autodesk.Aec.DatabaseServices.GridType.UVRectangular;
grid2d.BaseGrid.UAxisLength = 40;
grid2d.BaseGrid.ULayoutMode = UVLayoutModeType.SpaceEvenly;
grid2d.BaseGrid.UStartOffset = 0;
grid2d.BaseGrid.AppendGridRow(0);
grid2d.BaseGrid.AppendGridRow(1);
grid2d.BaseGrid.AppendGridRow(2);
grid2d.BaseGrid.AppendGridRow(3);
grid2d.BaseGrid.UEndOffset = 0;
grid2d.BaseGrid.VAxisLength = 30;
grid2d.BaseGrid.VLayoutMode = UVLayoutModeType.SpaceEvenly;
grid2d.BaseGrid.VStartOffset = 0;
grid2d.BaseGrid.VEndOffset = 0;
grid2d.BaseGrid.AppendGridColumn(0);
grid2d.BaseGrid.AppendGridColumn(1);
grid2d.BaseGrid.AppendGridColumn(2);
grid2d.BaseGrid.UpdateParameters();
Answer B:
The answer depends on what the developer wants to do. The original code
log2d.BaseGrid.ULayoutMode = 0
log2d.BaseGrid.UAxisLength = 42.0 'This wont stay set!
log2d.BaseGrid.USpacing = 42.0 'Stays set
log2d.BaseGrid.VLayoutMode = 0
log2d.BaseGrid.VAxisLength = 0.5 ' This wont stay set!
log2d.BaseGrid.VSpacing = 0.5 'Stays set
seems to be trying to create a grid with one column one row, in the size of 42.0 * 0.5.
As the grid already has one column and one row by default at creation, the easiest way is adjusting the size of existing column and row. Here's the code:
log2d.BaseGrid.ULayoutMode = 0
log2d.BaseGrid.MoveGridColumn(log2d.BaseGrid.UAxisLength, 42.0)
log2d.BaseGrid.VLayoutMode = 0
log2d.BaseGrid.MoveGridRow(log2d.BaseGrid.VAxisLength, 0.5)
You could still set U/VAxisLength values, but there won't be any visual differences.
The problem of the original code is that it's using manual layout mode, ULayoutMode = UVLayoutModeType.Manual (or 0 as in the code). In this mode, the underlying logic always increases the axis length to match the maximum column/row position. The default column size is 350 at creation, so the specified UAxisLength 42.0 will always get rejected without resizing the column.
Probably some samples could help more...
1. Repeat mode: specify overall size, and spacing.
The following code creates a grid with 5 columns and 2 rows.
log2d.BaseGrid.ULayoutMode = UVLayoutModeType.Repeat;
log2d.BaseGrid.UAxisLength = 100;
log2d.BaseGrid.USpacing = 20;
log2d.BaseGrid.VLayoutMode = UVLayoutModeType.Repeat;
log2d.BaseGrid.VAxisLength = 50;
log2d.BaseGrid.VSpacing = 25;
2. Space evenly mode: specify overall size, and then specify the number of columns/rows via appending.
The following code creates a grid with 6 columns and 2 rows. Please note that, the specified column/row position is not important, the actual position will be calculated automatically from the overall size and the number of columns/rows.
The code looks a bit weird. Anyway, this is how it works for now.
log2d.BaseGrid.ULayoutMode = UVLayoutModeType.SpaceEvenly;
log2d.BaseGrid.UAxisLength = 100;
for (int i = 1; i <= 5; i++)
log2d.BaseGrid.AppendGridColumn(i);
log2d.BaseGrid.VLayoutMode = UVLayoutModeType.SpaceEvenly;
log2d.BaseGrid.VAxisLength = 50;
log2d.BaseGrid.AppendGridRow(log2d.BaseGrid.VAxisLength / 2);
3. Manual mode: specify each column and row manually.
The following code creates a more complex grid.
log2d.BaseGrid.ULayoutMode = UVLayoutModeType.Manual;
log2d.BaseGrid.MoveGridColumn(log2d.BaseGrid.UAxisLength, 10);
log2d.BaseGrid.AppendGridColumn(20);
log2d.BaseGrid.AppendGridColumn(50);
log2d.BaseGrid.AppendGridColumn(98);
log2d.BaseGrid.AppendGridColumn(100);
log2d.BaseGrid.VLayoutMode = UVLayoutModeType.Manual;
log2d.BaseGrid.MoveGridRow(log2d.BaseGrid.VAxisLength, 30);
log2d.BaseGrid.AppendGridRow(50);

I hope this helps.
Best regards,
Jeremy