Automate adding connection points at prescribed dimensions

Started by RudySchneider, February 03, 2015, 02:37:11 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

RudySchneider

Greetings, from sunny (for now) California ---
I've created a few custom shapes to aid producing electronic schematics and block diagrams.  I am attempting to create a macro to automatically add connection points at prescribed dimensions (for instance, the first point would be 6mm down, subsequent points would be every 10mm down) along one or both edges of a selected shape, based on its height (which varies in 10mm increments).  Since I'm using snap-to-grid, I could of course add the points manually, but that gets a bit tedious when creating so many different-sized shapes.  Moreover, if I need to re-size the shape, I need to maintain this 10mm separation, rather than having the connection points "stretch" or "compress."

I have toyed with the shapesheet to insert specific dimensions for the connection points rather than percentages, which works well.  So, what I'm after definitely seems doable.  I recorded a macro of manually placing a connection point, and am attempting to edit the code through trial-and-error and information I've gathered from the web.  But in the interest of possibly saving some time, and actually learning something more, I thought I'd "reach out" for some help from those far more knowledgeable than I.

Best regards --- Rudy
There are no problems, only opportunities

Yacine

Hi Rudy,
greetings back from grey German winter. Welcome in the forum.
There are several "electric" guys in the forum and much more others eager to provide help. You'll certainly enjoy the forum.
From what I read it is difficult to write something meaningful. I could imagine, that you either reformulate your post with a clear question, or upload your work and ask for critics.


Regards,
Yacine
Yacine

RudySchneider

#2
Yacine ---
Thanks for the welcome.  And perhaps my request does need a bit of clarification.  I have been poring over the internet and the various Visio-related forums, and am surprised a shapesheet or stencil doesn't already exist for this feature!

Attached is a picture of the shapes on which I'm working.  The top shape is a connector, whose height automatically adjusts by the number of "paragraphs."  I use actions to specify whether the shape is positioned below the top row or above the bottom row (label on top versus label on bottom), whether the shape faces left or right, and whether it has curves or not.  The macro I'm trying to create would automatically place (the correct number of) connection points on either side of the numbers inside the shape.

The bottom shape is similar, but (obviously) for a horizontal orientation.  In this case, I rely on center tabs to place the numbers in place of paragraph returns.  The primary problem with this shape is that in order for the label" to appear in the correct location, it relies on a right tab.  Obviously, this means the very first text character must be a tab character.  Also, unlike the top shape, moving the "label" to the right side of the shape means this tab formatting needs to be changed.  I'd be curious to know if you have any recommendation for work-arounds for these issues. 

Best regards --- Rudy
There are no problems, only opportunities

wapperdude

Hi Rudy...

Creating shapes can be a simple process or quite involved depending upon the features that you desire.  So, as you've discovered, it is possible to give the connection points literal coordinates.  It is possible to automate that task by writing a macro to do so.  However, creating the macro can become quite involved.  For example, how do let the macro know how many connection points?  Consider your horizontal shape.  Will the spacing from the left edge to the first connection point always be the same, or can it vary?  Macro needs to know that.  Should the macro also draw the shape or merely place the connectin points?  Will there be one row or two rows of connection points?  Do you want a single shape that is smart and knows how to adjust the text based upon orientation or perhaps two views:  one for horizontal and one for vertical.  Many decisions to make in creating a part generating macro. 

Regarding the text orientation as the shape is rotated, the justification of the text can be handled in the shapesheet, specifically, in the Text Transform section.  You need to use conditional "IF" statements to analyze the "angle" of the shape to set the justification and text rotation, and any other attribute that might be impacted, e.g., TxtPinX, TxtPinY, etc.  In addition, you may want to use the "Bound" statement to limit the shape angles to be only 2 possible choices:  0 deg and 90 deg, everything else being derived by flipping X or Y.  See this link for a more thorough treatment on text behavior:  https://msdn.microsoft.com/en-us/library/aa200986(v=office.10).aspx

Many schematic capture programs provide just two views as mentioned above, and then allow the part to flip either vertically or horizontally.  The text properties become much similar in this scenario, but, it does require, potentially, two instantiations of the symbol.

Paul Herber has a huge selection of electronic symbols.  You may want to explore those, too.

HTH
Wapperdude
Visio 2019 Pro

RudySchneider

Wapperdude ---
You're preaching to the saved.  I'm well aware of, and am incorporating, constraints on both text and shapes.  That's precisely why I'm creating this shape as a "tool," which will exhibit consistent behavior each time it's used.  And yes, the number of connection points is governed by the constrained size of the shape.  For instance, as I initially described, for the vertically-oriented shape, the first connection point will always be 6mm from the top, each subsequent connection point will be 10mm down.  The number of connection points will be based on the shape height.  The minimum height is 12mm (using BOUND), and can "grow" in 10mm increments.

As the attached .vsd illustrates, working with the text is not really a problem.  I've constrained the size of the shapes based on the textual content within the shapes so that it is consistent.  The vertical connector is more refined than the horizontal one at this stage.
There are no problems, only opportunities

wapperdude

#5
 ;D

Well, faith, without works...    ;)   

And now I see some of your works!  OK.  Now I'm confused.  So, what you're looking for is to see if there's an easier way to do what you've done...which I presume means a macro???  You mentioned macro recorder and editing that macro.  That's a good way to start.  But, there's no macro attached, so, it's difficult to make any pointers in that regard.

I guess one question would be, are you willing to do a grouped shape?  If so, then I would suggest making the Reference Designator text separate from the pin text.  That way, when you shift text top/bottom, you only have to relocate the reference designator and not mess with the pin text.  That could save a lot of effort.  But, going with what have, you only need to change the order of the text in the text box.  Certainly do-able...use "IF" statement to arrange the text as desired.  This could be done in the Insert>Field>custom formula.  Specifically, you could enter the following formula:  IF(Scratch.C1=1, "1" & CHAR(10) & "2" & CHAR(10) & "3" & CHAR(10) & "J1", "J1" & CHAR(10) & "1" & CHAR(10) & "2" & CHAR(10) & "3")  It looks like you're already shifting the text as needed.

That's about the only functional thing I see. 

BTW, where abouts CA?  I'm in the LA area.

Wapperdude
Visio 2019 Pro

RudySchneider

#6
Wapperdude ---
Yes, the shape adjusts itself fine around the text.  And the reason why I don't care to uses a grouped shape is because there will be times when there won't be a label needed, but unless any other user doesn't know that, he/she may be hard-pressed to insert one into a shape he/she's copied from it.  THis way, there will at minimum be an obvious placeholder for the label.

Thanks for that additional bit of info.  I think it'll help me complete the horizontal shape tool.

Regarding the "automated" placement of connection points --- which was my original question --- the VisioGuy forum wasn't the only avenue I pursued.  I also contacted David Parker at bVisual (http://blog.bvisual.net/).  He came up with a way to do what I'm after without using a macro.  Once I get the horizontal shape sorted, I'll post the final .vsd, just in case it might be useful for someone else.

Moving on...

[edit]... Oh, and I live in Boulder Creek among redwood trees, just "over the hill" from Silicon Valley, where I work.
There are no problems, only opportunities

wapperdude

Ah yes!  David Parker was my first contact with a Visio MVP for a problem I had.  He was key to expanding my understanding of the inner workings of Visio.

Just a thought re the reference designator...
QuoteTHis way, there will at minimum be an obvious placeholder for the label.

You can always indicate something like "J#" as a placeholder.  Your shape can have a data property that would request a designator number from the user upon drop on the page.  Then you have multiple options:  1.)  Always show the J#, making the user add a number, or 2.) using an action entry to show/hide the reference designator, or 3.) let the field be blank (similar to how the connector text works) and automatically hide the text.  If you used a separate text box for the reference designator, options (2) and (3) would be fairly straight-forward.  With your current approach, you would have to enter null text to hide the reference designator.  The other feature that the separate text box provides is the user can move the ref des, using, say a control point, to manually position the text.

Just throwing some ideas out for your consideration.

Wapperdude
Visio 2019 Pro

RudySchneider

Yes, of course a "J#" placeholder, and some of your other suggestions can work for a shape that's in the stencil.  That's a no-brainer.  But tell me this: once you've moved a shape from the stencil onto your working page, how often do you go back to the stencil rather than simply copy and paste the shape on your worksheet?  And if the one you copied doesn't have a label --- and hence, the placeholder either doesn't exist any longer, or is a major pain to get to --- then what?

The whole point is, how a proper "tool" works should be obvious to anyone who uses it.  If only the person who created the tool knows how it works, it's only useful to him/her, and not a true tool.  Yes, it'll serve their immediate needs, but if it's a "shared" work, the tool better be intuitively obvious, or people will simply "force" it to look like they want it, much like Word documents (don't get me started on Styles!).

A Data Property and/or Action may be a better/alternative solution, especially for the horizontal case where I want the label on the right side.  But this again assumes that the next user knows about, knows how to use, and actually uses them.  Ahhh, in a perfect world.

What it seems to boil down to is a tradeoff.  I can get some of what I want, but not all of it.  Hmmm, just like life!

Oh, and by the way, rather than a Null, all I need to enter is a tab character to hide the label (or any other space where I don't want (a) character(s) to appear).
There are no problems, only opportunities

wapperdude

I agree that the shapes need to be user friendly...as much as possible.  But there does need to be a small amount of user awareness.  After all, there is a learning curve for every app out there, especially if you want to become more proficient.

I'm attach an example that is simple to the user, but, has some "smarts" to it.  Easier to have something to explore than to try and spend a 1000 words explaining.  The features are as follows:
  1.)  The shape has the ask the user for info on drop.  Note, this also applies for copy / paste operations.
  2.)  If the user double clicks the shape, the same ask for info pops up.
  3.)  Is a grouped shape to allow separate text boxes.
            a) In this case, the sub-shapes grab the group shape data to insert the text.  Text box grows with the amount of text.
            b)  When I made the shape, rather than just grouping, I drew the schematic symbol, then converted the shape to group.  All other shapes get added.
  4.)  Uses control points to position the text boxes. 
            a)  But, it could just as easily not use control points, but use "actions" to move the text to fixed locations.  E.G., place the text to left or right of shape.
            b)  The connection points are moved based upon which view is selected.  This could also be extended to the control points to set their initial position. 
  5.)  Also, at the same time, you can change the justification or whatever. 
  6.)  There are multiple geometries to switch between a schematic symbol or a layout symbol.
  7.)  If the Part Number field is left blank, its control point is not displayed, a la, connector text behavior.
  8.)  The connector points are "Named Connectors", available by just clicking change row type.  Uses the "D" cell, which could be grabbed for connectivity reporting.
   
Within reason, there are a vast number of things that can be done.  I tried to add various features to give you a chance to see what can be down, but not be overwhelming.  Here are a few more links that ought to be of value:

Shapesheet functions:  https://msdn.microsoft.com/en-us/library/ms427031.aspx
Elements of Formulas:  https://msdn.microsoft.com/en-us/library/aa200961(office.10).aspx  Be sure to scroll thru this one!
DOCMDS:  https://msdn.microsoft.com/en-us/library/aa342178.aspx  Commands available for the shapesheet are indicated in last column on right.

Of course, if you haven't already done so, there's the free download of the SDK, which is more towards programming, but also has a lot of useful info.

I think you'll find the above info useful.

wapperdude
Visio 2019 Pro

RudySchneider

Thanks, Wapperdude.  I'll check out those resources and consider your suggestions.

Right now, even if I don't come up with a consistent scheme for handling the shape label, I've definitely learned a way from David Parker to have connection points automatically populated at prescribed locations with fixed spacing (that doesn't grow or compress with shape re-sizing).  So, this exercise has already proven beneficial. 

BTW, I still intend to post a .vsd of what I consider my final "tools."
There are no problems, only opportunities

RudySchneider

Wapperdude ---
OK, I like your NPN transistor example.  That way, I can use one tool that automatically place connection points, specify whether the connector is horizontal or vertical and, if a label exists, allow the user to assign where it's positioned.

Now it's just a matter of editing (at least that's what it says in fine print)!

There are no problems, only opportunities

Yacine

Hi you both,
Your conversation was so intimate, I did not dear to join. But I kind of still stayed interested because it handles making stable smart shapes.
So sorry for the stupid question, but how are these shapes meant to be used? (I don't understand so much about electrical circuits).
Yacine

RudySchneider

Yacine ---
There is no such thing as a stupid question.

Here's a very simple example, showing the wiring between two connectors.
There are no problems, only opportunities

wapperdude

Hi Yacine,

Join the party!   ;D

Not sure what Rudy intends, but I see to potential uses.  1st, just. Cobble together a semi-dumb drawing, basically,  a quick diagram for show / tell or perhaps just capture an idea while it's fresh in your mind.   This would be an alternative to invoking a full fledged schematic capture program.

The 2nd would be to take the first, add alternative view which has scaled layout footprints.  So, once you hook up your circuit and are happy with it, switch to layout view, re-arrange parts to get an idea of placement and routing.  Add to that my earlier development and you can get a connectivity netlist list with some basic, rudimentary error checking.

Wapperdude
Visio 2019 Pro