Visio Guy

Visio Discussions => ShapeSheet & Smart Shapes => Topic started by: WillVis on March 08, 2023, 05:06:30 PM

Title: Use name (not number) of line pattern in Shapesheet
Post by: WillVis on March 08, 2023, 05:06:30 PM
Hello,

I want to set the "DisplayLevel" of a shape based on the line pattern (or alternatively line style) used at the shape.

The line patterns would be named in a systematic way, e.g.
3_Big Line -> DisplayLevel = 3
2_Normal Line -> DisplayLevel = 2
2_Other Normal Line -> DisplayLevel = 2
1_Small Line -> DisplayLevel = 1

I tried "=LEFT(LinePattern,2)", but LinePattern returns the ID of the line pattern rather than its name. How can I read the line pattern name?
Title: Re: Use name (not number) of line pattern in Shapesheet
Post by: Yacine on March 08, 2023, 05:42:41 PM
You would store your DisplayLevel in a prop field, with row type = fixed list.
The format cell would hold the names of the patterns - eg "Big Line;Normal Line;..." (mind the semi-colons)
Then your LinePattern cell would get the formula; =USE(prop.DisplayLevel)



If you prefer numbers (1..3) then you could either name you line patterns accordingly or map the pattern names with a number list.
Fortmat of prop.DisplayLevel would then be "1;2;3"
The would be a user field "Pattern_Names" with the patterns list "Big Line;Normal Line;..."
And the formula of the linepattern cell would become =USE(LOOKUP(INDEX(prop.DisplayLevel,propDisplayLevel.Format),user.Pattern_Names)

The thing I haven't understood is how you want to distinguish "Normal Line" from "Other Normal Line".
Title: Re: Use name (not number) of line pattern in Shapesheet
Post by: WillVis on March 08, 2023, 08:18:50 PM
Thanks a lot for the quick response!

I'm not sure if I get it correctly - isn't that the other way around? What I want: The user sets the line pattern (or style), and the value of the DisplayLevel cell is then set automatically based on the user's selection of the line pattern.

Background: I want to use custom line patterns with white background to simulate line jumps. (refer to http://visguy.com/vgforum/index.php?topic=416.msg1870#msg1870) The DisplayLevels shall make small lines "jump" (by putting them to the back).

Normal line and Other normal line have the same priority in my example.
Title: Re: Use name (not number) of line pattern in Shapesheet
Post by: Yacine on March 09, 2023, 08:32:51 AM
The other way around.

The shapesheet misses a function "FORMULA(of cell)".

You can overcome the problem by writing a macro.

eg

Sub getFormula(shp As Shape)
  shp.Cells("user.Row_1").FormulaU = Chr(34) & Replace(shp.Cells("LinePattern").FormulaU, Chr(34), "'") & Chr(34)
End Sub


In a second user cell write CALLTHIS("getFormula")+DEPENDSON(LinePattern)

Parsing the formula can then be done in the shapesheet. You may also do it in the macro itself. Easier.
Title: Re: Use name (not number) of line pattern in Shapesheet
Post by: WillVis on March 09, 2023, 03:06:41 PM
Ok, thanks again. For the time being I have decided to use the line weight (in the line style), which is then transfered to the connector. (I am using Visio in an environment in which I can't easily use VBA code.)

Linestyle ShapeSheet e.g. for the big lines:
LineWeight = GUARD(3 pt)

Connector ShapeSheet (in the Document Stencil):
DisplayLevel = IF(FORMULAEXISTS(LinePattern),FORMATEX(LineWeight,"0",,"pt"),0) -> DisplayLevel = 3
-> the FORMULAEXISTS part should limit the calculation to custom line patterns
Title: Re: Use name (not number) of line pattern in Shapesheet
Post by: Yacine on March 10, 2023, 05:28:31 AM
FORMULAEXISTS returns true for EVERY formula, even a simple "1", and LinePattern is never empty.