The documentation about this is very poor. I figured out a few things so happy to share the following function. Hope this helps.
def create(self, name, h, w=0., t=0., shape='round', is_solid=True,
material='', unit=1e-3):
"""Creates a custom section.
The supported section shapes are round or rectangular, solid or
hollow.
:param str name: The section name
:param float h, w, t:
Height, width and thickness of the section (**w** and **t** may be
omitted if not relevant).Dimensions are in mm by default
(see **unit**).
:param str shape: `'rect'` or `'round'`
:param bool is_solid: Whether the section is solid
:param str material: The material for the section
:param float unit:
The unit of section dimension relative to model unit (e.g. mm
for a model in m: 1e-3)
"""
h, w, t, shape = unit * h, unit * w, unit * t, str(shape).lower()
shape_params = {
('round', True): {
'type': IRobotBarSectionType.I_BST_NS_TUBE,
'shapetype': IRobotBarSectionShapeType.I_BSST_USER_TUBE,
'params': {
IRobotBarSectionNonstdDataValue.I_BSNDV_TUBE_D: h,
IRobotBarSectionNonstdDataValue.I_BSNDV_TUBE_T: 0.
}
},
('rect', True): {
'type': IRobotBarSectionType.I_BST_NS_RECT,
'shapetype': IRobotBarSectionShapeType.I_BSST_USER_RECT,
'params': {
IRobotBarSectionNonstdDataValue.I_BSNDV_RECT_H: h,
IRobotBarSectionNonstdDataValue.I_BSNDV_RECT_B: w
}
},
('round', False): {
'type': IRobotBarSectionType.I_BST_NS_TUBE,
'shapetype': IRobotBarSectionShapeType.I_BSST_USER_TUBE,
'params': {
IRobotBarSectionNonstdDataValue.I_BSNDV_TUBE_D: h,
IRobotBarSectionNonstdDataValue.I_BSNDV_TUBE_T: t
}
},
('rect', False): {
'type': IRobotBarSectionType.I_BST_NS_RECT,
'shapetype': IRobotBarSectionShapeType.I_BSST_USER_RECT,
'params': {
IRobotBarSectionNonstdDataValue.I_BSNDV_RECT_H: h,
IRobotBarSectionNonstdDataValue.I_BSNDV_RECT_B: w,
IRobotBarSectionNonstdDataValue.I_BSNDV_RECT_T: t
}
}
}
label = self._ctype(self.Create(self._ltype, name))
data = self._dtype(label.Data)
data.Type = shape_params[(shape, is_solid)]['type']
data.ShapeType = shape_params[(shape, is_solid)]['shapetype']
if material:
data.MaterialName = material
nonstd_data = data.CreateNonstd(0.) # Argument 0. is the position
for arg, val in shape_params[(shape, is_solid)]['params'].items():
nonstd_data.SetValue(arg, val)
data.CalcNonstdGeometry()
self.StoreWithName(label, name)