Robot API - Parametric Section

Robot API - Parametric Section

milczarekuba
Participant Participant
1,443 Views
2 Replies
Message 1 of 3

Robot API - Parametric Section

milczarekuba
Participant
Participant

Hi

How can I make parametric section like on the image, but through Robot API. 

I am able to only make sections based geometrical characteristics.

 

milczarekuba_0-1591619855008.png

@Rafal.Gaweda 

Is it possible to have some help from you? If you could post sample code in python it would be great.

 

this is what i got

 

app = RobotApplicationClass()

labels = app.Project.Structure.Labels    
i=0
outs = labels.Create(IRobotLabelType.I_LT_BAR_SECTION, SectionName[i])

outs.Data.Type = I_BST_NS_RECT  
outs.Data.ShapeType = I_BSST_RECT_FILLED
outs.Data.MaterialName = "S355"
outs.Data.SetValue(IRobotBarSectionNonstdDataValue.I_BSNDV_RECT_B,Properties[i][4])
outs.Data.SetValue(IRobotBarSectionNonstdDataValue.I_BSNDV_RECT_H,Properties[i][5])

labels.Store(outs)

 

I cant find in documantation the number witch corresponds to this type and shapetype, I can not do it in python like this because variables are not defined.

0 Likes
Accepted solutions (2)
1,444 Views
2 Replies
Replies (2)
Message 2 of 3

Rafal.Gaweda
Autodesk Support
Autodesk Support
Accepted solution
0 Likes
Message 3 of 3

JacquesGaudin
Advocate
Advocate
Accepted solution

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)