SETATREF doesnt work with master shapes

Started by Sereda, August 22, 2012, 10:47:22 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Sereda

Hi

I have created a grouped header shape. The group contains two rectangles, one for Issue and one for Date. The issue and date are stored in the documents shape-sheet in user defined cells named 'User.Issue' and 'User.Date'. Each of the two rectangles have a user-defined cell named 'User.Text' referencing to either 'TheDoc!User.Issue' or 'TheDoc!User.Date'. Each rectangle have a text-field linked to its own 'User.Text' to display the header information.

the header group has two shape data rows with the respective formula in the value field:
SETATREF(TheDoc!User.Issue)
SETATREF(TheDoc!User.Date)

This way the information can be changed from any header in any page in the document. This is all fine.

BUT!!

I would like to have the header in my stencil and drag'n drop it when needed. But then it doesn't update properly. If I change the data from one header, I need to 'force' Visio to refresh, and it still doesn't work 100%.

If I delete the Master automatically created in the document stencil, it starts to work again.

Questions:
Is there a better way to do this?
Can I prevent a master from beeing created when drag'n dropping from the stencil?

This is driving me crazy!!
BR
Anders Aadin

Jumpy

First: Can I prevent a master from beeing created when drag'n dropping from the stencil?
I don't think so, as that is Visio's mechanism to keep the drawings filesize small.
The first drag and drop creates the master in the document stencil and a copy of that master as a shape on the page. But that copy is more a reference to the master, to  keep the memory usage small. Every shape based on that master, that is than dropped to a page, is only a referende to that master, too.

As to your problem. Have you looked at the shapesheet of such a new shape? What formulas are in your custom cells? Are there any Ref()-Errors?

vojo

I dont seem to have this problem (visio 2003).

Basically, I use Setatexpression (or whatever that function is called) to align a master shape, on drop, to a coordinate system on the page
(basically, to make sure the master shape lines up on a isometric axis).   In my case, these functions are in the pinx and piny cells.

On 2003 at least, there is decent help files for this (not like the LOC or PAR functions which after 10 years, I still dont understand
how they actually execute).

Sereda

Hi Jumpy

I checked the formulas and they did not 'break' during the drag'n drop.

I think it has something to do when different shapes are refreshed.

Example:
I change the value through shape-data and nothing happends. If I then double-click one of the shapes to enter 'edit-text-mode' it is refreshed and the previous changes are visible (but only in the one I double-clicked). But as soon as I delete the master, these refreshes occure instantaniously on all shapes and there is no need to 'force' a refresh'.
BR
Anders Aadin

Sereda

#4
Hi Vojo

You are right, but my problem comes later. When I drop the shape from the stencil, it directly updates its fileds to whatever is in the TheDoc!User.Issue. I guess this is what happends when you drop your shape and it reads the coords from another place.

But have you tried ochange the coordinates afterwards from a shape-data filed and seen that all your geometry moves? This is where it stops working for my header. It is when I try to update the data that fails.


BTW:
I checked LOC out and it was a bit confusing, but I got it to work. I made two rectangles with one of the shapes having a second geometry-section. That section was a simple line that should point from the centre of the main shape to the pivot point of the second shape.

I put "PNTX(LOC(PNT(Sheet.2!LocPinX,Sheet.2!LocPinY))) " in the X column of the 'LineTo' and similar for the Y-column.

PNT creates a coordinate object of the local coordinates of Sheet.2
LOC returns the same point but relative the Sheet.1 coordinate system
PNTX/PNTY extracts the X and Y parts of the new coordinate (the one relative to Sheet.1)

I had some problems first, but it was because I used PinX/Y and these are absolute coords. But LOC assume they are relative, so the further away the shapes were, the greater the error and confusion :)

It still doesn't help me with my first problem though  ::)
BR
Anders Aadin

Jumpy

Is only the field in the Text not refreshed, or is the User.Text cell in the ShapeSheet not refreshed, too?

Maybe you could force a refresh with a +Dependson(TheDoc!YourCells) somewhere?

vojo

sorry....my reference to LOC and PAR was that they never made sense to me (especially if the 2 shapes are different).   I was not suggesting that LOC or PAR could be used in place of SETATREF

I think if you want to do
   A)   take a cell from one shape and place in a cell in another shape....You should do this
         SETF(GETREF(<dest shape cell>), <F(<srce shape cell>)>)            I.e place srce info that was modified (or not) into dest cell
         For example:   take the value of shapes 1 user.num cell and add 2 to it and place int shape 2 then
         SETF(GETREF(sheet.2!user.rslt), sheet.1!user.num + 2)

   B)   want to intercept the UI for this given cell and more the inbound info....its more like this
         SETATREF(<dest shape cell>, SETATREFEVAL(<srce shape cell>)) kind of thing
         I dont know if you can actually put cell references in eval or its just a call to catch UI inbound values....but I believe its something like this

Sereda

Hi, sorry for the late reply but I had other assignments at work.

Jumpy:
It seem like the cells are updated correctly, but not the actual graphics. If I select a shape and hit F5 (fullscreen), that shapes graphics updates (and sometimes another). Or if I select a shape and hit F2 (text edit) it also refreshes. So I think the broblem is a bug (or missing feature) in Visios refresh-functionality. DEPENDSON didn't seem to work... I will try it out more when I get the time...

Vojo:
No problem, I realised that you were refrencing to poor documentation, but that triggered my curiosity and I had to check it out ;)
I didnt get that to work either. I think my problem is that it should work both ways:

If I update the shape-data then TheDoc!User.Header should be updated
If TheDoc!User.Header is updated by another header, my shape-data shoul also be updated.

Thanks for the interesting discussion. I will change employer next week and unfortunatly they do not use Visio (to my knowledge), so I will be unable to continue this investigation :(

BR
Anders Aadin

vojo

np.....

But I think that kind of behavior (x==>Y   Y==>x) only works on a given page.   I dont think having info at the Doc level forces shapes on a
given page to update.    For example, I know for sure that if do something on 1 page, it doesnt affect the other pages in the drawing.

One thing you could explore is the following:   The edit==>replace function has the options for selection or all shapes.   May want to record a macro of that action and see how it deals with walking thru the shapes, making changes, etc.

BTW, you could look at this in a different way....may your environment a template with all the pertinent stencils and such.   With that you could
harden all links needed

I general, this to be one of the short comings of Visio (ability of a shape to "explore/discover" other shapes dynamically).   Too bad 2013 doesnt address that kind of behavior (use shape_type || universal ID per shape and have a function that can walk the shapes looking for it....once found, user can, apriori add user cells to signal more user friendly info...so on say drop:  discover each shape, look at user cells, take action based user.cell value, etc).    I know this could be done in VBA....but that is not the point since that forces user to do all this coding to get there.
   
I am thinking something like  SHAPE_EXPLORE(<user.cell as handle>,<handle value>,<user.cell of interest>, <get/set>, <set value>)....put this in any cell (maybe with a dependson or IF(...) to trigger if needed) and it will interrogate the shape DB for all shapes (in doc or even on page only), on each shape look for user cell handle value, if found, look for user cell of interest, do get or set.

And of course it would be great to add functions like this could be added to the function table vs have to use CALLTHIS(....) or similar.

And finally, the grand vision would be to do something akin to DHCP.   On shape drop, the shape would register itself in special DB as a shape to be visible to all other shapes....use that subset shape DB as the DB to interrogate.   This would be more complicated but would speed things up and would protect some shapes from inadvertent changes.   I.e. could even open the door for logical sub collections of shapes (for a page...class 1 has  13 network fabric shapes....class 2 has 24 server shapes....class 3 has 10 blah blah shapes....etc.....class specified when registering...any new shape could use class index to subset even further)

Just some musings