As it happens, I'm working on an update to my utilities package to include a tool to generate rack and pinion gears.
The utilities already has a tool to generate external spur/helical gears so the update just needs to generate the appropriate rack.
As usual, a template file can be of great benefit especially when there are features needed that are not part of the standard API.
In this case, it is the linear pattern - but it seemed appropriate to put the whole model into a part. The utilities add-on will use this part and set the appropriate parameters before a call to regenerate the part.
This is just some test code - but you'll get the idea..
C#:
private void BuildRack(object sender, EventArgs e)
{
var fileData = GetRackDetails();
var filePath = GetAlibreFilePath(fileData.SaveFile, fileData.Template);
var session = InitAlibreFile(filePath);
session.Parameters.OpenParameterTransaction();
session.Parameters.Item("Alpha").Value = Radians(20);
session.Parameters.Item("Beta").Value = Radians(0);
session.Parameters.Item("Module").Value = 2.5 * 0.1;
session.Parameters.Item("RackTeeth").Value = 25;
session.Parameters.Item("Width").Value = 10 * 0.1;
session.Parameters.CloseParameterTransaction();
((IADPartSession) session).RegenerateAll();
}
Template file is attached.
David