question

Majid A avatar image
0 Likes"
Majid A asked Mischa Spelt edited

Set reset position of multiple selected objects using code

I can run the following code to set reset position of a selected object:

treenode selected_ = selectedobject(nodefromwindow(activedocumentview())); 
if (selected_) 
	setresetposition(selected_);

If I select multiple objects, only the last selected object is affected. How to set for all selected objects at once?

What is this menu option in the screenshot doing in the background?

FlexSim 17.1.2
flexscriptselected objectsset reset
untitled.jpg (140.1 KiB)
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

1 Answer

·
Matthew Gillespie avatar image
2 Likes"
Matthew Gillespie answered Matthew Gillespie commented

The selectedobject() command only gives you the object with a yellow box highlighting it. To find out all the objects in your model that have a red box around them you need to loop through all the objects in the model and ask each one if it has a red box.

This is the code that the right click option is using:

forobjecttreeunder(model()) {
	if (switch_selected(a, -1))
		setresetposition(a);	
}
· 2
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

Majid A avatar image Majid A commented ·

Where can I find a list of methods like 'forobjecttreeunder' which are not documented in the user manual?

0 Likes 0 ·
Matthew Gillespie avatar image Matthew Gillespie ♦♦ Majid A commented ·

That command is an exception. For some reason it is currently marked as a developer only command.

0 Likes 0 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.