How to control master shape group position relationships and set limits.

Started by Mouthpear, August 09, 2022, 11:32:29 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Mouthpear

OK I have a Chicken Pop Door Master that I use to illustrate to people how an automated door with pressure switch as a safety feature is wired. I want to show the door in three different positions. Open, Mid and Closed. With it the wires, door sensor, and the pressure switch. As it is now I have to copy the Door, the wires, part of the sensor and the pressure switch three times and put them in three different layers. I would much rather have only one setup and have the three positions as, I'm guessing, a Shape Data thing where I can right click on the shape and choose Open, Mid or Closed. All the while making sure the door stays centered horizontally to the door frame.

Also I would like to know if it is possible to keep the Egg cut out that's in the door frame centered horizontally with the frame and maintain it's size and shape when the door frame itself is resized. The door frame itself will be needed to resized but the opening (Egg cut out) will not change size or shape within the door frame.

I have tried to figure it all out in the shape sheet but don't even know where to start.

Keep in mind I have not been using Visio on this level just making simple shapes and diagrams. I want to learn do make the more efficiently.


Attached file Page 1 shows door positions. Page 2 shows how I am having to do it right now. Three Layers with 16 shapes, copies of the same things, each.

TY

Edit I am not looking for a VBA solution at this time. I am not ding this with VBA since, when people want to use my diagrams they don't have to worry about the VBA warning.

vojo

Overall, this is pretty easy

1) the piece that slides up and down = slide.....piece with the hole = back
2) draw slide....draw the back
3) align them ....then group them...lets say this is sheet.999...slide is sheet.1...back is sheet.2
4) at group level...2 ways to accomplish
     4a) use props to create a props.cell ( sheet.999!prop.slide (also called shape data)....
           cell name = prop.slide...format is list ...
           play with it to undrestand...list might be = "open" "mid" "closed".....from here on out prop.slide  lets call it slider
           read up on prop cells
     4b  use action cells...1 for close, 1 for mid, 1 for open
           actual action.close = setf(getref action.close.checked ), action.close.checked = 1 +
                                          action.mid.checked = 0 + action.open.checked = 0)        //read up on action rows
5) select the slide shape (sheet.1) and open shapesheet
6) create a a user cell and lets assume using 4a above......
     sheet.1!user.slideY = if(strsame(sheet.999!prop.slide, "open"),1,if(strsame(sheet.999!prop.slide, "mid"), 4,
     if(strsame(sheet.999!prop.slide, "close"), 8, NA))))
     ///this basically creates an offset index for moving the slider up and down...you can play with 1,4,8 as you want
7)  in sheet.1!piny = <initial value before all this> + user.slidey*40mm   
     ///should study guard function...guard prevents this value from being changed by UI
8) get out of all these shapesheets
9)  got to shape data and select the slide field...select the list entry you want
     if you pick "close", sheet.1 should slide all the way down and close the hole
     if you pick "mid", sheet.1 should slide halfway down partially close the hole
     if you pick "open:, sheet.1 should be at top and have the hole fully open

Be sure to do all the reading since the devil is in the details....start simple to understand behaviors
(maybe make sure 2 shapes in group move around as you want...then figure out 4) works...then combine the learning)

Mouthpear

Thank you very much for your quick response. Saw it this morning gave it a go. Did not get it to work. I would elaborate but I just got home from work and am dawg tired. Just wanted to let you know I appreciated the reply, before I head to the shower then bed. TY

Soundstorm

I was in a similar situation as you, the forum helped me, and I learned a lot from it. So I hope I can do the same now.

This is how I would solve your problem. I think it is similar to what vojo suggests.
I made changes on page-2, you can just right click or use shape data.

Mouthpear

Quote from: Soundstorm on August 11, 2022, 09:36:46 AM
I was in a similar situation as you, the forum helped me, and I learned a lot from it. So I hope I can do the same now.

This is how I would solve your problem. I think it is similar to what vojo suggests.
I made changes on page-2, you can just right click or use shape data.

Thank you very much. Yes it works for what I need.

Reason It has taken me a bit to reply is that you grouped all the parts(shapes) together. I kept trying to seperate them all but I would keep losing the data each time I would remove shapes from the groups. I finally just had to start over, but even tho I would try and keep the formulas the same, just changing references here and there, I could not get it to work. I then hit a "taking off point" where I figured out one of the shapes had a "bad" name. No underscores as spaces and no number ID. And BAM! It was back up and running.

Felt good with that but as always, I wanted to get more out of it. Added check marcks for the active selections and made the Limit Switch actuate with the selected position.

I appreciate your help. Thank you.

Mouthpear

Quote from: vojo on August 09, 2022, 12:39:26 PM
Overall, this is pretty easy

1) the piece that slides up and down = slide.....piece with the hole = back
2) draw slide....draw the back
3) align them ....then group them...lets say this is sheet.999...slide is sheet.1...back is sheet.2
4) at group level...2 ways to accomplish
     4a) use props to create a props.cell ( sheet.999!prop.slide (also called shape data)....
           cell name = prop.slide...format is list ...
           play with it to undrestand...list might be = "open" "mid" "closed".....from here on out prop.slide  lets call it slider
           read up on prop cells
     4b  use action cells...1 for close, 1 for mid, 1 for open
           actual action.close = setf(getref action.close.checked ), action.close.checked = 1 +
                                          action.mid.checked = 0 + action.open.checked = 0)        //read up on action rows
5) select the slide shape (sheet.1) and open shapesheet
6) create a a user cell and lets assume using 4a above......
     sheet.1!user.slideY = if(strsame(sheet.999!prop.slide, "open"),1,if(strsame(sheet.999!prop.slide, "mid"), 4,
     if(strsame(sheet.999!prop.slide, "close"), 8, NA))))
     ///this basically creates an offset index for moving the slider up and down...you can play with 1,4,8 as you want
7)  in sheet.1!piny = <initial value before all this> + user.slidey*40mm   
     ///should study guard function...guard prevents this value from being changed by UI
8) get out of all these shapesheets
9)  got to shape data and select the slide field...select the list entry you want
     if you pick "close", sheet.1 should slide all the way down and close the hole
     if you pick "mid", sheet.1 should slide halfway down partially close the hole
     if you pick "open:, sheet.1 should be at top and have the hole fully open

Be sure to do all the reading since the devil is in the details....start simple to understand behaviors
(maybe make sure 2 shapes in group move around as you want...then figure out 4) works...then combine the learning)

I was not able to get it to work with your way. Rather than go over you instruction point by point maybe you can take a look at the formulas that I ended up using that are kinda close to what you stated. Or do it the way you wrote. I really would like to see and understand what you were intending.

On another note. When you say "read up on action rows" "read up on prop cells", can you provide a link to a good site to read up on them. I did google and bing searches with those words "Visio" "prop cells" "action rows" and after going 10 pages deep of results I still could not find anything. It was mostly VBA (that I can't use) stuff and stuff unrelated. In fact that's why I'm here actually posting the question. I usually can figure stuff out by reading posts on forums.

Again I would really like to see how you would do it. Uploaded my attempt to do it your way.






Surrogate

Quote from: Mouthpear on August 14, 2022, 02:18:54 AMWhen you say "read up on action rows" "read up on prop cells", can you provide a link to a good site to read up on them
Hope this link can helps, with this code you can iterate rows in Shape Data (aka Custom Properties) section
Public Sub RowCount_Example()

Dim vsoStencil As Visio.Document
Dim vsoMaster As Visio.Master
Dim vsoPages As Visio.Pages
Dim vsoPage As Visio.Page
Dim vsoShape As Visio.Shape
Dim vsoCell As Visio.Cell
Dim intRows As Integer
Dim intCounter As Integer

'Get the Pages collection for the document.
'ThisDocument refers to the current document.
Set vsoPages = ThisDocument.Pages

'Get a reference to the first page of the Pages collection.
Set vsoPage = vsoPages(1)

'Get the Document object for the stencil.
Set vsoStencil = Documents("COMPS_U.VSS")

'Get the Master object for the desktop PC shape.
Set vsoMaster = vsoStencil.Masters("PC")

'Drop the shape in the approximate middle of the page.
'Coordinates passed to the Drop method are always in inches.
'The Drop method returns a reference to the new shape object.
Set vsoShape = vsoPage.Drop(vsoMaster, 4.25, 5.5)

'The second method of accessing custom properties uses
'section, row, cell. This method is best when you want
'to iterate through all the properties.
intRows = vsoShape.RowCount(Visio.visSectionProp)

'Loop through all the rows and add the value of Prop.Manufacturer
'to the list box. Rows are numbered starting with 0.
For intCounter = 0 To intRows - 1
Set vsoCell = vsoShape.CellsSRC(Visio.visSectionProp, intCounter, visCustPropsValue)

Next intCounter


End Sub

Mouthpear

Quote from: Surrogate on August 14, 2022, 05:41:20 AM
Quote from: Mouthpear on August 14, 2022, 02:18:54 AMWhen you say "read up on action rows" "read up on prop cells", can you provide a link to a good site to read up on them
Hope this link can helps, with this code you can iterate rows in Shape Data (aka Custom Properties) section
Public Sub RowCount_Example()

Dim vsoStencil As Visio.Document
Dim vsoMaster As Visio.Master
Dim vsoPages As Visio.Pages
Dim vsoPage As Visio.Page
Dim vsoShape As Visio.Shape
Dim vsoCell As Visio.Cell
Dim intRows As Integer
Dim intCounter As Integer

'Get the Pages collection for the document.
'ThisDocument refers to the current document.
Set vsoPages = ThisDocument.Pages

'Get a reference to the first page of the Pages collection.
Set vsoPage = vsoPages(1)

'Get the Document object for the stencil.
Set vsoStencil = Documents("COMPS_U.VSS")

'Get the Master object for the desktop PC shape.
Set vsoMaster = vsoStencil.Masters("PC")

'Drop the shape in the approximate middle of the page.
'Coordinates passed to the Drop method are always in inches.
'The Drop method returns a reference to the new shape object.
Set vsoShape = vsoPage.Drop(vsoMaster, 4.25, 5.5)

'The second method of accessing custom properties uses
'section, row, cell. This method is best when you want
'to iterate through all the properties.
intRows = vsoShape.RowCount(Visio.visSectionProp)

'Loop through all the rows and add the value of Prop.Manufacturer
'to the list box. Rows are numbered starting with 0.
For intCounter = 0 To intRows - 1
Set vsoCell = vsoShape.CellsSRC(Visio.visSectionProp, intCounter, visCustPropsValue)

Next intCounter


End Sub




Thank you but I am not looking for a VBA solution at this time. I am not ding this with VBA since, when people want to use my diagrams they don't have to worry about the VBA warning.

Surrogate

Sorry, but i dont know ways iterate (read) rows in section without VBA  :(
QuoteI then hit a "taking off point" where I figured out one of the shapes had a "bad" name
What you mean as bad name? Can you share more details?

Mouthpear

Quote from: Surrogate on August 14, 2022, 05:13:22 PM
Sorry, but i dont know ways iterate (read) rows in section without VBA  :(
QuoteI then hit a "taking off point" where I figured out one of the shapes had a "bad" name
What you mean as bad name? Can you share more details?

"I then hit a "taking off point" where I figured out one of the shapes had a "bad" name. No underscores as spaces and no number ID."

Renamed sheet to
Chicken Pop Door Soundstorm

Still not working
Chicken_Pop_Door_Soundstorm

Started working when I added the .1
Chicken_Pop_Door_Soundstorm.1

Surrogate


wapperdude

Since most of the heavy lifting was already done, I just did modification to keep the egg opening to remain constant size, constant position relative relative to horizontal center and vertically from bottom of the edge.  All of the changes were in geometry 1.  Some formulae were modified to be based off LocPinX.  Other cases had the width/height references changed to hard initial design values.
Visio 2019 Pro