Visio Guy

Visio Discussions => Shapes & Templates => Topic started by: john.morton on February 17, 2011, 10:14:39 AM

Title: HP Rack Stencil: Need More Calculated Fractional Connection Points (1/3 of 1U)
Post by: john.morton on February 17, 2011, 10:14:39 AM

Calling all Visio experts!

For the life of me I can't work out how to programtically/dynamically add additional vertical connection points to HP's official rack stencils (located here: http://www.visiocafe.com/downloads/hp/HP-Common.zip (http://www.visiocafe.com/downloads/hp/HP-Common.zip)). Please help!!

Background: we have a computer room (which I'd like to accurately diagram) where equipment has been installed into the racks at non-standard rack unit locations. Correct placement is to occupy space in multiples of 1.75" beginning at either the top or the bottom of the cabinet (see here for more information: http://en.wikipedia.org/wiki/Rack_uni (http://en.wikipedia.org/wiki/Rack_uni)t).

Rather than try and add these connection points manually I would like them to be programatically/dynamically added to this existing stencil (possibly by somehow manipulating the Shape Sheet (or the formulas therein)?).

If this is too difficult to implement - it may be possible to manually add them all to a master stencil by way of calculating the values in Excel and manually entering them all?

I'd also be quite happy downloading an existing modified stencil if someone has one to hand or knows where on might be!

Please help - it's driving me loopy!

Kind regards,

John
Title: Re: HP Rack Stencil: Need More Calculated Fractional Connection Points (1/3 of 1U)
Post by: Jumpy on February 17, 2011, 02:35:01 PM
Here's some code to change or Add CPs, hth.
You have to change the values to your needs.


Sub Change()
  Dim shp As Visio.Shape
  Dim s As Visio.Section
  Dim r As Visio.Row
  Dim i As Integer
  Dim Offset As String
 
'  Offset = "2 mm"

  For Each shp In ActiveWindow.Selection
   
   
    Set s = shp.Section(7)
   
    'This here could change the position of the CPs that are already there
'    For i = 0 To s.Count - 1
'      Set r = s.Row(i)
'      r.Cell(0).Formula = r.Cell(0).Formula & "+" & Offset
'    Next i
   
    'This Adds new CPs:
    For i = s.Count To 150 'change the number as needed
      shp.AddNamedRow 7, "CP" & i, 0
     
      If i Mod 2 = 1 Then
        shp.Cells("Connections.CP" & i & ".X").Formula = "1 mm *" & i 'Adjust Height of the CP
      Else
        shp.Cells("Connections.CP" & i & ".X").Formula = "1 mm *" & i - 1 'Adjust Height of the CP
      End If
     
      If i Mod 2 = 1 Then
        shp.Cells("Connections.CP" & i & ".Y").Formula = "5 mm"         'Adjust left or right position
      Else
        shp.Cells("Connections.CP" & i & ".Y").Formula = "55 mm"
      End If
    Next i
   
  Next shp
End Sub