Add multiple actors in one Simulink Simulation 3D Actor Block

10 ビュー (過去 30 日間)
Alyssa
Alyssa 2024 年 9 月 3 日
コメント済み: Alyssa 2024 年 9 月 4 日
I am trying to mimic the example https://www.mathworks.com/help/sl3d/automate-virtual-assembly-line.html, with a much simpler starting case. However, I am finding that the second object created in the block does not show in the 3D simulation viewer. Is there some command I need to run to force it to render? It is not Hidden, according to its properties.
Here is my "loadActors.m" file:
function loadActors(Actor, World)%Load actors
%Actor.load('Actor1_scene.mat')
Actor1 = Actor;
createShape(Actor1, 'box', [0.2, 0.2, 1]);
Actor2 = sim3d.Actor('ActorName','Actor2');
%Actor2.load('Actor2_scene.mat');
createShape(Actor2, 'cylinder', [0.5, 0.5, 0.75]);
add(World, Actor2);
It is called as follows:
And the output is:

採用された回答

Nishan Nekoo
Nishan Nekoo 2024 年 9 月 3 日
Hi Alyssa,
When using the Simulation 3D Actor block, you are effectively creating an Actor in the World.
Any element that you add via a .m or .mat script must be a child of this Actor. Within one Simulation 3D Actor block, you cannot create multiple Actors that are children of the World when using this .m or .mat import workflow.
Using the following modified function would work:
function loadActors(Actor, World)%Load actors
Actor1 = sim3d.Actor();
createShape(Actor1, 'box', [0.2, 0.2, 1]);
World.add(Actor1, Actor)
Actor2 = sim3d.Actor('ActorName','Actor2');
createShape(Actor2, 'cylinder', [0.5, 0.5, 0.75]);
World.add(Actor2, Actor);
Alternatively, you can still make Actor 1 be the same as the Actor of the block, but Actor2 must be a child as follows:
function loadActors(Actor, World)%Load actors
Actor1 = Actor;
createShape(Actor1, 'box', [0.2, 0.2, 1]);
Actor2 = sim3d.Actor('ActorName','Actor2');
createShape(Actor2, 'cylinder', [0.5, 0.5, 0.75]);
World.add(Actor2, Actor1);
I have created a ticket internally to make this limitation clearer to the user instead of simply not creating the second actor in the world.
I hope that helps and I apologize for any inconvenience you faced!
Nishan
  1 件のコメント
Alyssa
Alyssa 2024 年 9 月 4 日
Thank you! This makes sense, and the flag will be useful!

サインインしてコメントする。

その他の回答 (0 件)

製品


リリース

R2024a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by