Image Placeholder

Started by thalantyrdsl, July 12, 2017, 10:13:45 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

thalantyrdsl

Hi there,

First time poster.

I currently work through building plans for a fibre company. As a part of the plans I provide them, we send photos of the route we're going to use.
At the moment I try to keep all photos that I take in portrait mode, drag and drop them into Visio, align them, etc.
The downside is that each page has x8 photos of it and I'd prefer not to have to re-align photos every time I added them to Visio.

I was wondering if there was a 'placeholder' shape/stencil that could be inserted, where you then click it and browse to the image you want to add, which then auto re-sizes to that shape size?

Please let me know if I need to explain it better.

Thank you.

wapperdude

Visio 2019 Pro

thalantyrdsl

Most of that involves selecting and aligning things. I wanted to try and avoid that work every time I insert pictures.

Please see below some better pictures in what I'm trying to do.

Picture #1 is how the end result works out.
Picture #2 is somewhere along the lines of what I'd like, which are shapes locked in place, but allow me to insert a picture somehow, and auto-size it to the size of that shape.

Thank you.

wapperdude

That's doable, well, pretty sure.  Takes some code development.

Which version of Visio?

My initial thought is something like this...
1)  place 8 shapes / containers on the page as placeholders like you've shown.
2)  drop your picture on the page...the mouse should be within one of the placeholders...that will be picture center
3)  use spatial relations to determine which shape geometry contains the picture center.
         (Other techniques are possible)
4)  set pic Pin X & Pin Y to be center of contAiner
5) resize picture to fit within container boundaries.

That would be it.  The macro automatically fires when picture is dropped on the page.

Wapperdude
Visio 2019 Pro

thalantyrdsl

Thank you for the reply. I understand about half of what you've put above, which is promising that it may be possible.
In terms of the next step forward, is this something that I'd need to engage a coder or Visio expert to do? Freelancer.com?

wapperdude

Do you do any coding at all?

Your next step depends upon your urgency.  Among the volunteer contributors at this forum, there are several that are capable of such coding.  But, their time is limited and sporadic.  So, it could take a couple days, or more.  Not sure how you might secure someone one on a commission basis.

Wapperdude
Visio 2019 Pro

thalantyrdsl

I don't do this sort of coding. I'd be limited to HTML/CSS and it's been a while since I did any coding work.
I'm not in a huge hurry. This is more of an efficiency thing to speed up the plans I do and also ensure they're nice and clean.

How would I go about requesting someone from the forums take a look over this? Thank you.

metuemre

Here is a simple template as starting point. You can improve it if you like

wapperdude

#8
Most impressive!  Simple indeed! :D  Yes simple to use, but the development and code was hardly simple.  You pulled this together in amazingly short order.

Nice job metuemre.  Works very well.

wapperdude
Visio 2019 Pro

Yacine

#9
I also got inspired by the question and used Wapperdude's idea of a container.
Otherwise the same image handling as metuemre.

At the same time I solved the issue of the "relationships" issue, which fires only ones. The trick is to catch the modifaction by a dependson call, do all the necessary handling, then delete the value in the relationsships field. It's now empty again and reacts to new drops. http://visguy.com/vgforum/index.php?topic=4554.0


Yacine

wapperdude

Well, how could I resist?!?

Naturally, I had to take a different approach.  The idea is any page may be used.  Assumes page is blank, i.e., no shapes.  It also assumes the target (final) shape width and height.  These are hard coded, but could be adjusted.  Finally, it defines the picture locations.

Any shape or picture may be dropped.  These are automatically placed left to right, top to bottom.

Doesn't use a mask shape or containers...(for those of us in the dark ages.)

Enjoy!
Wapperdude
Visio 2019 Pro

thalantyrdsl

Wow guys. Thank you very much. I just got back to this post and am going over what you put together. Thank you.

thalantyrdsl

Quote from: metuemre on July 13, 2017, 10:28:37 AMSolution

Thank you Metuemre. When I try to run the script that you wrote I get the attached error regarding a 64-bit operating system. I'm unsure how to approach this.

Quote from: Yacine on July 13, 2017, 04:50:32 PMSolution

Thank you Yacine. This is very easy to use. I think I need to make a few adjustments to the sizes so that it fits perfectly for photograph dimensions.
When I currently drop in a 480x640 image it sizes it smaller than the actual bounding box, both vertically and horizontally.
How would I get to the code to look at if this is easy to re-size the dimensions so the dropped image fits perfectly?

Quote from: wapperdude on July 13, 2017, 07:04:34 PMSolution

Thank you Wapperdude. I'm having troubles getting the image to drop into any of the actual shapes.
I drag and drop the image from outside Visio in and then try to move it over the top of the shapes but it won't snap in.
Am I looking at your solution from the wrong point of view? Thank you.

wapperdude

For my solution, the template shows example of final solution.  As mentioned, start with a blank drawing page, either delete the shapes on the existing page, or merely add a page.  Then, just find a picture you want drag, drop, release.  It places and resizes itself.  It's a rather simple approach, and lacks the flexibility of the others.  Specifically, it merely counts shapes and places them in a pre-arranged order.  So, if you delete a shape, it won't drop to the empty spot.  My goal was pure simplicity.

As for Metuemre's solution, I'm surprised there's an issue.  The code is involved, so I didn't go thru it.  It did run just fine on my PC, which is a 64 bit machine.  I'm assuming you're running 32 bit.  First thing to try is re-saving the file on your machine.  Then try to run that.  Might clear up the 32 / 64 issue.

As for Yacine's approach, I cannot look at it, as it is for newer Visio versions.

For any of these approach's, once the Visio file is open, if you press <alt> + F11, that will bring up the VBA window.  Typically, in left column, you'll see Visio Objects > ThisDocument.  Dbl click ThisDocument and you'll see the code in the right window.

Wapperdude.
Visio 2019 Pro

thalantyrdsl

Quote from: wapperdude on July 14, 2017, 03:39:10 AM
For my solution, the template shows example of final solution.  As mentioned, start with a blank drawing page, either delete the shapes on the existing page, or merely add a page.  Then, just find a picture you want drag, drop, release.  It places and resizes itself.  It's a rather simple approach, and lacks the flexibility of the others.  Specifically, it merely counts shapes and places them in a pre-arranged order.  So, if you delete a shape, it won't drop to the empty spot.  My goal was pure simplicity.

Ahhh. I see what you mean. That's quite handy. I also see what you mean by it not dropping into an empty spot. I deleted a few and it'll place it on top of another, etc.

Quote from: wapperdude on July 14, 2017, 03:39:10 AMAs for Metuemre's solution, I'm surprised there's an issue.  The code is involved, so I didn't go thru it.  It did run just fine on my PC, which is a 64 bit machine.  I'm assuming you're running 32 bit.  First thing to try is re-saving the file on your machine.  Then try to run that.  Might clear up the 32 / 64 issue.

I'm definitely running 64-bit Windows 10, with Visio 2013. I've tried opening both the .VSD and .VSDM files, which open fine, but when double-clicking it gives the previous error. I may be doing something wrong here? Macros seem enabled. I've tried to re-save it on my machine, re-enable macros and it gives the same error unfortunately.

Quote from: wapperdude on July 14, 2017, 03:39:10 AMAs for Yacine's approach, I cannot look at it, as it is for newer Visio versions.

This one seems to work the cleanest so far, but has sizing issues, which I believe can be very easily fixed.