Possible Project

Started by gajtguy, June 06, 2012, 04:05:21 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

gajtguy

Just wanting some feedback on whether this idea should be tackled, or if you experts feel it's got major hurdles or can't be done for some reason. And I'm not looking for anything but opinions, not for someone to write this for me. If I decide to start, then the specific questions will start pouring in. I do have a background in writing VB code for Office programs (mainly Excel), but not Visio. Which seems to be the one program in Office that does not conform like the rest of the office programs.

So my idea:
   Phase 1: To create a template file and custom symbols for doing electrical schematic drawings or security drawings. The main page would actually just have buttons which allow for additional pages to be added, renamed with a sequence number, and have some default shapes put on, based on which button was pressed on the main page. The user then can add additional shapes manually to the new page and connect them together as needed. Each added page would utilize a shared background, which is simply a title block. The title block would not be required on the very first page. That 1st page is more of a windows form anyway. But the title block would contain a 'pageName' reference field so each printed page could be identified easily.
  Phase 2: Utilize the above, but allow an automatic placement of additional shapes to the page, based on various manufacture codes entered in to an actual windows form. The program would receive a batch of codes from the user, then go seek out the best matching custom Shape which contains all of the items the person was asking for. I would create a library of custom shapes for this program to associate and search through.

Sounds like a pipe dream to me. But I feel anything is possible if you know the limitations. So let me know if there are any red flags to you guys on this one.  Or feel free to ask for clarification on something.

Thanks
Don't throw everything away. There is NO away!

Jumpy

Hi,
I'm not an expert jet, but tackeled a simmilar project a year ago, but with hydraulic schematas, and it is definitly doable. But it's a lot of work :-)

Phase1:
- Cerating shapes involves familiarisation with the ShapeSheet, so you can create smart shapes
- Lots of tips & tricks about that here in the forum and on the Visio Guy site.
- Instead of the first page with buttons, you could use a Winform, like you said, and/or you can create your own customized menu-bar or contextmenus
- One background page with titleblock for all pages is possible, only information that may differ from page to page, would have to be placed on the actual page.

Phase2:
- Here you'll have to work a lot with VBA, but doable. Maybe not always easy, but no rocket science either.
- And again many infos in this forum and on many blocks from the Visio MVPs.

There will be many questions, like for example: where to place your code (in the template, in a stencil, in an AddOn). But you'll find good advice and answers to that kind of question here.

I advise to make shure what you want, and start asking question at an early stage, so you get a good start and don't run into dead ends, because of an fault in your design you made at an early stage.

hth Jumpy

JohnGoldsmith

Just adding to Jumpy's comments:

Where to store your code - This depends a little bit on how widely you need to distibute your solution and what version of Visio you're targeting.  If your intended audience is a small internal group then VBA would be a good route to follow.  It is very flexible and easy to debug/maintain.  If you want to distribute this more widely, perhaps to external customers, then a VSTO .Net addin provides a more robust solution in addition to making it  easier to protect your code (not really possible with VBA).  You might want to start in VBA, while you're still testing and establishing all the functionality, and then migrate to .Net later on when you're in a more stable state.

From what you've described I would be tempted to add your code to a stencil (.vss) that would be open for every document you create based on your own template.  That way you'll have a single instance of your code.

In terms of your idea for using the first page as a 'window', my preference would be to put this functionality into the UI (or display a Form via VBA).  David Parker has a good post on creating Document level ribbon controls if your using Visio 2010, which might be of interest to you:

http://blog.bvisual.net/2011/03/14/how-to-run-vba-macros-from-a-ribbon-button-in-visio-2010/

Otherwise you'll want to look at CommandBars:

http://msdn.microsoft.com/en-us/library/aa201791%28office.10%29.aspx


Other complex areas from your description include 'automatic placement' and 'search'. 

As far as placement is concerned, dropping a shape at a specific location is straight forward but 'layout' of shapes based on your own custom logic can get pretty challenging.  Where possible, I would try and stick using Visio's own auto layout algorythms.  Have a look at this for starters:

http://msdn.microsoft.com/en-us/library/aa201732%28office.10%29.aspx

Having reviewed the built-in layout options, if you still feel you need to implement your own logic, then have a go at manually laying out your shapes and make a note of every step that you take to get to a finished design.  The more you do this the clearer you'll be on the code required to automate the process.  This may sound obvious, but layout is not always clear when you start off.  Bear in mind that it might be worth splitting your layout code into multiple passes.  For example WPF and Silverlight have two passes for their layout system - the first one measures each of the elements to get a desired or calculated size and then the second does the actual arrangement based on values in the previous pass.

For your search functionality it would depend on what you intend to do with the shapes that are returned by your logic.  For example:

Would you automatically place all of the shapes returned or just a selection?  This would clearly have an impact on layout and you'd have to decide on when you called you re-layout.

Would you present the user with a selection of possible (shape) candidates, and wait for them to manually drop them on the page?  If that's the case how would you want to present the returned shapes and how would the user then drag / drop them onto the page.  Graham Wideman looks at drag drop from places other than stencils in his book:

http://diagramantics.com/v11dsp/index.htm

Anyway, as Jumpy says it's all doable, but there'll be lots of choices along the way.  I would start with your phase one and decide on what part would benefit most from automation.

Hope that helps.

Best regards

John
John Goldsmith - Visio MVP
http://visualsignals.typepad.co.uk/

gajtguy

Thank you both for the replies and guidance. I have some lite reading to do, but excited about jumping in a trying some things out.
Don't throw everything away. There is NO away!