Check if a column is selected in the workspace

Hello,

in my JavaScript macro I iterate over the selected objects of the current model (this is done by using form.RegisterObject(This, ‘SelectedObjects’) inside the script.

This works fine. However I would also like to detect if only certain attributes/columns of the entities are selected.

In the attached image, only the columns “length” and “release_year” are selected. I would like to detect this situation in my script.

Is that possible? If yes, how?

selected.png

Hi,

unfortunately this is not possible now. You can only iterate throught objects selected on workspace or objects selected in Physical Model Explorer. If you want to do operation on selected columns, I recommend you to select the columns in Physical Model Explorer (or Object Viewer result set) and then run macro.

I hope it helps,

Regards,

Vaclav

Thanks. Using the Physical Model Explorer would be OK for me.

Could you show me an example on how I can get hold of the selected items there?

OK, I found out how to do it.

However I can’t seem to find a way to get the Entity that belongs to the selected attribute. PERAttribute does not seem to link back to it’s parent (the Owner attribute always returns null)

Hi,

pleasee try this:
Log.Information(Attribute.Owner.Name.toString());
and let me know result.

You can also try the following:

MyEntity = Attribute.Owner;
Log.Information(MyEntity.Name);

Thanks,

Vaclav

Message was edited by: vaclav