Jump to content

convert absolute <-> relative


ikoon

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).

Link to comment
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

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...