Author Topic: Use name (not number) of line pattern in Shapesheet  (Read 625 times)

0 Members and 1 Guest are viewing this topic.

WillVis

  • Newbie
  • *
  • Posts: 3
Use name (not number) of line pattern in Shapesheet
« on: March 08, 2023, 12: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?

Yacine

  • Hero Member
  • *****
  • Posts: 3165
Re: Use name (not number) of line pattern in Shapesheet
« Reply #1 on: March 08, 2023, 12: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".
« Last Edit: March 08, 2023, 12:50:14 PM by Yacine »
Yacine

WillVis

  • Newbie
  • *
  • Posts: 3
Re: Use name (not number) of line pattern in Shapesheet
« Reply #2 on: March 08, 2023, 03: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.
« Last Edit: March 08, 2023, 03:38:15 PM by WillVis »

Yacine

  • Hero Member
  • *****
  • Posts: 3165
Re: Use name (not number) of line pattern in Shapesheet
« Reply #3 on: March 09, 2023, 03: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

Code
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.
Yacine

WillVis

  • Newbie
  • *
  • Posts: 3
Re: Use name (not number) of line pattern in Shapesheet
« Reply #4 on: March 09, 2023, 10:06:41 AM »
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

Yacine

  • Hero Member
  • *****
  • Posts: 3165
Re: Use name (not number) of line pattern in Shapesheet
« Reply #5 on: March 10, 2023, 12:28:31 AM »
FORMULAEXISTS returns true for EVERY formula, even a simple "1", and LinePattern is never empty.
Yacine