This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Synchro Script - PARENT.PARENT.PARENT.PARENT...

I am writing a script to generate ResourceGroups based on a UserField that is dependent on the name of the imported .ifc file.

Example:

There are 9 child tasks underneath the parent task of the construction.ifc file. The condition of the script:

RESOURCE (PARENT.PARENT.PARENT.PARENT.PARENT.PARENT.PARENT.PARENT.PARENT.NAME <> "construction") ....

The installation .ifc model only has 6 child tasks underneath the parent task. The condition of this script:

RESOURCE (PARENT.PARENT.PARENT.PARENT.PARENT.PARENT.NAME <> "installation") ....

I don't want to edit each script based on the number of child tasks as this varies on the type of the model.
I wrote the following script which searches in the name of all 9 parent tasks in case there are fewer child tasks.

RESOURCE (PARENT.NAME <> "construction") ....
RESOURCE (PARENT.PARENT.NAME <> "construction") ....
RESOURCE (PARENT.PARENT.PARENT.NAME <> "construction") ....
RESOURCE (PARENT.PARENT.PARENT.PARENT.NAME <> "construction") ....
RESOURCE (PARENT.PARENT.PARENT.PARENT.PARENT.NAME <> "construction") ....
RESOURCE (PARENT.PARENT.PARENT.PARENT.PARENT.PARENT.NAME <> "construction") ....
RESOURCE (PARENT.PARENT.PARENT.PARENT.PARENT.PARENT.PARENT.NAME <> "construction") ....
RESOURCE (PARENT.PARENT.PARENT.PARENT.PARENT.PARENT.PARENT.PARENT.NAME <> "construction") ....
RESOURCE (PARENT.PARENT.PARENT.PARENT.PARENT.PARENT.PARENT.PARENT.PARENT.NAME <> "construction") ....

Is there a way to easily search in all available parents?

Best regards,
Stephan Klotz

Parents
  • Hi Stephan, 

    One alternate way of achieving this would be through assigning a new UserField to filter all the Resources containing the name 'construction' in any part of the tree heirarchy.

    Lets say, and please confirm, you are working with the following dataset - 

    Create a Custom Filter for the column Name


    Select all filtered Resources and run the following Script - 

    RESOURCE(SELECTED).LEAF ASSIGN_UF("New User Field B", STRING, "construction")

      

    Now you can use both the User Fields to create the Resource Groups - 

    RESOURCE( UFV("New User Field B")=="construction") ASSIGN_GROUP_BY_ID(UFV( "New User Field A"))

    I hope this helps!

  • Hi Arpit,

    Thank you, this is an interesting workaround. I guess there is no alternative script to do this?
    I would like to create a workflow where we don't need any filters or manually selecting Resources, but just one or multiple scripts that could work on any .ifc file, regardless of the numbers of child tasks. 

    Stephan

  • We are considering to implement something like this: Level(n) to return specific level parent for both UF and Script. We don't have an estimate yet, but this is something that's being discussed, hopefully you will hear from us soon. 

    Answer Verified By: Stephan Klotz 

  • Hi Jacqueline, any update on this topic? this Level(n) function would be really helpfull in many cases.

Reply Children
  • It was released with 6.4 and only implemented for UF, mentioned in release notes here: communities.bentley.com/.../synchro-4d-pro-2021-1

    New object commands LEVEL_1, LEVEL_2... LEVEL20 was added.
    Using of this command is possible for Task, Resource or 3D objects.
    Command 'LEVEL_N' - returns the list of objects with placed on N deep level in object tree in the same branch as current object.
    If N smaller or equal than deep level of current object - it's parent object of required absolute deep level. If the N is bigger than result is list of sub objects with fixed deep level N - this result may be multiple or empty.
    'N' is 1 based numeration. 1 - root level.
    Example of script:
    3D( DEEPLEVEL > 3) ASSIGN_UF( "UF", STRING, LEVEL_1.NAME + "::" + LEVEL_2.NAME + "::" + NAME )
    - assign to all 3D objects which more then 3 deep level - string UF named "UF" with contents - concatenation of names: root parent object + parent object of 2 level + own name with splitter "::"

    Answer Verified By: Stephan Klotz