Visio Guy

Visio Discussions => Shapes & Templates => Topic started by: Gate on March 16, 2009, 12:15:17 AM

Title: Making blocks with perspective transparent.
Post by: Gate on March 16, 2009, 12:15:17 AM
My current drawings include many blocks with perspective. Now I need to make some of them transparent.

The face of the block becomes transparent, but the top and sides do not. How do I make the entire shape transparent?

Thanks!
Title: Re: Making blocks with perspective transparent.
Post by: Lars-Erik on March 16, 2009, 08:50:45 AM
Welcome Gate,

Are you using the Visio perspective blocks? If so, these blocks are groups that are made up out of different shapes. By default the group is locked so it looks like its just one shape. To make the top etc transparent you will first need to use the shapesheet of the group to change the group properties, and set selectmode to 1 instead of 0. This will allow you to sellect the parts of the shape you need to make transparent (eg the top). By selecting these and going into the shapesheet again (because the shape is guarded against changes) you can set the Fill Format property FillForegroundTrans, default is 0% (solid), setting it to 100% will make it completely transparent.

Hope this helps,

Lars
Title: Re: Making blocks with perspective transparent.
Post by: Gate on March 16, 2009, 09:49:09 PM
Thanks Lars.

Took a few tries, but I did it. Takes three trips to the shapesheet, right? Or is there a less clunky way?

If anyone else wants to know how to do this, let them learn from my mistakes. The first couple times, I made the face of the cube transparent before visiting the style sheet. That makes the line disappear and there's no easy way to get it back.
Title: Re: Making blocks with perspective transparent.
Post by: aledlund on March 17, 2009, 01:42:07 AM
also you might try it with a macro something like this

al




Option Explicit


Public Sub makeShapeTransparent()

        Dim visWin As Visio.Window
        Set visWin = Application.ActiveWindow
        Dim dghShape As Visio.Shape
        Dim selShapes As Visio.Selection
        Set selShapes = visWin.Selection
       
        If selShapes.Count = 1 Then

            Set dghShape = selShapes(1)
           
            ' set it semi-transparent
            Dim strTrans As String
            strTrans = "50%"
            ' first the fill properties
            recurseApplyCellFormula dghShape, visSectionObject, visRowFill, visFillForegndTrans, strTrans
            recurseApplyCellFormula dghShape, visSectionObject, visRowFill, visFillBkgndTrans, strTrans
            ' then the line properties
            recurseApplyCellFormula dghShape, visSectionObject, visRowLine, visLineColorTrans, strTrans

        End If

End Sub



'
' some of the shapes that are used are groups of groups, so the need
' is to change not only the top level shape but those that are grouped
' inside as well
'
Private Sub recurseApplyCellFormula _
    (ByVal visShape As Visio.Shape, _
    ByVal intSection As Integer, _
    ByVal intRow As Integer, _
    ByVal intCell As Integer, _
    ByVal strFormula As String)
   
    On Error GoTo ErrHandler
   
    Dim visCell As Visio.Cell
   
    ' set transparency of the shape
    If visShape.CellsSRCExists(intSection, intRow, intCell, 0) = True Then
        Set visCell = visShape.CellsSRC(intSection, intRow, intCell)
        visCell.FormulaU = strFormula
    End If
   
    ' if embedded shapes exist, recurse through them also
    Dim visEmbShape As Visio.Shape
    Set visEmbShape = Nothing
    If visShape.Type = visTypeGroup Then
        For Each visEmbShape In visShape.Shapes
            recurseApplyCellFormula visEmbShape, intSection, intRow, intCell, strFormula
        Next visEmbShape
    End If
   
ExitHandler:
    Exit Sub

ErrHandler:

    If Err.Number = -2032466648 Then
        'guarded
        Resume Next
    Else
        ' might want to know which shapes and cells are giving us problems
        Debug.Print Err.Number & " " & Err.Description & " " & visShape.Name & " " & visCell.Name
        Resume Next
    End If


End Sub



Title: Re: Making blocks with perspective transparent.
Post by: Visio Guy on March 17, 2009, 01:57:02 PM
Very cool, Al!

I especially like your GUARD detector:

    If Err.Number = -2032466648 Then
        'guarded
        Resume Next
        ...

Title: Re: Making blocks with perspective transparent.
Post by: aledlund on March 17, 2009, 02:27:46 PM
Chris,
thanks
as a note, by adding this before calling the recurse function you gain the ability to start globally applying format changes to data graphics. That's how I was changing the text attributes in the drawing I sent you.

    ' unlock the groups so we can change the font sizes
    recurseApplyCellFormula visShape, visSectionObject, visRowLock, visLockGroup, "0"

al