question

shanice.c avatar image
0 Likes"
shanice.c asked shanice.c commented

PropertyTable problem

Hello, I'm trying to use PropertyTable to edit object labels. I have 2 problems, first is that when using "Apply to all" option, it works right after the values are filled in each rows. But after reset, some rows of that label value is also reset. I'd like to know is it because I'm missing some steps?

Second is that if there's a way (use code or use Property table) to let my model check "Automatically Reset" and also "Save reset value for all labels"? Or I have to do this by visiting every object one by one? I want to do this because these label values are fixed(won't be changed in the future). So I would like to define these labels to describe the objects in the beginning of building the model.

Thank you!


FlexSim 21.2.0
propertytable
· 1
5 |100000

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

anthony.johnson avatar image anthony.johnson ♦♦ commented ·
This looks like a bug. Thanks Felix for helping with the workaround. Well add this to our dev list.
0 Likes 0 ·

1 Answer

Felix Möhlmann avatar image
0 Likes"
Felix Möhlmann answered shanice.c commented

The first processor has the "Automatically Reset" option for the labels checked. Adding/changing a label in the property apparently doesn't update the labelreset node so the labels get reset to the old value on model reset.

To update the reset values for all objects in a group you can run the following code:

// Insert the correct name
for(int index = 1; index <= Group("GroupName").length; index++)
{
    treenode objectLabels;
    if (!objectexists(objectLabels)) {
    objectLabels = Group("Group1")[index].find(">labels");
    }

    treenode resetlabels = Group("Group1")[index].find(">labelreset");
    if (!objectexists(resetlabels)) {
    resetlabels = nodeinsertafter(objectLabels);
    setname(resetlabels, "labelreset");
    }

    if (objectexists(resetlabels) && (content(resetlabels) > 0 || content(objectLabels) >    0)) {
        if (time()==0||msg("Label Values Reset","Update Label Reset Values?",4)) {
        createcopy(objectLabels, resetlabels, 1, 0,0,1);
        setname(resetlabels, "labelreset");
        }
    }
}

This is mostly the same code that gets run when clicking the button in the properties window that updates the reset values. It is adjusted to iterate over all objects in a group. Essentially it creates a copy of the objects' "labels" node with the name "labelreset". The presence of that new node will also activate the automatic reset.

· 3
5 |100000

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

shanice.c avatar image shanice.c commented ·

Hello @Felix Möhlmann, Thank you for your answer. May I ask how could I query the property one object has, for example, we change forklift "forkinitialheight" by putting "forkinitialheight" in the first parameter in setVariable(). It's a kind of hard to find what properties or variables an object has directly from the manual. But I could easily see "forkinitialheight" from tree.

Previously I failed to find property spelt like labelreset, and just now I tried to directly look for "labelreset" from Tree, but also haven't seen. My question is that how to know that we could change this property by finding it's property name?

0 Likes 0 ·
Felix Möhlmann avatar image Felix Möhlmann shanice.c commented ·

"labelreset" is not a property but a separate node that gets created when the corresponding function is activated. Then you find it in the object's tree directly following the "labels" node.

1641459129068.png

To know which properties an object has, you can either look in the "Reference" section of the manual. Link to processor properties as example:

https://docs.flexsim.com/en/22.0/Reference/3DObjects/FixedResources/Processor/#properties

Other than that, everything listed in the properties table for an object and it's parent classes should be possible to be accessed with "getProperty()"/"setProperty()".

1641459461638.png

0 Likes 0 ·
1641459129068.png (5.3 KiB)
1641459461638.png (20.1 KiB)
shanice.c avatar image shanice.c Felix Möhlmann commented ·

@Felix Möhlmann Thank you for your help! I have used the code to create the labelreset node, and have labels reset saved.

0 Likes 0 ·