Visio Guy

Visio Discussions => General Visio => Topic started by: Dusty_Rhodes on March 04, 2019, 10:49:52 AM

Title: Tag position on created master shapes
Post by: Dusty_Rhodes on March 04, 2019, 10:49:52 AM
Hello smart people.

I am having a problem that should be easy to fix (i think/hope) but i cant wrap my head around it. When making diagrams i want to have component tags (this works great on the shapes that come with visio) but the component tags for my own shapes always end up in the wrong location (often the middle) see the image. I would wantt he tag to be below the symbol like it is for the valve.
Title: Re: Tag position on created master shapes
Post by: Paul Herber on March 04, 2019, 11:18:47 AM
Are you creating your shapes from scratch or editing a pre-existing shape?
I'll guess that you need to look at the Text Transform section of the shape's shapesheet.
Title: Re: Tag position on created master shapes
Post by: Dusty_Rhodes on March 04, 2019, 01:37:28 PM
Hello Paul

Most shapes have been created from scratch about 80% i would say and then 20% are pre-existing shapes that have been edited. The image shows how i have been defining the tag format for the master shapes: i choose the stencil i want to edit, then the shapes in it i want to add the correct tag format to. Afer the tags have been added it is in the middle of the shapes not underneath.
Title: Re: Tag position on created master shapes
Post by: Paul Herber on March 04, 2019, 02:50:27 PM
I would say that you need to copy the Text Transform section from a shape that works.
You maybe also need to copy any text formatting.
Title: Re: Tag position on created master shapes
Post by: Dusty_Rhodes on March 04, 2019, 05:25:29 PM
Hello Paul,

The suggestion you made worked great in moving the tag position. But do u know if there is a way to change multiple shapes at once instead of needing to manually do it for every shape ? I have around 100 shapes this is needed to be done for.
Title: Re: Tag position on created master shapes
Post by: wapperdude on March 04, 2019, 05:34:56 PM
If you upload the shape, it would be easier to advise.

From the picture, the "tag", looks like the text, "E - 5".  Yes?  Is this just text?  If so, it looks like (a) the font size is too large and Visio is wrapping the text into multiple lines.  Reducing the font size will help.  (b) The block may need editing.

To edit the text block, select the shape and then, from the GUI, Home tab > Tools section > Text Block tool.  You can resize and reposition the text block as necessary.

A secondary text edit option is the Home tab > Paragraph.  Expand the section (lower right corner), select the Text Block tab and then decrease the left / right margins.  Sometimes, by reducing font size and changing margins is enough to avoid text wrapping without using the Text block tool.

Finally, as Paul indicated, there are additional steps for positioning / sizing the text block in the Text Transform section.  The above, previous steps, ought to be enough without direcctly involving the Text Transform section.
Title: Re: Tag position on created master shapes
Post by: Dusty_Rhodes on March 04, 2019, 06:57:39 PM
Hello the tag is for Piping and instrumentation diagrams (the tag feature is default for valves anf components in the template that comes with Visio). I have attched a stencil with only 3 shapes ( the valve works as it should the other 2 does not work correctly with the tag format).
Title: Re: Tag position on created master shapes
Post by: wapperdude on March 04, 2019, 08:11:52 PM
Looked at your shapes.  There are a number of things that need changing:
1) Font size needs to be reduced to 6 pt.
2) Need to add a Control point to set position of tag text.  See an existing shape.
3) Need to edit Text Transform cells:  TxtWidth, TxtHeight, TxtPinX, and TxtPinY.  See an existing shape.


As far as editing the shapes:
1)  Edit the shapes in the doc stencil.  These will flush upward into the drawing shape.  Also, copy edited shape and replace the stencil version.
or ...
2) Write VBA program to go thru the shapes and make the changes.  The macro recorder will give you a good start. 

Wapperdude
Title: Re: Tag position on created master shapes
Post by: wapperdude on March 04, 2019, 09:32:22 PM
Had some time, so here's the guts of a VBA program.  Most of this was derived from the macro recorder.  The captured code was cleaned up and simplified.

It only works on the selected shape.  For your entire document, you need to add a loop to go thru all pages, and then an inner loop to search all shapes on the page.  Plus, you need to add some sort of a test so that only shapes of interest are edited.


Sub Macro1()
    Dim vsoShp As Visio.Shape
   
'Need to loop thru all pages
'Need to loop thru all shapes
'Need to test to see if shape should be edited

    Set vsoShp = ActiveWindow.Selection(1)    'Assumes only desired shape is selected

'Assuming vsoShp should be edited:   
    With vsoShp
        .CellsSRC(visSectionCharacter, 0, visCharacterSize).FormulaU = "6 pt"
       
        .CellsSRC(visSectionObject, visRowTextXForm, visXFormWidth).FormulaU = "TEXTWIDTH(TheText)"
        .CellsSRC(visSectionObject, visRowTextXForm, visXFormHeight).FormulaU = "Textheight(TheText,TxtWidth)"
       
        .AddSection visSectionControls
        .AddRow visSectionControls, visRowLast, visTagDefault
        .CellsSRC(visSectionControls, 0, visCtlX).RowNameU = "TagPos"
        .CellsSRC(visSectionControls, 0, visCtlX).FormulaForceU = "Width*0.5"
        .CellsSRC(visSectionControls, 0, visCtlY).FormulaForceU = "Height*-0.3"
        .CellsSRC(visSectionControls, 0, visCtlXDyn).FormulaForceU = "Controls.TagPos"
        .CellsSRC(visSectionControls, 0, visCtlYDyn).FormulaForceU = "Controls.TagPos.Y"
        .CellsSRC(visSectionControls, 0, visCtlXCon).FormulaForceU = "0"
        .CellsSRC(visSectionControls, 0, visCtlYCon).FormulaForceU = "0"
        .CellsSRC(visSectionControls, 0, visCtlGlue).FormulaForceU = "TRUE"
        .CellsSRC(visSectionControls, 0, visCtlType).FormulaForceU = "0"
        .CellsSRC(visSectionControls, 0, visCtlTip).FormulaForceU = """"""
   
        .CellsSRC(visSectionObject, visRowTextXForm, visXFormPinX).FormulaU = "Controls.TagPos"
        .CellsSRC(visSectionObject, visRowTextXForm, visXFormPinY).FormulaU = "Controls.TagPos.Y"
   End With

End Sub
Title: Re: Tag position on created master shapes
Post by: Yacine on March 05, 2019, 12:04:17 PM
You may have a look at the tool I posted here: http://visguy.com/vgforum/index.php?topic=7461.0
Title: Re: Tag position on created master shapes
Post by: Dusty_Rhodes on March 11, 2019, 06:51:53 AM
Hello:

Thx Yacine the tool u uploaded worked great and i was able to use it to change the tag position of the shapes and update the master shapes. Now the tag position is correct when they are added to a new drawing  :) Cool stuff