[Solved] Sparse XML and Layers

Started by lllama, March 17, 2010, 09:56:06 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

lllama

Hello all,

I'm trying to create a network diagram using a sparse VDX file. This has been going well up until I wanted to put different components on different layers. I thought I could just add a "LayerMem" and appropriate "Layermember" elements to the parent shape and, because the parent shape points to a master, I thought the sub-shapes would all inherit the layer assignment. Sadly this doesn't seem to be the case so I've ended up populating my shape with sparse sub-shapes, each with their own layer membership.

This works and the shapes are now all on the correct layer, but now the sub-shapes' positioning is shifted. The attached file should demonstrate what I'm seeing: if you were to click on the server then you'll see that its bounding box is shifted to the left of the actual graphics themselves. The box is in the correct position as determined by the XForm of the parent shape.

So my questions are:
Does anyone know if I'm approaching this in the correct way?
Can anyone see where I'm going wrong?
and
Does anyone have any good reading recommendations for working with Visio's XML?

Many thanks in advance, I realise this is a bit of a obscure one.


Aeon

i'm not certain i'm getting the questions right but i can answer as to the positioning of your shapes and subshapes

the reason your server is off a little is that it's part of a group, and the position of the server is relative to that group.
if you want to see how to handle that you might want to right click the server in the file you provided and go to group > open group
there you can adjust the server location to be within bounds of the white "sheet" boundaries". after you do that it will be located in the bounding box.

then you can proceed to save it as a different  filename and compare the 2 xml sources.

same thing as to adding subshapes to layers, just start out with a group of shapes, then open group and assign each subshape to a different layer, save the file and check xml to see how visio handles it. that should at least help you along the way.

lllama

Thanks Aeon.

I'm going slightly insane staring at XML but I'll try a few more test cases.

A quick test (which I'm sure I tried before) shows that it's not the adding of layers that's the problem, it's the adding of the sub-shapes.

Looking at some Visio generated XML it seems that you have to add the sub-shapes if you want the whole thing to be on a layer but it's the added of the sub-shapes, not the assigning to the layer, that's causing the problem. I'm guessing I'll have to give each shape an XForm or something similar.

Thanks for the quick response. If anyone else can spot what's wrong then please chime in. I'll post anything else I find out.

lllama

I seem to have found a solution. The master Server shape had an ID of 2. It then contained sub-shapes with various other IDs (duh). On a Visio generated example the first sub-shape was missing from the shape on the page. Once I modified my program to do likewise everything started to line up. It works with the other shapes I have (routers, etc) so it doesn't seem to be Server shape specific.

Looking at the master again it now seems "obvious". The first shape is the one that defines all of the main properties: XForm, Events, the various Props, so I was including this shape twice - once in the original reference to the master and once as a sub-shape. As Aeon stated, the grouped shapes are all positioned in relation to each other, so the additional XForm was what was probably translating all of the other shapes.

Thanks again to Aeon for replying - I probably wouldn't have looked at this again if he hadn't. Thanks to the forum as well: if I hadn't prepared the trimmed down version then I probably wouldn't have spotted this.