Add multiple actors in one Simulink Simulation 3D Actor Block
10 次查看(过去 30 天)
显示 更早的评论
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:
0 个评论
采纳的回答
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
更多回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!