News:

BB code in posts seems to be working again!
I haven't turned on every single tag, so please let me know if there are any that are used/needed but not activated.

Main Menu

Responsive height of multiple shapes

Started by mlussier, May 26, 2017, 01:37:03 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

mlussier

Hi,
I'm creating a list of materials with a custom shape. The columns in the list are controllables in width. It works fine when all of the items have all the same width, the problem is when I resize the width to a smaller one my text becomes in a 2 line textblock(which is what I want) but if there's a smaller line before, it overlaps the smaller line with the first line of the item below when it's on 2 line.

i.e.:
This line is very long and will be on 2 lines when the width is small.
A small line.
Another long line that will be on 2 lines after the resize.

It will become:
This line is very long and will be
on 2 lines when the width is small
A small line    <----Another long line that will be
on 2 lines after the resize

The middle shape will overlap both lines and i don't want that.

I use material.Cells["PinY"].Formula = "Sheet." + last.ID + "!PinY-Sheet." + descrip.ID + "!Height"; for the position of the shape.

Any toughts on an algorithm for that or am I unclear ? (I'm in C# but I understand VBA)

Thanks

Yacine

#1
Basically you're trying to build a table. There are numerous threads to this problem in the forum. None is very satisfactory.

If I may give an advice, build the report outside of Visio and insert it via OLE. That gives you so much more functionality without the trouble of having to code everything by yourself.
You may want to persist and the forum may help you solve this one issue, but at the end of the day, you will probably look over a very complicated and possibly fragile construct, that you may could have solved in an easier way.
Yacine

mlussier

I'm already doing this with an Excel sheet but they want a dynamic shape to do the same functionnality without copy paste the Excel sheet.
So basically I will try to find an algorithm to do this automatically.

Thanks for you answer

Yacine

Yacine

wapperdude

Visio can create an Excel worksheet from scratch via insert object.  Similarly, the report wizard, as I recall, can embed the report within Visio without touching the outside world...IIRC.

Wapperdude
Visio 2019 Pro

mlussier

My shape now works just as wanted. I'm just moving around the PinY cells of my shape depending of the height of the cells that grows in height when I shrink the master shape.
It took some times to figure out the algorithm, but it is now working properly.

This is the algorithm I found that worked for me so if anyone needs it here it is:
material.Cells["PinY"].FormulaU = "=IF(Sheet." + descrip.ID + "!User.numbLine.Prompt>1,Sheet." + last.ID + "!PinY-Sheet." + descrip.ID + "!Height-(Sheet." + descrip.ID + "!User.numbLine.Prompt*0.125mm),Sheet." + last.ID + "!PinY-Sheet." + descrip.ID + "!Height)";

Where descrip.ID is the shape that can go on multiple line of the current shape, last.ID is the shape pasted before the one I'm working on, numbLine is a property in the descrip shape which holds the number of line taking by the descrip shape.

First screenshot show the table created dynamically with my C# code where the descrip column is stretch to the max
Second screenshot is with the descrip column shrink to show the algorithm used


wapperdude

Glad we could help!   ;D

That's a lot of shapes. There is some max number for Visio, but don't recall what it is.  Still seems like a lot of effort to avoid Excel.

Wapperdude
Visio 2019 Pro

mlussier

I'm already using Excel to generate the same list but with more informations. The thing is that I copy paste the Excel sheet on Visio. So I wanted to avoid the extra operations to have the same benefits.
I didn't know there was a maximum number of shapes ... I must check that because the shapes on the screenshots are probably way higher than that on different projects.

Thanks

mlussier

#8
I have another question related to my shape ... for now it scans the active page for shapes then writes them in my list. I want to know if it's possible to do this with a selected area. I know I could do it with a macro but the directors don't want more macros that we already have. My shape works with an action on the right-click button so I can't check for the selection since my list will be selected.
If I could do like Excel does with the range selector but let's say position selector with Visio

Any idea if it's possible with a shape to use the selected area instaead of the entire page ?

Thanks

Yacine

I wonder how you would avoid macros, but compare it to the range method in Excel.

Without selection by macro: iterate over each shape in activewindow.selection

With selection by macro: draw a temporary rectangle in the desired area and check which shapes it overlaps by using the spatialneighborhood function.
Yacine

mlussier

That's my problem, I can't iterate trough the shapes of the selection since the selection will be my list shape but I want to populate my list with a selection on the page. With a macro it would be easy but they say we have to much macros.
Or I need to change the way I populate my list, but I don't know how I could do this without a macro.
The best way i found was the Excel range selector but I don't think there is such thing in Visio.

Yacine

#11
I'm confused.
The constraint to avoid macros comes probably from the wish to minimize the commands to remember, not the actual amount of macros.

So to give the impression that no more macros were written, modify the current one:
- instead of scanning directly the page, let a non-modal dialog pop up, which would ask the user to select the area to scan and inform him (the user) that if no selection is made, then the whole page is scanned. Once the scan button is hit, hide the dialog and do whatever needs to be done.
- Voila!

----
PS: Triggering the list macro from a selection of shapes could also be possible, but then you would need to implement the call of the macro from the shapes themselves. This is the less elegant method because you rely on the proper setup of the shapes. By the way: the shapes could be prepared by a macro at page level, instead of the stencil.
Yacine

mlussier

Thanks for your answer I will go with the modeless window and let the user select shapes. It might be the simpliest way to do what I need to do.

Browser ID: smf (possibly_robot)
Templates: 4: index (default), Display (default), GenericControls (default), GenericControls (default).
Sub templates: 6: init, html_above, body_above, main, body_below, html_below.
Language files: 4: index+Modifications.english (default), Post.english (default), Editor.english (default), Drafts.english (default).
Style sheets: 4: index.css, attachments.css, jquery.sceditor.css, responsive.css.
Hooks called: 359 (show)
Files included: 34 - 1306KB. (show)
Memory used: 1192KB.
Tokens: post-login.
Cache hits: 14: 0.00295s for 26,715 bytes (show)
Cache misses: 4: (show)
Queries used: 16.

[Show Queries]