## [Script] Bookmark Node Positon

pingking
Fusionista
Posts: 729
Joined: Thu Aug 14, 2014 9:10 am
Been thanked: 8 times

### [Script] Bookmark Node Positon

(splitting this into a seperate thread)
in the discussion about the feature wish for a "bookmark system" which can store specific locations in the composition and you can jump quickly to them i came up with these 2 scripts:

- both are comp scripts
- positions are stored in the comp meta data, so you dont lose them after closing the comp
- currently i store the name of the selected node and jump to this node even if you moved it

script to store the "Bookmarks":
1. --------------------------------------
2. -- example to recal position and names of tools in the composition metadata
3. -- and jump the flowView to the selected tool
4. --
5. --
6. -- Michael Vorberg
7. --
8. -- CC BY-NC 4.0
10. -----------------------------------------------------------------
11.
12.
13. fusion = Fusion()
14.
15. composition = fusion:GetCurrentComp()
16.
17. flow = composition.CurrentFrame.FlowView
18.
19. CurXPos, CurYPos  = flow:GetPos(composition.ActiveTool)
20. tool = composition:GetAttrs().COMPH_ActiveTool
21.
22. ret = comp:AskUser("Save Position to ...", {
23.     {"storeName", Name="store as", "Text", Lines = 1, Default = tool:GetAttrs().TOOLS_Name},
24.     })
25.
26.
27. if ret == nil then
28.     print("cancelled") return
29. else
30.     storePositionName = "Position_"..ret.storeName..".name"
31.     storePositionX = "Position_"..ret.storeName..".x"
32.     storePositionY = "Position_"..ret.storeName..".y"
33.     composition:SetData(storePositionName,tool:GetAttrs().TOOLS_Name)
34.     composition:SetData(storePositionX,CurXPos)
35.     composition:SetData(storePositionY,CurYPos)
36.
37. end
ideas, feedback and improvements welcome!
Last edited by pingking on Sat Sep 17, 2016 12:09 pm, edited 1 time in total.

pingking
Fusionista
Posts: 729
Joined: Thu Aug 14, 2014 9:10 am
Been thanked: 8 times

### Re: [Script] Hotspot Nodes

1. --------------------------------------
2. -- example to store position and names of tools in the composition metadata
3. -- to recall them later and jump the flowView to the selected tool
4. --
5. -- you can store the positions under any name, but by default it will be the active tools name
6. --
7. -- tool/node has to be active to be stored
8. --
9. -- Michael Vorberg
10. --
11. -- CC BY-NC 4.0
13. -----------------------------------------------------------------
14. fusion = Fusion()
15.
16. composition = fusion:GetCurrentComp()
17.
18. flow = composition.CurrentFrame.FlowView
19.
20. storedPositionTable = {}
21.
22. for i,v in ipairs(composition:GetData()) do
23.     a, b = string.find(v, "Position")
24.     if b ~= nil then
25.         table.insert( storedPositionTable, string.sub(v, b+2))
26.
27.     end
28. end
29.
30. ret = comp:AskUser("jump ...", {
31.     {"PosSlot", Name="to ", "Dropdown", Options = storedPositionTable},
32.     })
33.
34.
35. if ret == nil then print("cancelled") return
36.
37. else
38.     storePositionName = "Position_"..storedPositionTable[ret.PosSlot+1]..".name"
39.     storePositionX = "Position_"..storedPositionTable[ret.PosSlot+1]..".x"
40.     storePositionY = "Position_"..storedPositionTable[ret.PosSlot+1]..".y"
41.     newX = composition:GetData(storePositionX)
42.     newY = composition:GetData(storePositionY)
43.     newName = composition:GetData(storePositionName)
44.     source = composition:FindTool(newName)
45.     composition:SetActiveTool(source)
46.     composition.CurrentFrame.FlowView.SetScale(2)
47. end
Last edited by pingking on Sat Sep 17, 2016 12:10 pm, edited 1 time in total.

Fusionista
Posts: 619
Joined: Sun Sep 21, 2014 6:17 am
Been thanked: 13 times

### Re: [Script] Hotspot Nodes

Maybe a different name for it might be a good idea, since we already have an actual tool that's called Hot Spot in Fusion, just to prevent con-Fusion. (Sorry 'bout that)

Kristof
Fusionista
Posts: 545
Joined: Thu Aug 07, 2014 1:30 pm
Been thanked: 16 times

### Re: [Script] Hotspot Nodes

ShadowMaker SdR wrote:Maybe a different name for it might be a good idea, since we already have an actual tool that's called Hot Spot in Fusion, just to prevent con-Fusion. (Sorry 'bout that)

As in X marks the spot? Cool. Waypoints, jump-to points, anchors, bookmarks, hooks...

Thanks Pingking, going to give it a whirl!

pingking
Fusionista
Posts: 729
Joined: Thu Aug 14, 2014 9:10 am
Been thanked: 8 times

### Re: [Script] Bookmark Node Positon

just changed the title of the thread and the names of the scripts

Kristof
Fusionista
Posts: 545
Joined: Thu Aug 07, 2014 1:30 pm
Been thanked: 16 times

### Re: [Script] Bookmark Node Positon

Hi pingking, a few ideas:

have the list sorted alphabetically (easier to look through)
store the zoom level and average position of selected nodes (in case of multiple selected nodes) as part of the bookmark's settings. A single node is not always the ideal jump-to point and you might need a certain zoom level to be able to really focus on that part of the comp. Like a "fit selection" workflow

Thanks for the script, it is already a great starting point and allows a user to get a taste of what's possible.

pingking
Fusionista
Posts: 729
Joined: Thu Aug 14, 2014 9:10 am
Been thanked: 8 times

### Re: [Script] Bookmark Node Positon

Kristof wrote:Hi pingking, a few ideas:

have the list sorted alphabetically (easier to look through)
store the zoom level and average position of selected nodes (in case of multiple selected nodes) as part of the bookmark's settings. A single node is not always the ideal jump-to point and you might need a certain zoom level to be able to really focus on that part of the comp. Like a "fit selection" workflow

Thanks for the script, it is already a great starting point and allows a user to get a taste of what's possible.
sorting the list seams easy, i'll put it on my list for improvements

i wanted to have a system where you can jump to specific XY coordinates in the flow with a certain zoom level. so you can jump to the "Bookmarks" even if the node doesnt exist anymore. but i didnt find a way to do it (okay, i found one, but that was a very silly one). it seems that you can only jump in the flow to specific nodes and not XY positions

ColoristNow
Posts: 10
Joined: Mon Oct 30, 2017 3:53 am
Been thanked: 1 time

### Re: [Script] Bookmark Node Positon

This is awesome! just what I needed.
As a side-note would it be possible to also add an option to delete the bookmarks?

Movalex
Fusioneer
Posts: 108
Joined: Fri Nov 03, 2017 5:36 am
Been thanked: 22 times
Contact:

### Re: [Script] Bookmark Node Positon

Here's my little bookmarking script.
Add bookmarks for selected tool, set custom name or use default name. Then invoke jump script and instantly switch to the desired node of your huge comp.
I used Michael's approach and added some features:
* bookmarks sorted alphabetically
* delete single bookmark or reset all
* instant switch between bookmarks without prompt
* submit bookmark addition on press Enter
* close window on press ESC
* do not switch to first bookmark on script launch
* the bookmarked tool can be either active or just selected, whatever

Script requires 64-bit Python v2.7 or v3.6.
Shortcuts are mapped in config file to SHIFT+A and SHIFT+J (Add and Jump respectively)

TODO:
* I'd like to center bookmarked node in a flow. I thought it can be easy done, since we already have Find Tools built-in functionality that centers the tool found in the flow. I even created a topic (viewtopic.php?f=6&t=2812), but nobody answered. So it is either me failed to clearly explain my intent or there's no solution.
* Use shortcut to open bookmarks dropdown of the Jump script on MacOs. It already works on Windows: after script is launched you can use DOWN (or ALT+DOWN) to (visually) switch between bookmarks. It currently does not apply for Mac. There's ShowPopup() method in UIComboBox class, so we could probably assign a key to force show dropdown, but I am not sure how to do that.
* Submit to Reactor (almost done).

You do not have the required permissions to view the files attached to this post.

intelligent machine
Fusionista
Posts: 403
Joined: Fri May 13, 2016 10:01 pm
Location: Austin, Texas, USA
Been thanked: 29 times
Contact:

### Re: [Script] Bookmark Node Positon

Hey @Movalex
I searched every alternate keyword I could think of in every text and binary document in every fusion folder and came up with nothing....so I worked out a hackaround that gets the centering of the bookmarks 'almost' there.
With some more work and querying of actual window and view dims this could get a lot closer.

So the hack is:
We start by getting the position of the bookmarked tool on the flow.
We then get the flow scale amount that will be used and add two new nodes that are offset in X and Y from the source node's position.
We activate each of those new nodes and then delete them and activate the source.

I added a variable for the scaleFactor so that hopefully each bookmark can have a stored scale. The scaleFactor variable is used for the actual flow scale and to calculate the offsets of the temp nodes.

It doesn't center 100% because as I mentioned, we need to query actual window/view dimensions and use half of that result to create the offsets.

Added in 16 minutes 34 seconds:
Here's the edited file:
(edits marked with '#**')
bookmark_jump-edit.py
You do not have the required permissions to view the files attached to this post.

Movalex
Fusioneer
Posts: 108
Joined: Fri Nov 03, 2017 5:36 am
Been thanked: 22 times
Contact:

### Re: [Script] Bookmark Node Positon

This is a really nice workaround, thanks! I'm currently onto add scaling preserve for bookmarks.

intelligent machine
Fusionista
Posts: 403
Joined: Fri May 13, 2016 10:01 pm
Location: Austin, Texas, USA
Been thanked: 29 times
Contact:

### Re: [Script] Bookmark Node Positon

I fiddled with it a little more after the last post and found that just offsetting the PipeRouters to a fixed distance and activating from a max zoom (400%) works better considering varying screen widths and tool/modifier panels:

Code: Select all

toolName = "Background1"
source = comp.FindTool(toolName)
sx, sy = flow.GetPosTable(source).values()
scaleFactor = 1.75
pr1 = comp.AddTool("PipeRouter", sx - 2, sy - 2)
pr2 = comp.AddTool("PipeRouter", sx + 2, sy + 4)
flow.SetScale(4)
comp.SetActiveTool(pr1)
comp.SetActiveTool(pr2)
flow.Select()
pr1.Delete()
pr2.Delete()
flow.SetScale(scaleFactor)
comp.SetActiveTool(source)


Movalex
Fusioneer
Posts: 108
Joined: Fri Nov 03, 2017 5:36 am
Been thanked: 22 times
Contact:

### Re: [Script] Bookmark Node Positon

Hey, @intelligent machine!
Here's a bit refactored version of the script, featuring preserve scaling and your slightly modified hackaround for centering bookmark.

Current issues:
1. With hackaround enabled the surrounding tools temporarily disappear until the flow is moved.
2. Centering feature produces unnecessary clutter in comp, so while useful, still a bit annoying. We need a native solution!
3. If the tool is renamed after bookmark add, it will not be found, since the script is looking for tool's name. Dunno how to handle this or even whether it worth handling.

TODO:
Current revision allows to create as many bookmarks for one tool as you like.
Probably it is not optimal, so for current tool we need only one bookmark.
We could check 'TOOLI_ID' of the tool, and if it exists, bookmark will be replaced with the new name.

P.S. You are welcome to make some PR's here: https://github.com/movalex/fusion_scrip ... Bookmarker
You do not have the required permissions to view the files attached to this post.

intelligent machine
Fusionista
Posts: 403
Joined: Fri May 13, 2016 10:01 pm
Location: Austin, Texas, USA
Been thanked: 29 times
Contact:

### Re: [Script] Bookmark Node Positon

@Movalex Working pretty well so far.
A few suggestions:
1. Creating bookmarks that begin with numbers will produce errors.
I'd suggest either testing for that and automatically preceding with an underscore if true or throwing up a "not allowed" warning message.

3. make the window dockable if possible.

4. maybe make the dropdown and buttons inline and change buttons to just icons (trash can, reset (mail reply), and plus sign) - more relevant to #3 above if this could be docked and kept minimal.

Movalex
Fusioneer
Posts: 108
Joined: Fri Nov 03, 2017 5:36 am