Length of a dynamic link

C

Christophe Malizia

Hello,

I wish to know how to have the length of a link... I'm doing a cabling plan
of an high computing solution and need to know the appropriate length of
network cable...

Thanks in advandce for your answer!
Regards
Christophe
 
P

Philippe C.

John, I tried the sample program.
In my drawing I have in order of making a line, a connector, a freeform,a
wall and a rectangle.

Yet it only gives zeroes. The output of the program is :

Page Name,Shape ID,Assigned to layers:,Shape Length (inches)
Page-1,1,,0
Page-1,2,Connector 0
Page-1,3,,0

If I leave out the check for onedimensionality I get :
Page Name,Shape ID,Assigned to layers:,Shape Length (inches)
Page-1,1,,0
Page-1,2,Connector;,0
Page-1,3,,0
Page-1,4,,1181,10236220472
Page-1,5,,913,385826771653

Could it be because of my dutch/belgian settings ?
 
J

John Goldsmith

Hello Philippe,

Are you using Visio 2003? I spotted a post in which Mark Nelson said that
there was a bug in 2003 in which LengthIU returned zeros:

http://groups.google.co.uk/group/mi...k=st&q=visio+lengthiu&rnum=2#a559f3f892c5059b

Does that apply to you? If so have you upgraded to SP3 (not sure if this
was fixed in the SP though)?

Also, as far as I'm aware, this only works for straight line connectors not
freeform (NURBS as I know you are aware).

Best regards

John


John Goldsmith
www.visualSignals.typepad.co.uk
www.visualSignals.co.uk
 
P

Philippe C.

I work with Visio 2003 SP 2.
But at home I play with Visio 2007.
I'll have a try one of these days.
 
P

Philippe C.

Starting in the Shapesheet

Sub Macro2()
Application.ActiveWindow.Shape.CellsSRC(visSectionScratch, 0,
visScratchA).FormulaU = "Data1()"
End Sub

Does work.

But

Sub Macro2()
Application.ActiveWindow.Shape.CellsSRC(visSectionScratch, 0,
visScratchA).FormulaU = "LengthIU()"
End Sub

Does not work. The error is = "Unknown function name"
Visio 2003.
 
J

John Goldsmith

Hello Philippe,

LengthIU is a property of the shape object and is only availble via code.
It's not a ShapeSheet function.

If you want to report the length then you need to add a User cell to your
respective shapes and then run a procedure to update them prior to running
your report.

So your syntax should be something like:

shp.CellsU("User.MyAddedLengthCell").Formula = shp.LengthIU

Best regards

John


John Goldsmith
www.visualSignals.typepad.co.uk
www.visualSignals.co.uk
 
P

Philippe C.

As I know there is great demand, I give a working snippet.
Run it and
Then have a look at the shapesheet. The length is 16
Then look for "lengte" to add in your report.

Now to have something useful there should be a in it

for each shape in selection
test if row exists
to delete or add



----------------------------------------------------------------------------------------------
Public Sub Cells_Example()

Dim vsoPage As Visio.Page
Dim vsoShape As Visio.Shape
Set vsoPage = ActivePage

'If there isn't an active page, set vsoPage
'to the first page of the active document.
If vsoPage Is Nothing Then
Set vsoPage = ActiveDocument.Pages(1)
End If

'Draw a rectangle on the active page.
Set vsoShape = vsoPage.DrawRectangle(1, 5, 5, 1)

'Add a scratch section and add a row to the scratch section.
vsoShape.AddSection visSectionUser
vsoShape.AddNamedRow visSectionUser, "Lengte", 0
vsoShape.CellsU("User.Lengte").Formula = vsoShape.LengthIU
End Sub
 
P

Philippe C.

It took me a shameful lot of effort to fabricate following piece of miserable
code.

Sub UpdateLengths()
' to be run on a selection of shapes
' before making a report with the lengths of the shapes
' LengthIU in Visio 2003 only works with closed shapes

Dim sel As Visio.Selection
Dim shp As Visio.Shape
Dim iRowIndex As Integer
Set sel = ActiveWindow.Selection

For Each shp In sel
If Not (shp.SectionExists(visSectionUser, 1)) Then
shp.AddSection visSectionUser
End If
If shp.CellExists("User.lengte", 1) Then
iRowIndex = shp.CellsRowIndex("User.lengte")
shp.DeleteRow visSectionUser, iRowIndex
End If
shp.AddNamedRow visSectionUser, "Lengte", 0
shp.CellsU("User.Lengte").Formula = shp.LengthIU
Next shp
End Sub
 

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