is allocation subshapes to parent shape possible? how?

Started by hidden layer, October 21, 2019, 09:02:31 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

hidden layer

Hello,
I'm using Visio 2010 in german version. Please excuse some spelling/ naming failures because I'm not sure if I have the right term (in english) at hand.

(1) I draw some shapes (lines, rectangles and text-shapes). At the textshapes i added prop-fields whose data comes from the master-shape after I make a Master (in the stencil) out of it. The textfields itself contains a field (menue: insert-> field) where I can add this text with right-click-> Data...

(2) Then I selected them and pulled them together to the stencil- place to make a master out of it. I did not group it before.

(3) Then I pull this master back to the sheet and this is kinda 'grouped' (with a separate shapeSheet for the whole Master/ Group...whatsoever)

(4) let's say I do this ten times. One text shape (of every Master/Group) contains a special term (3 characters); no other textshape in this Master/Group contains a term like this - but others. And some of the different Master/Groups have the same 3-character word inside the textshape.

(5) Now I want to make relations between the Master/Group if they have the same 3-character-word.

The pseudocode could look like this:


Dim shp as shape
Dim subshp as shape
'text inside < and > is pseudocode
For Each shp in ActivePage.Shapes
  <if cells("User.Type").FormulaU = "Slave" Then
        look around for the parent, get its ID and>
           cells("User.TLA").FormulaU = "=Sheet." & parentID & "!User.Master"
    End If
Next shp


I've looked around here and there but cannot find some snippets to make this working.

If you could push me in the right direction - that would be great. Maybe it's because I did not enter the right terms...

Thanks a lot,
hl

Yacine

Try the following:

Sub test()
    iter ActivePage
End Sub

Sub iter(obj As Object)
    Dim shp As Shape
    Dim parent As Object
   
    For Each shp In obj.Shapes
        If shp.CellExistsU("user.type", visExistsAnywhere) Then
            If shp.CellsU("user.type").ResultStr("") = "Slave" Then
                Set parent = shp.parent
                If shp.CellExists("prop.B", visExistsAnywhere) Then
                    shp.CellsU("prop.B").FormulaU = Chr(34) + Str(parent.ID) + Chr(34)
                End If
            End If
        End If
        iter shp
    Next shp
End Sub
Yacine

hidden layer

hello Yacine - wow! thanks a lot.

as always I didn't explain it 100% exact. It's a bit different. Sorry!

I started with making a stop-point at 'next shp' command.

For Each shp In obj.Shapes
shows "coil" if I hover at shp - this is the right shape.
   
If shp.CellExistsU("user.type", visExistsAnywhere) Then
shows -1 at shp.CellExists although the cell exists (?)
and thereafter it doesn't work as expected. And I didn't get a clue out of these visExistsAnywhere...

If shp.CellsU("user.type").ResultStr("") = "Slave" Then
shows ="coil" for example.. and then I was lost :(

Let's start again.
There are shapes which parents have 2 cells
- User.Type (which have to be "coil")
- Prop.BMK (which have to be stored in a variable a)
- ShapeID (which have to be stored in a variable b)

then I want to go through all shapes whose parents have a cell
- Prop.BMK (=a)
- User.Type (="contact")
- User.active (where the formula shall be =Sheet.b!User.active)

and after that start with the next shape(coil)

In simple words: the contacts of the relays shall move if the relay is active.
(like I did it with the wires in the attached vsd.)

Thanks again,
hl

hidden layer

#3
hi Yacine,
thanks for the push!

meanwhile I solved this 'by foot':

For Each mshp In ActivePage.Shapes
    If mshp.CellExistsU("User.Type", visExistsAnywhere) Then
        If mshp.Cells("user.type").ResultStr("") = "Coil" Then
            bmk = mshp.Cells("prop.BMK").ResultStr("")
            mID = mshp.ID
            For Each sshp In ActivePage.Shapes
                If sshp.CellExistsU("User.Type", visExistsAnywhere) Then
                    If sshp.Cells("user.type").ResultStr("") = "contact" Then
                        If sshp.Cells("Prop.bmk").ResultStr("") = bmk Then
                            sshp.Cells("user.active").FormulaU = pre & mID & suf
                        End If
                    End If
                End If
            Next sshp
        End If
    End If
Next mshp


I added some cells to the parent and linked them from (or to) the children and so I can work with the parents only. ;)

It works so far without complications (in my sandbox-like-space).

but if someone would like to make it bullet-proof - any hint is welcomed!

cheers
hl