Re-ordering rows in the prop section

Started by Yacine, August 29, 2022, 07:51:51 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Yacine

We were recently discussing big smartshapes and one issue kept nagging on me, how to re-order prop rows.

Why at all? It is not absolutely necessary since you can display the props in the order you want using the SortKey field.
But having the rows in proper order helps when maintaining the shape.

You can't just delete the prop section and rebeuild, it would break the formulas in all cells depending on the prop section. These cells can by anywhere in the shapesheet and even in other shapes.

First try - using ShapeReplace
- Make a new shape where the props are ordered the way you want. Fill in every information you find in the original.
- Replace this new shape by the new one, hoping that it will only rewrite the contents of the data rows.

--> Failed because it re-writes the prop section as in the original shape.

Second try - targeting the xml of the shape
- Copy the original shape in a virgin document, save and close
- Rename the vsdx into zip

- using the file explorer, enter the zip and navigate to \visio\pages.
- The target file is page-1.xml. Don't edit it directly in the zip file, it is read-only. Instead copy it to another location (eg Desktop).
- Edit the file.
- I used Visual Studio Code, because it has neat xml tools - I used the xml tools from Josh Johnson, but any other should probably do.
- The code comes as a 2 liner - hard to read. So you format it with with line breaks and indentations (Shift-Alt-F).
- Reorder the sections to your gusto.
- I don't know if it is really necessary, but I formatted the xml back to the 2 liner ("Minify xml").
- Save and close
- In the file explorer delete the file page-1.xml and copy the one from the desktop in it.
- Rename the zip file back to vsdx, open the file and save the shape to the stencil of your choice.

Caution: unzipping, editing and re-zipping did not work. I'm using 7-zip and it seems to pack the contents in a way Visio doesn't like.
That's why the a.m. method for editing the files.
Yacine

Surrogate

QuoteCaution: unzipping, editing and re-zipping did not work. I'm using 7-zip and it seems to pack the contents in a way Visio doesn't like.
That's why the a.m. method for editing the files.
At my side unzipping/editing/re-zipping in 7-zip application did not work.
I open it in IZArc application without repack.
PS what is it a.m. method?

Yacine

#2
a.m. = above mentioned
I meant, don't unzip the file, then zip again, but copy the file from inside the windows file explorer, paste it as regular file in another folder. After editing and saving, drag the so modified file and drop it into the windows explorer, in the sub folder "pages" of the zip file. This way the zip file won't get corrupted.


Does it work with izarc?


----
I may write a python script to automate the process.
There libraries for zip and xml handling.
I would write a small form displaying the props, ordering them by their sortkey.
Buttons for up and down.
Then do the above mentioned steps automatically.
Yacine

Surrogate

Quote from: Yacine on August 29, 2022, 10:18:29 AMDoes it work with izarc?
I didn't try it for your purposes, but this tool is single way for make changes in xml into vsdx files without re-packing...

Croc

#4
I use other tools: WinRar and Notepad++.
It looks like this.
https://drive.google.com/file/d/1ZwiTiBDNJwDkHqhC3XSqlpc0Z6KEn-fi/view?usp=sharing
WinRAR opens .vsdx without renaming. The plugin for Notepad++ shows the XML structure very well.