[Feature-1739]Perspective Relative Path for Embedded View, Flex Repeater, etc

It would be nice to be able to optionally reference other views via a relative path in the path prop. For example, in this image if we could reference ‘./Realistic’ instead of ‘Components/Pump/Symbol/Realistic’ I could then rename the folder or move everything to a different folder without breaking the references.

Hacky workaround:

Bind the path property with a property binding on any property (you actually need access to the transform part of the binding).
Add a transform to the binding.
Supply the following script: return "/".join(self.view.id.split("/")[:-1]) + "/desiredViewName" where “desiredViewName” is the name of the View you want a relative position of.

In this example, I bound against view.props.loading.mode, but I don’t need that value - I just need the transform. Note the returned value in the binding dialog preview area.

With that binding in place, I was able to drag my something directory around into different locations of my View directories and the references to other Views within the directory remained functional.

4 Likes

Perfect! I was attempting to implement a workaround like this and that self.view.id property is what I was looking for. That will get me going for now. Thanks!

1 Like

I’ll suggest self.view.id[:self.view.id.rfind('/')], which avoids spliting and joining.
It might be less readable when dealing with this kind of variable, but this can easily be fixed by assigning the string to another var, which actually makes the whole thing more readable than the initial solution in my opinion:

Is this actually a bad solution ?

1 Like