Skip to main content

Robot Structural Analysis

VIKTOR's Autodesk Robot integration requires a specific Autodesk Robot worker which can be downloaded here.

Analyzing an Autodesk Robot model in VIKTOR can be done using the RobotAnalysis class (worker required). No binding is provided by VIKTOR for this module, which means that the input file has to be generated manually:

from viktor.external.robot import RobotAnalysis

# Generate the input STR file.
input_file = ...

# Run the analysis and obtain the results.
analysis = RobotAnalysis(input_file)
analysis.execute(timeout=10)
results = analysis.get_results() # obtain the results in a dict
model_file = analysis.get_model_file() # obtain the model file (.rtd)

If return_results is set to True, a result dictionary can be retrieved:

If return_model=True, the model file will also become available:

Testing

New in v13.5.0

mock_RobotAnalysis decorator for easier testing of RobotAnalysis

RobotAnalysis.execute needs to be mocked within the context of (automated) testing.

The viktor.testing module provides the mock_RobotAnalysis decorator that facilitate mocking of workers:

import unittest

from viktor import File
from viktor.testing import mock_RobotAnalysis

from app.my_entity_type.controller import MyEntityTypeController

class TestMyEntityTypeController(unittest.TestCase):

@mock_RobotAnalysis(
get_model_file=File.from_path('test_file.rtd'),
get_results={'bar_forces': {...}, ...},
)
def test_robot_analysis(self):
MyEntityTypeController().robot_analysis()

For the decorator's input parameters the following holds:

  • If a Sequence type is provided, the next entry is returned for each corresponding method call. When a call is performed on a depleted iterable, an Exception is raised.
  • If a single object is provided, the object is returned each time the corresponding method is called (endlessly).
  • If None is provided (default), a default File/dict object (with empty content) is returned each time the corresponding method is called (endlessly).