News:

BB code in posts seems to be working again!
I haven't turned on every single tag, so please let me know if there are any that are used/needed but not activated.

Main Menu

Use name (not number) of line pattern in Shapesheet

Started by WillVis, March 08, 2023, 05:06:30 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

WillVis

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

#1
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".
Yacine

WillVis

#2
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.

Yacine

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

WillVis

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

FORMULAEXISTS returns true for EVERY formula, even a simple "1", and LinePattern is never empty.
Yacine

Browser ID: smf (possibly_robot)
Templates: 4: index (default), Display (default), GenericControls (default), GenericControls (default).
Sub templates: 6: init, html_above, body_above, main, body_below, html_below.
Language files: 4: index+Modifications.english (default), Post.english (default), Editor.english (default), Drafts.english (default).
Style sheets: 4: index.css, attachments.css, jquery.sceditor.css, responsive.css.
Hooks called: 278 (show)
Files included: 34 - 1306KB. (show)
Memory used: 1086KB.
Tokens: post-login.
Cache hits: 13: 0.00149s for 26,767 bytes (show)
Cache misses: 2: (show)
Queries used: 15.

[Show Queries]