Visio Guy

Visio Discussions => Shapes & Templates => Topic started by: maclarkson on September 11, 2019, 02:47:19 PM

Title: Guarded object within a group still grows
Post by: maclarkson on September 11, 2019, 02:47:19 PM
Hi all,

I am creating a new template that has icons in the top left-hand corner. I have attached my template. can anyone tell me the best way i can get them to stay where they are in relation to their objects and to not grow change position even if the text gets bigger or the shape srinks or grows?

Many thanks

Mike
Title: Re: Guarded object within a group still grows
Post by: wapperdude on September 11, 2019, 05:21:13 PM
There are at least 2 ways to do this...
1) most common:  select shape and icon and group.  This locks the icon to the shape.  Downside, extra shape added per each grouping.
2) less common:
     a) select shape and convert to group.  No extra shape, and the shape is the group.
     b) ribbon>Developer tab>Shape  Design (Behavior); set Group Behavior (Group Data) = Behind member shapes.
     c) with main shape still selected, add icon selection, then Add to Group.  Icon locked to shape.  Takes a few more steps, but, I think this is cleaner.

Based upon method (2):
Now to lock size and position:  open shapesheet for icon.
We will need literal size and positions, not values based upon width, height formulas!
>>  Set shapesheet to display values.
>>  Size:
          ** Width:  enter guard(actual value), e.g. guard(0.5 in)
          ** Height:  do the same

>> Position:  note, we want the icon's position to be fixed relative to left and top edges of main shape, regardless of its size and placement.
          ** PinX:  =LocPinX + some Xoffset value
          ** PinY:  =Sheet.1!Height*1 - (Height-LocPinY) - some Yoffset value  Where Sheet.1 is the main shape.  This will change with each icon/shape pair.  Note, for method (1), use the group name, Sheet.whatever, instead of the main shape name.

That should take care of it.
Title: Re: Guarded object within a group still grows
Post by: vojo on September 11, 2019, 06:23:16 PM
Couple other options

a)    width cell = guard(width*1 - 20mm),  Height cell = guard(height*1 - 30mm)
       Placement will be locked as an offset from the northeast corner of the mother shape

b)    Be careful about guard     Width cell = guard(width *0.74).   In this equation, guard is defeated.
       so be careful about using guard this way.
Title: Re: Guarded object within a group still grows
Post by: wapperdude on September 11, 2019, 06:38:33 PM
...and for Method3.  For completeness.  See http://visguy.com/vgforum/index.php?topic=5167.msg20306#msg20306 (http://visguy.com/vgforum/index.php?topic=5167.msg20306#msg20306), reply #12.  This allows the option of moving the icon, but, it will track the new location.  Just adds some flexibility.
Title: Re: Guarded object within a group still grows
Post by: wapperdude on September 11, 2019, 10:37:59 PM
Wrote a little program to go thru the method2 steps.  It requires that the main shape be selected first.  Also, the offset spacing is hard coded at the moment, = 0.125".

This ought speed things up. 
Title: Re: Guarded object within a group still grows
Post by: maclarkson on September 12, 2019, 01:32:54 PM
That's Awesome, a terrible amount of work but I am getting through it. Would you know how i could create an action to hide the icon using a right-click menu item?
Title: Re: Guarded object within a group still grows
Post by: wapperdude on September 12, 2019, 02:24:59 PM
Not difficult.  Could be added to the code...

The steps would be...
1) select Main shape
2) open shapesheet and add Actions Section
3) add new action, duh!
   This Action would point to the Geometry section of the Icon shape.  In the header that section, there's something like hide all.  This needs to get toggled true/false, i.e., 1 or 0.

Since there's a few steps involved, and there's a lot of shapes, recommend doing this in code.
You can use macro recorder to get the necessary code syntax.  Adding it to furnished code could happen at end of macro.  Plus, there are two existing  variables that refer to the shapes:  vMain and vIcon.
Title: Re: Guarded object within a group still grows
Post by: wapperdude on September 12, 2019, 03:24:36 PM
Here's updated code:

Sub Macro1()
'Select the "Main" shape.  Macro will find the iCon shape
'and the code will convert Main to group and add iCon.
'Finally, macro stores formulae into iCon to lock size and position.
    Dim intTolerance As Integer
    Dim vsoReturnedSelection As Visio.Selection
    Dim strSpatialRelation As String
    Dim intSpatialRelation As VisSpatialRelationCodes
   
    Set vMain = ActiveWindow.Selection(1)
    vMain.ConvertToGroup
    vMain.CellsU("DisplayMode").Formula = "1"

    strSpatialRelation = ""
    intTolerance = 0.05
    intSpatialRelation = visSpatialContain
    Set vsoReturnedSelection = vMain.SpatialNeighbors(intSpatialRelation, intTolerance, 0)
    For Each vNbr In vsoReturnedSelection
        Set vIcon = vNbr
        ActiveWindow.Select vIcon, visSelect
    Next

    ActiveWindow.Selection.AddToGroup

    vIcon.CellsU("Width").Formula = vIcon.CellsU("Width").ResultStr(visNone)
    vIcon.CellsU("Height").Formula = vIcon.CellsU("Height").ResultStr(visNone)
    vIcon.CellsU("PinX").FormulaU = Chr(34) & "LocPinX + 0.125" & Chr(34)
    vIcon.CellsU("PinY").FormulaU = Chr(34) & vMain & "!Height*1-(Height-LocPinY)-0.125" & Chr(34)

    vMain.AddSection visSectionAction
    vMain.AddRow visSectionAction, visRowLast, visTagDefault
    vMain.CellsSRC(visSectionAction, 0, visActionMenu).RowNameU = "HideIcon"
    vMain.CellsSRC(visSectionAction, 0, visActionAction).FormulaU = "SETF(GETREF(Actions.HideIcon.Checked),NOT(Actions.HideIcon.Checked))"
    vMain.CellsSRC(visSectionAction, 0, visActionMenu).FormulaU = "IF(Actions.HideIcon.Checked,""Show Icon"",""Hide Icon"")"
    vIcon.CellsSRC(visSectionFirstComponent, 0, 2).FormulaU = "IF(" & vMain & "!Actions.HideIcon.Checked,1,0)"


End Sub
Title: Re: Guarded object within a group still grows
Post by: wapperdude on September 12, 2019, 07:28:29 PM
Looked at your file more closely.  The Icon is a grouped shape.  It does not have a geometry section.  Thus, there is no shapesheet fcn to implement show hide feature.  That will require using code.

Edit:  There is a work-around.  Add a rectangle slightly larger than the Icon shape.  This could be either a separate shape or added to the Icon group as the upper most shape.  Then set the color to the same color as the Main shape and FillPattern to solid.  The line could be set to no line.  In the Main shape, add the Action command to toggle the Icon between Show and Hide.  This action would toggle the new rectangle's Geometry1.NoShow cell between True and False.  Because of the matching color, it effectively hides the Icon.

Not a perfect solution, but does accomplishe the desired visual effect.
Title: Re: Guarded object within a group still grows
Post by: wapperdude on September 12, 2019, 07:50:20 PM
Here's updated code which will loop thru all shapes on the active page and create the desired Main/Icon grouping.
Sub Macro1()
' Macro runs thru all shapes on a page.
'Finds qualified Main/Icon pairs, creates grouping
'
    Dim intTolerance As Integer
    Dim vsoReturnedSelection As Visio.Selection
    Dim strSpatialRelation As String
    Dim intSpatialRelation As VisSpatialRelationCodes
   
    strSpatialRelation = ""
    intTolerance = 0.05
    intSpatialRelation = visSpatialContain
   
'    Set vMain = ActiveWindow.Selection(1)
    For Each vMain In ActivePage.Shapes
        'check to see if shape has containing neighbor.  If so select it.  Then get
        Set vsoReturnedSelection = vMain.SpatialNeighbors(intSpatialRelation, intTolerance, 0)
        If vsoReturnedSelection.Count = 1 Then
            Debug.Print "Main shape:  ", vMain.Name
            ActiveWindow.Select vMain, visSelect
            vMain.ConvertToGroup
            vMain.CellsU("DisplayMode").Formula = "1"
            For Each vNbr In vsoReturnedSelection
                Set vIcon = vNbr
                ActiveWindow.Select vIcon, visSelect
                Debug.Print "Icon:  ", vIcon.Name
            Next
               
            ActiveWindow.Selection.AddToGroup
       
            vIcon.CellsU("Width").Formula = vIcon.CellsU("Width").ResultStr(visNone)
            vIcon.CellsU("Height").Formula = vIcon.CellsU("Height").ResultStr(visNone)
            vIcon.CellsU("PinX").FormulaU = "LocPinX + 0.03125"
            vIcon.CellsU("PinY").FormulaU = vMain & "!Height*1-(Height-LocPinY)-0.03125"
       
        End If
        ActiveWindow.DeselectAll
       
    Next
End Sub
Title: Re: Guarded object within a group still grows
Post by: Yacine on September 13, 2019, 07:08:52 AM
You could also use this tool:

http://visguy.com/vgforum/index.php?topic=7120.0
Title: Re: Guarded object within a group still grows
Post by: maclarkson on September 14, 2019, 11:02:42 AM
Yasin lovely tool  :'( i just spent 5 hours doing it all by hand and just read your reply  :'(. O well her is the final outcome of the icon.

Title: Re: Guarded object within a group still grows
Post by: Yacine on September 15, 2019, 01:20:16 PM
Yes, sorry for my late answer. Unfortunately the search tools are still very limited. Good luck anyway.
Title: Re: Guarded object within a group still grows
Post by: wapperdude on September 15, 2019, 08:54:42 PM
Also, the revised code that was provided does the same shape "locking" on All of the shapes at a single pass.  Tried and executed on your file.  So, 1 min to install the code (copy / paste), and 1 or 2 seconds to run.  That was a day before Yacine's post. 

Yacine's Tool is quite handy, even with the bugs, and is more general purpose/universal than my code...which was developed for this specific case. 

It would take a bit of code development, but it would be possible to create a shapesheet action to show/hide the icons.  Perhaps Yacine would modify his tool.  At the group top level, create an action entry to execute show hide.  Then drill down to each &  every sub shape and set the Geometry1.No Show to respond to the group Action setting.
Title: Re: Guarded object within a group still grows
Post by: maclarkson on September 15, 2019, 09:57:30 PM
Hay Wapper I tried using your code on an old version and for the life of me couldn't get it to do anything. I have firstly grouped each icon. Do in need to do something to these to make them identify as icons, like changing the behaviour. I have the main object I have done nothing to these. Do in need to do anything to these? Should I then group an icon once I have done something with it and object together and then run you code?
Title: Re: Guarded object within a group still grows
Post by: wapperdude on September 16, 2019, 12:29:57 AM
My computer just went belly up...think an SSD drive failed.

I believe all I did was make a working copy of your vsdx file.  Added the code into This Document.  Then ran the code..  There were 3 main shapes on the left side that failed.  They were grouped...don't know if that was something I did during code debug or if they came that way.  All other shapes passed fine.

Don't be shy when code doesn't work...just let us know.  Sorry you had to spend long time on this.

I'll update if I can get my computer to boot.
Title: Re: Guarded object within a group still grows
Post by: vojo on September 16, 2019, 01:48:43 AM
Sorry to hear that!!

Being a storage guy, I have seen a lot of issues SSDs, but they were all FW design issues.  I have never seen an actual SSD wear out.  The only thing I can think of is that if the PC is powered off for 30 days or so, it will lose data (SLC is more like a year, but QLC is more like few days).  Also, if the drive is older, its more likely to wear out because of write leveling (moving data around in the FLASH - there is a virtual LBA <=> physical LBA mapping that is always updated - in order to find FLASH cells with some writes still available)

Windows usually have a backup boot sector if primary fails - a good BIOS will automatically try the backup if primary fails, I take it the issue is access to ANY of the SSDs LBAs...not just regions of the SSD.  The FW quality varies by vendor (Samsung is so good, they don't answer any calls from developers trying to build a solution around them).

FWIW, there are SMART tools that can interrogate the SSD to check its view of status (if drive thinks its actually worn out, etc)
Of course, have to ask the perpetual question:  "no recent FW updates?"

Lastly, put linux on a USB key, get system up with that, then poke around the drive to see if readable at all.
If so, ghost the drive to another drive.

Hope it works out for you.
Title: Re: Guarded object within a group still grows
Post by: wapperdude on September 16, 2019, 02:13:52 AM
The PC has 3 dad's.  One, a Seagate, is the oldest, working fine.  The other two are relatively young.  The C-drive is fine.  The D-drive, is 1TB, and is the problem.  Windows went into auto repair on the drive and locked up.  Because it thinks the drive has corrupt file system, I can't get past this point.

Computer is my main computer, so never off for more than 24 hours.  Somewhere, I have an image and bootable USB thumb drive.  As this just happened, haven't had much time to sort things out.  All else fails, I'll yank the drive.

Thanks for suggestions I'll take a look at those.
Title: Re: Guarded object within a group still grows
Post by: maclarkson on September 16, 2019, 12:20:49 PM
Thanks for all the help
Title: Re: Guarded object within a group still grows
Post by: maclarkson on September 16, 2019, 01:23:32 PM
Hi guys,

I attached a latest copy of the visio diagram. Its looking good. I managed to create a toggle button on the Vision1 Shape where if you click the Container Off or on it will change the shape into a container. Issue is that I will have to now do this for everything. Is there any way of using your code Wapper to run through the rest of the shapes and add the shapesheet changes automatically so that they all have the button?
Title: Re: Guarded object within a group still grows
Post by: wapperdude on September 16, 2019, 02:55:45 PM
First, the last two posts came thru without attachments.

Yes.  Code can do that.

My PC is still not useable at the moment, but getting close.

Might I ask why the shift to containers?
Title: Re: Guarded object within a group still grows
Post by: Yacine on September 16, 2019, 06:14:04 PM
@Wapperdude and Maclarkson,
Guys, I should not have posted such an inconsiderate answer. I did not thoroughly read the question, nor the answers to it.
I just saw a similarity to a problem a handled in the past and posted my link out of pure vanity.
With this post I didn't do justice to both the questioner and the responder. I apologize for that ... especially to my buddy Wayne ;) .
Title: Re: Guarded object within a group still grows
Post by: wapperdude on September 16, 2019, 08:20:44 PM
@Yacine:  Whoa!  No apologies needed to me.  Your tool works and is well thought out.  It is an appropriate option.  Yeah, you mentioned some bugs, but the tool is still quite useful.  I apologize because I keep forgetting about referring it.

Adding the ability to show hide subshapes would be a nice feature...especially if one of the subshapes is another group. 

Sorry if I came across as a nattling Nellie of negativity.  I think grumpy comes with age and frustration with remodelling contractors...5-6 month project now celebrating 1 year and still not finished.



Title: Re: Guarded object within a group still grows
Post by: wapperdude on September 16, 2019, 10:13:43 PM
PC is back!

Here's OP original file post with code added...but not run.  The code has been tested on this file, runs fine, main shape and icon shape become grouped, icon size fixed, and location fixed.  No need to select anything.  Just run code.  All shapes are process
Title: Re: Guarded object within a group still grows
Post by: maclarkson on September 17, 2019, 06:17:25 AM
Sorry about that (No Attachment) but wow I just ran your Code !!! I wished I could code like that. How do you learn to code like that?

Here is the attachment. its return of your template. but with some changes I made to the vision shape. You'll see that on the right click menu you can toggle the action of changing the shape into a container or turning it off. If you can teach me the code to run an add section, add row and add update to row. life will be so amazing coz I'll be able to apply global changes so fast.

I am eventually going to connect this up to a database and when finished I will show you what the out come is.

Maybe others will be able to use it.

Title: Re: Guarded object within a group still grows
Post by: wapperdude on September 17, 2019, 03:00:48 PM
Learning to code....hmmmm. 

I'm not aware of a good, comprehensive text for Visio dedicated to topic vba.   In my case, before  I retired, I had a major coding effort using Excel and VBA.  That helped some. 

For Visio, it comes from (a) looking at what other people are doing, (b) googling..."Visio vba ... " + whatever, example:  "Visio, vba drop shape on page", (c) storing pieces of code for future reference, (d) listening to experienced coders...Yacine has pushed me to be much better than I was.  (e) the free software kit SDK, has many examples. 

And finally, try things.  Start small.  Couple hints...
1)  Have both the drawing and vba Windows open side by side
2)  in the code window, click anywhere inside a subframe, then use F8 to step thru the macro to execute code line-by-line.  You can see what happens in the drawing window
3)  use the macro recorder.  It adds a lot of extra stuff you don't need at front & end that you can thru away.  You'll quickly sort that out when comparing to other code examples.
4) Add comments to your code.  Tomorrow, a month from know, you forget what and why, comments are your explanatory notes.

Some good sites to check out:
Visio Guys blog site has articles that explain things very well.: 
John Goldsmith:  https://visualsignals.typepad.co.uk/vislog/2007/10/just-for-starte.html (https://visualsignals.typepad.co.uk/vislog/2007/10/just-for-starte.html) 
                      and http://visio.mvps.org/VBA/default.html (http://visio.mvps.org/VBA/default.html)
David Parker:  https://blog.bvisual.net (https://blog.bvisual.net)

...and so many others.
Title: Re: Guarded object within a group still grows
Post by: wapperdude on September 17, 2019, 11:50:16 PM
See attached for latest implementation.  The code loops thru all shapes and everything as before, but now iterates thru each icon grouped shape and adds necessary shapesheet entries to each icon subshape and to the Main shape to mechanize Show/Hide of icon.  Right click Main shape and there's a toggle entry to show/hide the Icon.  Note, this is for regular grouped shape not a container shape.

Also, there are 4 shapes in the original file, see heavy border, that were already grouped.  The code assumes Main shape is just a simple shape with no grouping.

Title: Re: Guarded object within a group still grows
Post by: maclarkson on September 18, 2019, 03:33:19 AM
The SDK, is this where you would recommend to develop addins, such as one that could filter or search for rows from linked data. and allow me to create new connected objects from it.

I looked at your code to change the line far out thats totally awesome.

whats strSpaicialRelation and vsoReturnedCode I could not figure out what these were?
Title: Re: Guarded object within a group still grows
Post by: wapperdude on September 18, 2019, 04:21:50 AM
Regarding the "spatial", see https://docs.microsoft.com/en-us/office/vba/api/visio.shape.spatialrelation (https://docs.microsoft.com/en-us/office/vba/api/visio.shape.spatialrelation). 

visSpatialRelationCodes:  https://docs.microsoft.com/en-us/office/vba/api/visio.visspatialrelationcodes (https://docs.microsoft.com/en-us/office/vba/api/visio.visspatialrelationcodes)

The SDK:  https://www.microsoft.com/en-us/download/details.aspx?id=51221 (https://www.microsoft.com/en-us/download/details.aspx?id=51221)

I encourage you to search the internet for these things.  It is a good way to learn about Visio and VBA.

the vso
Title: Re: Guarded object within a group still grows
Post by: maclarkson on September 18, 2019, 10:25:26 AM
Do you reckon you'd have the skill to create a plugin? one that allows you to filter on your linked data, or one that allows you to add objects to a page and as you do it it automatically saves the objects in a database as a new row?
Title: Re: Guarded object within a group still grows
Post by: maclarkson on September 18, 2019, 12:22:30 PM
I just tried to add my container on\off button altering your code like so and it, of course, failed for me  :'( what am I doing wrong?

Sub Macro1()
'Macro loops thru all shapes.  Finds shapes that have a second (Icon) shape placed
'within border using Spatial Neighbor method.  Creates necessary grouping.  Locks position and size of icon, adds
'Action menu item to show/hide the icon.
'It assumes all shapes have been properly built and placed.
'The physical placement of the icon has the offset hardcoded.
'There is no error checking.

    Dim intTolerance As Integer
    Dim vsoReturnedSelection As Visio.Selection
    Dim strSpatialRelation As String
    Dim intSpatialRelation As VisSpatialRelationCodes
    Dim vMain As Visio.Shape
    Dim vIcon As Variant
   
    strSpatialRelation = ""
    intTolerance = 0.05
    intSpatialRelation = visSpatialContain
   
    For Each vMain In ActivePage.Shapes             'This construct needs to manual selecction
    'check to see if shape has containing neighbor.  If so select it.
        ActiveWindow.DeselectAll
        On Error Resume Next
        Set vsoReturnedSelection = vMain.SpatialNeighbors(intSpatialRelation, intTolerance, 0)
        If vsoReturnedSelection.Count = 1 Then
            Debug.Print "Main shape:  ", vMain.Name
            ActiveWindow.Select vMain, visSelect
'            setPgZm vMain          'Handy subroutine.  Using F8 to step code.  Takes windo to active vMain

'    Add vMain Actions here
            If Not vMain.CellExistsU("Actions.Icon", False) Then
                vMain.AddSection visSectionAction
                vMain.AddRow visSectionAction, visRowLast, visTagDefault
                vMain.CellsSRC(visSectionAction, 0, visActionMenu).RowNameU = "Icon"
                vMain.CellsSRC(visSectionAction, 0, visActionAction).FormulaU = "SETF(GETREF(Actions.Icon.Checked),NOT(Actions.Icon.Checked))"
                vMain.CellsSRC(visSectionAction, 0, visActionMenu).FormulaU = "IF(Actions.Icon.Checked,""Show Icon"",""Hide Icon"")"
           End If
               
      'Add msvStrcutureType container
                If Not vMain.CellExistsU("User.Container", False) Then
                vMain.AddSection visSectionUser
                vMain.AddRow visSectionUser, visRowLast, visTagDefault
                vMain.CellsSRC(visSectionUser, 0, visUserValue).RowNameU = "msvStructureType"
                vMain.CellsSRC(visSectionUser, 0, visUserValue).FormulaU = "SETF(GETREF(User.msvStructureType),0)"
               End If
       'Add container on action
                If Not vMain.CellExistsU("Action.ContainerOn", False) Then
                vMain.AddRow visSectionAction, visRowLast, visTagDefault
                vMain.CellsSRC(visSectionAction, 0, visActionMenu).RowNameU = "ContainerOn"
                vMain.CellsSRC(visSectionAction, 0, visActionAction).FormulaU = "SETF(GetRef(User.msvStructureType),""Container"")&SETF(GetRef(Actions.ContainerOff),""Container Off"")&SETF(GetRef(Actions.ContainerOn),"""")"
                vMain.CellsSRC(visSectionAction, 0, visActionMenu).FormulaU = "Container Off"
                End If
      'Add Container Off Action
                If Not vMain.CellExistsU("Action.ContainerOff", False) Then
                vMain.AddRow visSectionAction, visRowLast, visTagDefault
                vMain.CellsSRC(visSectionAction, 0, visActionMenu).RowNameU = "ContainerOff"
                vMain.CellsSRC(visSectionAction, 0, visActionAction).FormulaU = "SETF(GetRef(User.msvStructureType),"""")&SETF(GetRef(Actions.ContainerOn),""Container On"")&SETF(GetRef(Actions.ContainerOff),"""")"
                vMain.CellsSRC(visSectionAction, 0, visActionMenu).FormulaU = ""
               
            End If

' Convert vMain to group object
            vMain.ConvertToGroup
            vMain.CellsU("DisplayMode").Formula = "1"
            For Each vNbr In vsoReturnedSelection
                Set vIcon = vNbr
                ActiveWindow.Select vIcon, visSelect
                Debug.Print "Icon:  ", vIcon.Name
            Next
               
            ActiveWindow.Selection.AddToGroup       'Add vIcon to the group
       
' Lock vIcon size and position
            vIcon.CellsU("Width").Formula = vIcon.CellsU("Width").ResultStr(visNone)
            vIcon.CellsU("Height").Formula = vIcon.CellsU("Height").ResultStr(visNone)
            vIcon.CellsU("PinX").FormulaU = "LocPinX + 0.03125"
            vIcon.CellsU("PinY").FormulaU = vMain & "!Height*1-(Height-LocPinY)-0.03125"
           
' Iterate thru subshapes of vIcon
            For Each shp In vIcon.Shapes    'goes thru the Icon group shape and modifies the subshapes
                Debug.Print shp.Name        'name of member subshape
                shp.CellsU("Geometry1.NoShow").Formula = vMain & "!Actions.Icon.Checked"
            Next
        End If
    Next

   
End Sub
Sub setPgZm(vsoShp As Shape)

    Dim winMag As Double
    Dim shpWid As Double
    Dim shpHt As Double
    Dim pgWid As Double
    Dim pgHt As Double
    Dim widRatio As Double
    Dim htRatio As Double
   
'Use shape based upon selection:
    Application.Settings.CenterSelectionOnZoom = True
   
'    Set vsoShp = ActiveWindow.Selection(1)
   
    pgWid = ActivePage.PageSheet.CellsU("PageHeight").Result(inch)
    shpWid = vsoShp.CellsU("Width").Result(inch)
    widRatio = pgWid / shpWid
   
    pgHt = ActivePage.PageSheet.CellsU("PageWidth").Result(inch)
    shpHt = vsoShp.CellsU("Height").Result(inch)
    htRatio = pgHt / shpHt
   
    If widRatio < htRatio Then
        winMag = widRatio * 0.5
    Else
        winMag = htRatio * 0.5
    End If
   
    ActiveWindow.Zoom = winMag
    Application.Settings.CenterSelectionOnZoom = False

End Sub


Title: Re: Guarded object within a group still grows
Post by: wapperdude on September 18, 2019, 01:19:47 PM
Not really.  Never done that.  Start a new thread...make the title obvious.
Title: Re: Guarded object within a group still grows
Post by: maclarkson on September 18, 2019, 11:53:15 PM
Would it be possible to create a whole new discussion topic called the database project rather than a single thread?

I would like to ultimately create a plugin that allows you to connect to a database. The idea I have a really simple one where you can create or use existing shapes from the database to create diagrams. All of the connectors are also registered in the database. its only two tables.

The question the solution is primarily answering is what is, I have created x number of diagrams what is connected to what?

Imagine its uses:
Network diagrams
CMDBs
Architectural diagrams
Process flow diagrams
Integration diagrams
TOGAF diagrams

People would be able to use the data to discover the implications of changing anything.

Title: Re: Guarded object within a group still grows
Post by: Nikolay on September 19, 2019, 05:21:29 AM
Visio (now) has "Data Visualizer" for drawing diagrams from data.
https://support.office.com/en-us/article/create-a-data-visualizer-diagram-17211b46-d144-4ca2-9ea7-b0f48f0ae0a6

It works mostly for specific diagram types (flowcharts), but it's built-in, user-friendly, well-documented, and customizable (e.g. allows custom shapes for example).

In general, the implication of generating diagrams is basically the layout; how do you arrange shapes from your database on the diagram properly, so that it looks nice, and how do you update the diagram when you change both data in the database and on the diagram (i.e. how to merge "manual" changes with "database" ones)

There were multiple attempts in the past to create such an application that will do the work automatically based on data on the basis of Visio, none of them really worked for a wider audience, as far as I know (i.e. they worked basically for the project, for which they were created, or only for the person, who created them). But maybe you'll have more luck - you never know. Some of them were based on OrgChart wizard (since it has automatic layout feature) but it's quite a rigid solution that does not assume user customization, and in addition, it has issues with updating diagram (and sorting). Also, I remember some swiss guy tried to build a solution (https://www.calvert.ch/graphvizio/) based on GraphViz (http://www.graphviz.org/) engine. Unfortunately was not trivial to install and use. Another approach was to use MSAGL (https://github.com/microsoft/automatic-graph-layout) (Microsoft Automatic Graph Layout library), SaveenR was building (https://github.com/saveenr/VisioAutomation) and presenting (https://www.reddit.com/r/PowerShell/comments/27usm0/powershell_and_visio_crazy_delicious_powershell/) a PowerShell module (https://www.powershellgallery.com/packages/Visio) based on this idea.
The idea of automatic generation of diagrams from data is as old as Visio itself I suppose  :)
Title: Re: Guarded object within a group still grows
Post by: maclarkson on September 19, 2019, 05:52:51 AM
Orbus iServer, and ITP commerce have both achieved this. but the price of these product is simply ridiculous $1600 a user per seat!! and all it does is exactly what I explained.

I tried data visualizer and this is pretty rubbish in that its exactly as you called it. it only works with two diagram types. Its also is not relational with its connections. It put the relationships into a single cell. If I got this to work there would be every architect and their dog after this.
Title: Re: Guarded object within a group still grows
Post by: Nikolay on September 19, 2019, 05:57:14 AM
Oh. If you could manage to build a product that would do the same as Orbus or ITP commerce, you probably would be able to expel those greedy bastards from the market  ;D
Title: Re: Guarded object within a group still grows
Post by: maclarkson on September 19, 2019, 06:02:06 AM
Ye man, But that's not what I am try to do. If I was to look at it from a roadmap perspective. give the product free and then charge for specialised templates support and out of the box reports. That's were we'd make some money. I have achieved the above to some effect using your back sync product, but it would awesome if I could create something a little more robust.

By the way do you know where I am going wrong in my code above?
Title: Re: Guarded object within a group still grows
Post by: Nikolay on September 19, 2019, 06:08:37 AM
Sorry, it's a bit specific... maybe you have a diagram this could run against - that could help I suppose
The code has a comment at the top saying that it is supposed to be run on a prepared diagram ("the shapes should be properly built and placed"?)
Title: Re: Guarded object within a group still grows
Post by: wapperdude on September 19, 2019, 06:25:58 AM
@Nikolay:  LOL.  Yes.  It's specific.  See reply #26 for file that it was based on.  Other than the lines about the container, the code was my solution.  So, it assumes that the "Main" shape is just an ordinary 2D shape.  Then, the "Icon" shape is a grouped shape, and placed at the ~ desired location within the Main shape.  It's strictly based upon the physical layout.  Uses spacial neighbors to locate the Icon associated with the Main shape.  It then converts the Main shape to a group and adds the Icon to the new group.  There were some advantages to this method versus the typical select shapes and group.  Along the way it locks the Icon position and size.  Adds Action item to group to show/hide Icon visibility by write formula to each Icon subshape's Geometry1.NoShow cell.

Haven't looked at the container code lines yet.
Title: Re: Guarded object within a group still grows
Post by: Paul Herber on September 19, 2019, 07:59:26 AM
Quote from: maclarkson on September 18, 2019, 11:53:15 PM
Would it be possible to create a whole new discussion topic called the database project rather than a single thread?


There's a Database Diagramming section ripe and ready for any new topic you wich to create!
Title: Re: Guarded object within a group still grows
Post by: maclarkson on September 20, 2019, 04:16:26 AM
Hi guys,

I have created another topic under database diagraming

http://visguy.com/vgforum/index.php?topic=8924.0

And have added Yasine's database as a first release. I will probably have a go over the weekend to create a second release. and make sure the database is a web based one. See you all there.