Simcenter Prescan How to use Data model API in Prescan

Prescan Teamcenter Share Simcenter Prescan Marketing


Data model API is a function that allows user to create the content of experiment via a MATLAB


Step1: Create an empty experiment using GUI, build the experiment and save it.

Step2: Open Matlab via Prescan process manager and navigate to your experiment created from GUI

Step 3: In MATLAB create a new script and save it in the experiment folder

Step 4: Inside the script we can start building the model. User can access DMAPI and module using command doc prescan.api

Example script for reference

exp = prescan.api.experiment.Experiment();
%% Create a road
road_1 = prescan.api.roads.createRoad(exp);
%% Add sections to the road
sectionLength = 250; % [m]
sectionLength = 50;
startCurvature = 0.025;
endCurvature = 0.1;
road_1.addSpiralSection(sectionLength, startCurvature, endCurvature);
%% Once the sections have been added, add lanes to the road
lane1 = road_1.addLeftLane(3.2);
marker = lane1.getLaneMarker('Outer');
lane2 = road_1.addLeftLane(3.2);
marker = lane2.getLaneMarker('Outer');
lane3 = road_1.addRightLane(3.2);
marker = lane3.getLaneMarker('Outer');
lane4 = road_1.addRightLane(3.2);
marker = lane4.getLaneMarker('Outer');
centerOfLane1 = lane3.poseAtDistance(0.0).position.y;
centerOfLane2 = lane4.poseAtDistance(0.0).position.y;
edgeOfRoadLeft = lane2.poseAtDistance(0.0, 'Outer', 10.0).position.y;
edgeOfRoadRight = lane4.poseAtDistance(0.0, 'Outer', 10.0).position.y;
%% Add objects to the road
vehicleAudi = exp.createObject(exp.objectTypes.Audi_A8_Sedan); = 'Ego';
% Trees
for i = 0:35
    r = -3 + (3+3).*rand(3,1); % Make it random
    xtree = 6 * i + r(1);
    ytree1 = edgeOfRoadLeft + r(2);
    ytree2 = edgeOfRoadRight + r(3);
    tree = exp.createObject(exp.objectTypes.Dogwood20y);
    tree.pose.position.x = xtree;
    tree.pose.position.y = ytree1;
    tree = exp.createObject(exp.objectTypes.Dogwood20y);
    tree.pose.position.x = xtree;
    tree.pose.position.y = ytree2;
%% Position the vehicles correctly
vehicleAudi.pose.position.y = centerOfLane2;
%% Add a trajectory to the ego vehicle
z = [0, 0];
y = [vehicleAudi.pose.position.y, vehicleAudi.pose.position.y];
x = [vehicleAudi.pose.position.x, 200];
pathAudi = prescan.api.trajectory.createFittedPath(exp, x, y, z);
speedProf = prescan.api.trajectory.createSpeedProfileOfConstantSpeed(exp, 5);
trajectoryAudi = prescan.api.trajectory.createTrajectory(vehicleAudi, pathAudi, speedProf);
%% Add a camera to the ego vehicle
cameraAudi =;
%% Save the experiment to a file
%% Generate the CS
%% Run the experiment, 'Regenerate', 'off', 'StopTime', '5')

Step5: Once the required changes are done to the experiment, save the file and run the script.

Step 6: Load the PB file in the Prescan static viewer and see the experiment built using API.


KB Article ID# KB000054104_EN_US



Associated Components

Documentation Installer License Software