Need Correct Length of Connectors

  • Thread starter DigitalHomeSolutions
  • Start date
D

DigitalHomeSolutions

I am drawing wiring plans for home theater and structured wiring and need the
entire length of a connector, using dynamic connectors, size and position
window does not give a total length only a total of the sum x+y which is not
correct. I have found someone who said to use LengthIU property, but for the
life of me I can't figure out how to use it. I don't know where or what to do
with:
retVal = object.LengthIU
retVal
Double. The length (perimeter) of the object in internal units (inches).

object
Required. An expression that returns a Shape object.
I am fairly new to visio so please be descriptive I have someone else who
would also benefit from this information too, and I will pass it on. Thank
you in advance
 
D

David Parker [Visio MVP]

Oh dear, I just found this previous response to the LengthUI property:
In Visio 2003, the path of the shape's geometry must be closed. A bug
prevents this from working with open paths.

So, as an alternative, I offer the following:
To use, cut and paste into VBA modules, select a few connectors, then run
SetTextToLenghtUI

Public Sub SetTextToLenghtUI()
Dim shp As Visio.Shape
For Each shp In Visio.ActiveWindow.Selection
GetLengthUI shp
Next shp
End Sub

Public Sub GetLengthUI(ByVal shp As Visio.Shape)
'This should work! (But it doesn't in Visio 2003)
' If shp.OneD <> 0 Then
' shp.Text = shp.LengthIU(False)
' End If

'Fix for simple multi-segment lines - Assumes just one geometry section with
straight line segments
Dim dSeg As Double
Dim dTotal As Double
Dim iRow As Integer
Dim BeginX As Double
Dim EndX As Double
Dim BeginY As Double
Dim EndY As Double

For iRow = 2 To shp.RowCount(Visio.visSectionFirstComponent)
BeginX = shp.CellsSRC(Visio.visSectionFirstComponent, iRow - 1,
Visio.visX).ResultIU
BeginY = shp.CellsSRC(Visio.visSectionFirstComponent, iRow - 1,
Visio.visY).ResultIU
EndX = shp.CellsSRC(Visio.visSectionFirstComponent, iRow,
Visio.visX).ResultIU
EndY = shp.CellsSRC(Visio.visSectionFirstComponent, iRow,
Visio.visY).ResultIU
dSeg = Sqr((EndX - BeginX) ^ 2 + (EndY - BeginY) ^ 2)
dTotal = dTotal + dSeg
Next iRow

shp.Text = dTotal
End Sub
 
D

DigitalHomeSolutions

I put the code in but it it doesn't account for multiple direction
connections, e.i. down, right, up, right, up. how do I get a length for a
connector like that. I am thinking it has something to do with
"vis.SectionFirstComponent+i" but I can't figure out how to put that into the
code to make it work. I realy need some help here. I've been struggling for 3
weeks trying to figure this out. I'm not a code writer. If any one wants to
help me figure this out I will greatly apreciate it. I need to be able to
know the total accurate length of cable needed for a cable run on a floorplan
of a house or building for structured wiring. I am drawing the connectors to
shape symbols representing different outlets so they should be closed. If
that helps. Thank you in advance!!!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top