Shapes Relations Manipulation Tool

Started by Yacine, December 11, 2015, 08:11:42 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

J_M

#30
@Yacine,
Hope all is good!
Please note that i downloaded Box-in-box.vsdm and i was able to run the macro load_excel, many thanks :)

- When i loaded an excel with around 800 rows, i received Run-time error '6' Overflow (attached screenshot)
- So for now, i only included 3 rows in the Excel to test the output. I ran the macro load_excel, and the boxes were properly created (but not included within each other as parent/child which is expected). Next i need to run the macro BoxinBox3 as you explained right? since this macro will be responsible of placing the shapes correctly within each other based on their relations.
I searched for this macro, i didn't find it? can you help me locate it?
- Additionally, should i update the script BoxinBox3 (in the access file i have) with the updated code you shared with me?
- One last question: i see that the data displayed in each box is listing all the info within the Excel columns, if i only want to display the info contained within column "ID", "Label" and "Type" without the other columns, how can i do so?

Thanks!!

Yacine

#31
Right,
you're now at the step where you should use the actual Sharem tool.
To do so, drag the yellow square of the stencil "Relations" onto the drawing. The tool dialogue should open.
Select the "scripts" tab and push the "load scripts" button. (The access DB must be in the same folder as the stencil).
You should now see the lists of scripts.
Play with them and try to understand them. You may also want to read the posts above.
Yacine

J_M

@Yacine
Thank you so much for the provided tips! I managed to run the script BoxinBox2 after loading the Excel file (i checked the different scripts, and noticed that BoxinBox2 is the closest to what we want)

Just one thing, the text of the parent box is hidden by the child boxes (example of the attached screenshot)
Do you think anything can be done about this? If not, it's okay, i will check if this can be done manually

Many thanks!

Yacine

#33
@J_M,
Sorry that BoxesInBoxes 3 did not meet your expectations. I thought it would be better fit than the buggy version 2.
Anyway, you can adjust the text with the following script - it makes the text top and left aligned and sets the text margins.

IF PinX exists THEN
Para.SpLine := -100%;
Para.HorzAlign := 0;
VerticalAlign := 0;
LeftMargin := Char.Size * 0.5;
RightMargin := Char.Size * 0.5;
TopMargin := Char.Size * 0.5;
BottomMargin := Char.Size * 0.5;
Height := TEXTHEIGHT(TheText,Width);
ENDIF


You may want to:
1) delete the "Height" line to get shapes of equal height.
2) you may need the adjust the PinY property of the child shapes by increasing its value relatively to their parent's.
Cheers, Y.  ;)
Yacine

J_M

@Yacine,
Thanks for your reply!

I added the part you shared with me to the code (and removed the previous If/else statement), but apparently I am still missing something because the boxes are not yet properly set.
Below is the current code i have in BoxinBox2:
IF PinX exists THEN
Para.SpLine := -100%;
Para.HorzAlign := 0;
VerticalAlign := 0;
LeftMargin := Char.Size * 0.5;
RightMargin := Char.Size * 0.5;
TopMargin := Char.Size * 0.5;
BottomMargin := Char.Size * 0.5;
Height := TEXTHEIGHT(TheText,Width);
ENDIF
IF prop.LeftSibling  = 0 THEN
PinX := [P]!PinX + 2 mm;
PinY := [P]!PinY - 7 mm;
ENDIF
IF prop.LeftSibling  > 0 THEN
PinY := [L]!PinY;
ENDIF
IF prop.HierarchyDepth = 0 THEN
Height := [MAXDESC](Height) + TEXTHEIGHT(TheText,Width)+ 5mm;
ENDIF


Any advise on what else should I update?

Thank you so much for your time

Yacine

#35
Your code:
The following is for formating the text. Put it in a separate script, in order to concentrate on the layout task:
IF PinX exists THENPara.SpLine := -100%;
Para.HorzAlign := 0;
VerticalAlign := 0;
LeftMargin := Char.Size * 0.5;
RightMargin := Char.Size * 0.5;
TopMargin := Char.Size * 0.5;
BottomMargin := Char.Size * 0.5;
Height := TEXTHEIGHT(TheText,Width);
ENDIF

This block means that the first child should follow its parent in both vertical and horizontal direction.
It does not consider the text of the parent
IF prop.LeftSibling  = 0 THEN
PinX := [P]!PinX + 2 mm;
PinY := [P]!PinY - 7 mm;
PinY := [P]!PinY - TEXTHEIGHT([P]!TheText,[P]!Width) - 2 mm;
ENDIF


This block means that all children except the first one, shall follow the first sibling in vertical direction.
PinX is missing
IF prop.LeftSibling  > 0 THEN
PinY := [L]!PinY;
PinX:= [L]!PinX + [L]!Width + 5mm;
ENDIF


This block sets the height of the very first item in the hierarchy.
The height of the children is missing
IF prop.HierarchyDepth = 0 THEN
IF PinX exists THEN (just a trivial test that applies to any 2D shape)
Height := TEXTHEIGHT(TheText,Width)+ 5mm; (this formula will always work)
Height := [MAXDESC](Height) + TEXTHEIGHT(TheText,Width)+ 5mm; (The formula will only work if the item has children and will overwrite the line above.)
ENDIF


What about the width? -->
IF PinX exists THEN
Width := [SUMDESC](Width) + (prop.numdescendents+ 1)*2mm
ENDIF

final script:

IF prop.LeftSibling  = 0 THEN
PinX := [P]!PinX + 2 mm;
PinY := [P]!PinY - TEXTHEIGHT([P]!TheText,[P]!Width) - 2 mm;
ENDIF
IF prop.LeftSibling  > 0 THEN
PinY := [L]!PinY;
PinX:= [L]!PinX + [L]!Width + 2mm;
ENDIF
IF PinX exists THEN
Height := TEXTHEIGHT(TheText,Width)+ 5mm;
Height := [MAXDESC](Height) + TEXTHEIGHT(TheText,Width)+ 5mm;
Width := [SUMDESC](Width) + (prop.numdescendents + 1) * 2mm+5mm;
ENDIF
Yacine

J_M

@Yacine , Works great! thank you so much for all your assistance and for this useful thread !!