Skip to content

Add Optional 'Criteria' Parameter (Strength or Serviceability) to the 'add' Method in LoadCombinations Class #4

@Jeroen124

Description

@Jeroen124

Problem

The add method of the LoadCombinations class currently lacks an optional parameter for specifying the criteria. This results in a discrepancy between the output generated by the Python package and the expected input format for the API solver.

class LoadCombinations(ModelCollectionComponent):
    """Creates an instance of the SkyCiv LoadCombinations class.
    """

    def add(self, name: str, combination_factors: dict) -> int:
        """Adds a new load combination.

        Args:
            name (str): The name of the load combination.
            combination_factors (dict): Key value pairs for the factors to apply to the load groups.

        Returns:
            int: The ID of the created load combination.

        Example::

            lcs = LoadCombinations()

            factors = {
                "SW": 1,
                "windCase": 1,
                "liveLoad": 1.5
            }

            lcs.add("LC1", factors)
        """
        next_index = next_object_key(self)

        lc = LoadCombination(name, combination_factors)
        setattr(self, str(next_index), lc)

        return next_index

This gives te following input for the solver, resulting from the python package.

                    "load_combinations": {
                        "1": {
                            "name": "ULS1",
                            "Dead_load": 1.35,
                            "Product_load_1": 1.5750000000000002
                        },

Whilst the api solver expects something like this:

        "1": {
            "name": "LC1",
            "criteria": "strength"
        },

Possible solution:

class LoadCombinations(ModelCollectionComponent):
    """Creates an instance of the SkyCiv LoadCombinations class.
    """

    def add(self, name: str, combination_factors: dict, criteria: str = None) -> int:
        """Adds a new load combination.

        Args:
            name (str): The name of the load combination.
            combination_factors (dict): Key value pairs for the factors to apply to the load groups.
            criteria (str, optional): The criteria for the load combination (e.g., 'strength', 'serviceability'). Defaults to None.

        Returns:
            int: The ID of the created load combination.

        Example::

            lcs = LoadCombinations()

            factors = {
                "SW": 1,
                "windCase": 1,
                "liveLoad": 1.5
            }

            lcs.add("LC1", factors, criteria="strength")
        """
        next_index = next_object_key(self)

        lc = LoadCombination(name, combination_factors, criteria)
        setattr(self, str(next_index), lc)

        return next_index

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions