Jump to content
ikoon

convert absolute <-> relative

Recommended Posts

Please, do you have any complete solution to convert from or to relative references?

- sometimes I need to convert the expressions, e.g. chs("../name") or ch("../transform1/rx") or chs("/obj/geo1/name1/attribname")
- sometimes it is just a node reference, e.g. object_merge this node: ../OUT_data1
- it could also be object_merge many nodes: /obj/geo/OUT_data2    /obj/geo/OUT_data3   /obj/geo/OUT_data4

I usually do it manually. But sometimes it would be useful to convert some (or all) references on the node with a script. E.g after creating the Reference copy (Ctrl+Alt+Shift drag).

Share this post


Link to post
Share on other sites

This seems to work for converting simple expressions ... I have tried also the "getReferencedParm()" ... but this "brute force replace" seemed easier now. Still it is only a partial solution:

def parm_relative_to_absolute_all(node) :
    for parm in node.parms() :
        parm_raw     = parm.rawValue()
        try:
            path         = re.findall('[\"\'](.*?)[\"\']',parm_raw)[0]
            path         = path[:path.rindex('/')]
            path_abs     = node.node(path).path()
            parm_raw_abs = parm_raw.replace(path,path_abs)
            parm.setExpression(parm_raw_abs,  replace_expression=True)
        except:
            # probably it was not referenced
            pass

rel_to_abs.thumb.gif.dbeaa7659635ed8a5aade7c51733a561.gif

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×