"Vinnie Boombots" <VinnieB...@discussions.microsoft.com> wrote in
message news:7DB373E1-4CF1-4092...@microsoft.com...
> Does anyone have a trick or shape that will allow rack units or "U's" to
> be
> displayed instead of inches or feet when using the "Dimension - Vertical"
> shape from the Rack-Mounted Equipment stencils?
>
> Basically, I want to have a "callout" that displays the correct rack units
> as I change the length of the callout.
>
> Many shapes in the Rack-mounted stencils have this feature.
>
> Thank you.
"Vinnie Boombots" <VinnieB...@discussions.microsoft.com> wrote in
message news:AB92015F-EF97-4773...@microsoft.com...
>I would like to use the dimension as a dynamic ruler or guide.
>
> When placing shapes in the rack, I can stretch or shrink the dimension
> callout to a desired rack unit, then place the shape at the position of
> the
> callout. This would be useful since I do not want to count points on the
> rack shape. The dimension shape already displays feet/inches, but I don't
> want to convert this to rack units every time. Displaying a "U" would be
> quick and easy.
>
> Example, an a shape (RAID, or CPU) needs to be placed at the 30 U mark on
> a
> rack, I will adjust the dimension callout to 30 U and place the shape at
> 30
> U. This would be a great times saver since I have many shapes to place in
> a
> rack.
>
> If you have an easier solution, then that would help as well.
>
> Thanx
Thank you.
the first part renaming the shelves might use something like this.
'
' go through a rack and add connection point names so that
' we can address at a shelf level
'
Public Sub RenameRackShelfRows(ByVal visShape As Visio.Shape)
Dim visSection As Visio.Section
Dim visRow As Visio.Row
Dim strShelfName As String
Set visSection = visShape.Section(visSectionConnectionPts)
Dim intX As Integer
Dim intY As Integer
Dim intShelf As Integer
Dim rowName As String
rowName = ""
' connections start at zero
For intX = 0 To visSection.Count - 1
Set visRow = visSection.Row(intX)
strShelfName = "shelf_"
intY = (intX + 1) Mod 2 ' are we odd or even
If intY = 0 Then
intShelf = ((intX + 1) / 2)
strShelfName = strShelfName & "right_"
Else
intShelf = (intX / 2) + 1
strShelfName = strShelfName & "left_"
End If
visRow.NameU = strShelfName & CStr(intShelf)
visRow.Name = strShelfName & CStr(intShelf)
Next intX
End Sub
The second part might take advantage of some material in the visio sdk in
capturing mouse events and identifiying which shape was being pointed at.
'
' modified from the sdk
'
Private Sub vsoApplication_MouseUp _
(ByVal lngButton As Long, _
ByVal lngKeyButtonState As Long, _
ByVal dblX As Double, _
ByVal dblY As Double, _
blnCancelDefault As Boolean)
'
Const TOLERANCE As Double = 0.0001
Dim vsoClickedShapes As Visio.Selection
Dim vsoShape As Visio.Shape
Dim lngNextShape As Long
Dim strMessage As String
Dim strMasterName As String
Dim intName As Integer
On Error GoTo vsoApplication_MouseUp_Err
Set vsoWindow = vsoApplication.ActiveWindow
' Check if the left mouse Button caused this event to occur.
If lngButton = Visio.VisKeyButtonFlags.visMouseLeft Then
' Get the list of shapes at the click location.
Set vsoClickedShapes = getMouseClickShapes( _
vsoWindow.PageAsObj, dblX, dblY, TOLERANCE)
' Check if any shapes were found.
' if only one is found then check to see if it is a rack
If (Not vsoClickedShapes Is Nothing) Then
If (vsoClickedShapes.Count = 1) Then
Set vsoShape = vsoClickedShapes.Item(1)
strMasterName = vsoShape.Master.NameU
intName = InStr(1, LCase(strMasterName), "rack")
If 0 < intName Then
strMessage = getShelf(vsoShape, dblX, dblY)
Else
' no rack in name get out
Exit Sub
End If
If (vsoApplication.AlertResponse = 0) Then
MsgBox strMessage
End If
End If
End If
End If
Exit Sub
vsoApplication_MouseUp_Err:
Debug.Print Err.Description
End Sub
'
' this is from the sdk
'
Private Function getMouseClickShapes _
(ByVal vsoClickedPage As Visio.Page, _
ByVal dblClickedLocationX As Double, _
ByVal dblClickedLocationY As Double, _
ByVal dblTolerance As Double) _
As Visio.Selection
Dim vsoClickedShapes As Visio.Selection
On Error GoTo GetMouseClickShapes_Err
' Use the SpatialSearch function of the page to get the list
' of shapes at the location.
Set vsoClickedShapes = vsoClickedPage.SpatialSearch( _
dblClickedLocationX, dblClickedLocationY, _
Visio.VisSpatialRelationCodes.visSpatialContainedIn, _
dblTolerance, Visio.VisSpatialRelationFlags.visSpatialFrontToBack)
Set getMouseClickShapes = vsoClickedShapes
Exit Function
GetMouseClickShapes_Err:
Debug.Print Err.Description
End Function
The final part would be to add investigate the shape based on the mouse
click to find the shelf based on the connection points
' assumes the connections in the rack have been renamed
' connection formula for y
'=User.BaseHeight+IF(Prop.UCount>1,1,Prop.UCount)*User.OneUHeight
' so function should be asware of baseheight and oneuheight from
' the shape
Private Function getShelf _
(ByVal vsoShape As Visio.Shape, _
ByVal dblMouseX As Double, _
ByVal dblMouseY As Double) As String
Dim vsoCell As Visio.Cell
Dim vsoSection As Visio.Section
Dim strMasterName As String
Dim strPinX As String
Dim dblPinX As Double
Dim strPinY As String
Dim dblPinY As Double
Dim strBase As String
Dim dblBase As Double
Dim strUHeight As String
Dim dblUHeight As Double
Dim strMouseX As String
Dim strMouseY As String
Dim dblDisplace As Double
Dim strShelf As String
strShelf = "Not Found"
Dim intConnCt As Integer
Dim strConnCt As String
Dim intX As Integer
Dim strMessage As String
' for debug
strMasterName = vsoShape.Master.NameU
strMessage = Left(strMasterName, 4)
strMouseX = " mouseX " & CStr(dblMouseX) & vbCrLf
strMouseY = " mouseY " & CStr(dblMouseY) & vbCrLf
'get the page horizontal position
If vsoShape.CellExists("pinX", False) Then
Set vsoCell = vsoShape.Cells("pinx")
' the vertical middle
strPinX = " pinX " & CStr(vsoCell.ResultIU) & vbCrLf
dblPinX = vsoCell.ResultIU
End If
' get the page vertical position
If vsoShape.CellExists("pinY", False) Then
Set vsoCell = vsoShape.Cells("pinY")
' the bottom
strPinY = " pinY " & CStr(vsoCell.ResultIU) & vbCrLf
dblPinY = vsoCell.ResultIU
End If
' get the rack displacement
If vsoShape.CellExists("user.BaseHeight", False) Then
Set vsoCell = vsoShape.Cells("user.baseheight")
strBase = " Base " & CStr(vsoCell.ResultIU) & vbCrLf
dblBase = vsoCell.ResultIU
Else
strMessage = "Not a Rack addin shape"
End If
dblDisplace = dblMouseY - (dblPinY + dblBase)
' get the unit height to use as a range for testing
If vsoShape.CellExists("User.OneUHeight", False) Then
Set vsoCell = vsoShape.Cells("User.Oneuheight")
' the bottom
strUHeight = " OneUHeight " & CStr(vsoCell.ResultIU) & vbCrLf
dblUHeight = vsoCell.ResultIU
End If
If vsoShape.SectionExists(visSectionConnectionPts, False) = True
Then
Set vsoSection = vsoShape.Section(visSectionConnectionPts)
intConnCt = vsoSection.Count
strConnCt = " conns " & CStr(intConnCt) & vbCrLf
For intX = 0 To intConnCt - 1
' get the y for the connection point
Set vsoCell = vsoShape.CellsSRC _
(visSectionConnectionPts, intX, visY)
If dblDisplace <= vsoCell.ResultIU _
And dblDisplace < vsoCell.ResultIU + dblUHeight Then
strShelf = vsoSection.Row(intX).NameU
strShelf = Right(strShelf, 3)
strShelf = Replace(strShelf, "t", "")
strShelf = Replace(strShelf, "_", "")
strShelf = "shelf " & strShelf
Exit For
End If
Next intX
End If
' our debug message
strMessage = strMessage & vbCrLf _
& strPinX & strPinY _
& strBase & strUHeight _
& strMouseX & strMouseY _
& strConnCt
' return the shelf number
getShelf = strShelf
End Function
hope this helps to get you started on what you want to do,
al
"Vinnie Boombots" <VinnieB...@discussions.microsoft.com> wrote in
message news:7C11A039-A615-4EEC...@microsoft.com...
I am a newbie, and programming is not my "thing". I do not believe I need
something as complicated as your code at this time( maybe I do?).
I just need to replace the feet/inches displayed with "Units" on the
"Vertical Dimension" shape. I will adjust the "Vertical Dimension" shape to
any height and use as a guide / reference. It does not need to be used
exclusively for racks, it could also be used to outline custom shapes I
create for the rack.
I thought this was simple since many shapes in the Rack-Mounted stencil set
have this feature. Each "Unit" is 1.75 inches, so maybe a field to
calculate units based on feet/inches and display this in a callout?
Is there a way to import this field from other shapes?
I will try your technique below, since it will make future rack designs
easier.
Thank you again.
On 4/1/07 9:36 AM, in article #ZVnJLGd...@TK2MSFTNGP03.phx.gbl, "Al
I couldn't resist dinking with Visio's dimension line shapes, and posted a
modified "Rack Unit" version on my web site!
Have a look here:
http://www.visguy.com/2007/04/01/rack-unit-dimension-line/
--
Hope this helps,
Chris Roth
Visio MVP
Free Visio shapes:
http://www.visguy.com/category/shapes
Visio programming info:
http://www.visguy.com/category/programming/
Other Visio resources:
http://www.visguy.com/visio-links/
"Vito Cavallo" <vitom...@hotmail.com> wrote in message
news:C235338F.139DD%vitom...@hotmail.com...