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

Adjust shape handles to match object size

Started by harringg, August 29, 2024, 05:41:11 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

harringg

I'm using some stock stencils/shapes and they have a large box around them, such that when adding a Data Graphic value, it's too far from the object (for my liking).  I've adjusted DG to fit as close to the object as I can.  I went so far as to take a screen grab, paste that back as a new object, but it won't let me assign a Data Graphic value to it (The data graphic could not be applied to one or more invalid shapes in the selection).

I have dev mode enabled and wondering if there is a setting in shapesheet to adjust it in the original stencil?

The image below shows what it looks like (left most), what I'd like (center most), and the screen grab pasted as an image (right most).

wapperdude

Since you have Dev mode enabled, go to Operations in the Shape Design section.  There you will find Update alignment box.  Select it.  The box ought to contract to the size of your right most picture.

If you get a Shape protection error, you may have to open shapesheet.  Scroll down to the Protection section.  In the rt hand column, lock alien cell needs to be set to zero.  Doing so will remove the error reaction and allow reset of the align box.
Visio 2019 Pro

harringg

Thank you.  Neither of those worked.  No error was given, just didn't change.

The specific shape I'm working with is the built-in Network and Peripherals > Switch.

What I was able to do, was drag the stencil to a new page, drag it over to a custom Stencil Set I made.  Drag that back to the new page, and set ShapeSheet grouplock to 0.  Ungroup, and the re-group.  Now the text is closer to what I'm looking for.

I'll add connection points and data graphics, and save as a "new" stencil.

Paul Herber

Quote from: harringg on August 29, 2024, 09:23:54 PMUngroup

Never a good idea. This will almost certainly break the shape in ways that you might not see but will be critical. Edit the shape instead.
Electronic and Electrical engineering, business and software stencils for Visio -

https://www.paulherber.co.uk/

harringg

This use case the modified stencil scales properly. Agreed, ideally I'd like to bring in the handles on the stock stencil.

Since it's a built in stencil, if you are able to make it do so from my OP that'd be appreciated.


wapperdude

#5
There is no quick, global solution.  The stencil is just a repository.  The stencil does not impart characteristics to the shapes. 

So, having clarified that, the shapes can be modified, but it needs to be on a case by case basis.  So, the process can become quite tedious.

The method, proceeds, generslly, as follows. 
Let the group shape be sheet.1.  Contained in the group are 3 shapes, sheet.2...sheet.4. Each of these shapes will have formulas in their respective width and height cells relating to the group shape.  For example, sheet.2 height = sheet.1!height*0.5 and maybe sheet.3 height = sheet.1!height*0.25.  To make sheet.2 height = sheet.1 height, then change the formula to be sheet.1!*1.  All the other subshapes will need to have their formulas adjusted by the same factor of 2 in this example.  That is, sheet.3 becomes sheet.1!height*0.25*2 " sheet.1!height*0.5.  This results in a really weird looking shape.  The last step is to reduce sheet.1 height by 1/2.  So, its original of 1" becomes 0.5".  Now the shape is the correct size, everything has correct heights, and the bounding box is the size of the displayed shape. 

Because the editing retained the formula references to sheet.1, the grouping behavior is preserved...no ungrouping or re-grouping required.

Note, for these shapes, you need to go to Developer tab>Behavior.  Change the selection method from Group Only to Group 1st.
Visio 2019 Pro

Nikolay

#6
I think it depends on the structure of your shape. The white area you see may actually be a real shape (white rectangle or something).
Otherwise, the "Update Alignment Box" wapperdude suggested should have worked.

Could you share the shape with us to look at it?

wapperdude

#7
@Nikolay:  That was my initial reaction. 
The OP did provide name and source of shape.  The DEW indicated no other hidden shape forcing the large selection box.  It is just the way M$ designed it.  Looks like they gave all shapes on the stencil a standardized selection box size with no way of allowing it to resize to fit the subshapes. Whyyyy??? So, the only choices are un- & re-group, (bad idea as Paul already stated), or to edit without ungrouping.  Hence, the  provided details for doing that.
Visio 2019 Pro

harringg

Thanks for all the feedback.  In my use-case, it appears to be best to ungroup and regroup, realizing it's not the ideal solution.

wapperdude

Not advisable.

Some additional thoughts...
1) Make a new stencil.  Name it same as M$ stencil with your initials added to end of name.  This will contain your modified versions.

2) You can do whatever modifications you need, e.g., un- / re-group.  Save this new master to your new stencil using save as to give a name to shape that also has your initials.

3) This process may be automated using a macro.  The macro recorder could catch the steps of grabbing an original shape, doing your groupie thing, and then storing to new stencil.  End recording.
    > The macro will need some editting:
         >> To grab the original shape based upon selection...
         >> ...or to step thru all original shapes automatica.  This would be do it once and done.

Anyway, the new stencil gives you a permanent repository of edited shapes for future use.  Plus, it may be distributed for others to use.  It avoids confusion with existing M$ shapes via the name change.
Visio 2019 Pro

harringg

From my post above, I think that is what you are describing (1. Make a new stencil...), which I've done.  Thank you.

What I was able to do, was drag the stencil to a new page, drag it over to a custom Stencil Set I made.  Drag that back to the new page, and set ShapeSheet grouplock to 0.  Ungroup, and the re-group.  Now the text is closer to what I'm looking for.

I'll add connection points and data graphics, and save as a "new" stencil.

wapperdude

#11
Editing shape in drawing after it has been dragged and dropped from stencil does not edit the master shape on the stencil.  If you want your custom stencil to have edited shapes, do editing 1st and then place on the stencil. 

FYI:  What Visio does when drag N drop takes place is it makes a replica of the Master in the document stencil.  Future placements will be used from the doc.stencil.  This assures that when Visio file is moved or shared the necessary shapes for the drawing are available without having to include all of the associated stencils and superfulous shapes.

For what it's worth, I've included a macro that will do the ungrp/regrp steps and save to stencil.  It will need your editing to reference your custom stencil, and you may want to comment out the lines at the bottom for renaming and do that by hand.

Sub MasterEditnSave()
' This macro is crude design.
'
' ******** DANGER! Wil Robinson!!!
'It uses ungroup/regroup method to edit selected shape
' It ASSUMES that desired shape to be edited has been selected.
' ********
'
' It assumes that the target Custom stencil has been named and is loaded.
'
' It will rename the Master that has been dropped on the Custom template by
' using predefined name used at bottom of this macro.
'

    Dim vsoSelection1 As Visio.Selection
    Dim vsoDoc1 As Visio.Document
    Dim vsoMaster1 As Visio.Master
    Dim sel As Visio.Selection
  
      
'    Windows.ItemEx("Drawing1").Activate
'    ActiveWindow.Page.Drop Documents.Item("PERIME_U.vssx").Masters.ItemU("Scanner"), 4#, 8#
   
    Set sel = Visio.ActiveWindow.Selection
   
    If sel.Count = 0 Then
        MsgBox "No shapes are selected.  Select a shape."
        Exit Sub
    End If
       
    ActiveWindow.Page.Shapes.Item(1).OpenSheetWindow
    ActiveWindow.Shape.CellsSRC(visSectionObject, visRowLock, visLockGroup).FormulaU = "0"
    ActiveWindow.Close

    ActiveWindow.Selection.Ungroup
    ActiveWindow.SelectAll
    ActiveWindow.Selection.Group

    Set vsoSelection1 = ActiveWindow.Selection
'This is custom stencil previously created for this demo.  Change name to your stencil
    Set vsoDoc1 = Documents.Item("Peri_WAP.vssx")
    vsoDoc1.Drop vsoSelection1, 0, 0
   
'This assumes that orignal selected shape was "scanner"
    Set vsoMaster1 = Documents.Item("Peri_WAP.vssx").Masters.Item(1)
'Comment out this line to manually rename in custom stencil
    vsoMaster1.Name = "scanner_WAP"

    Documents.Item("Peri_WAP.vssx").SaveAs "C:\Users\wappe\OneDrive\Documents\Peri_WAP.vssx"

End Sub
Visio 2019 Pro

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: 344 (show)
Files included: 32 - 1207KB. (show)
Memory used: 1221KB.
Tokens: post-login.
Cache hits: 14: 0.00239s for 26,726 bytes (show)
Cache misses: 3: (show)
Queries used: 15.

[Show Queries]