Visio Guy

Visio Discussions => Shapes & Templates => Topic started by: andlop on May 12, 2020, 09:18:25 AM

Title: Changing shape name
Post by: andlop on May 12, 2020, 09:18:25 AM
Hi! I know that it is possible to change a shapes name in the developer tab, but I wanted to know if it is possible to change it by adding a field in the Shape Data, and program it to do the same thing. Or it is possible to do the same thing, but using programming in the ShapeSheet.

Thank you!
Title: Re: Changing shape name
Post by: Yacine on May 12, 2020, 11:04:49 AM
I know it is not the answer to your question, but it is generally a bad idea to work with shape names.
Those named shapes could be deleted, moved to another page, just to name some of the problems.
You're better off by defining a certain property - eg a user or a prop field - and set its value to an arbitrary unique id (eg chosen by yourself).
To work with that shape, you would iterate over the shapes of the page and check for the existance of the property and its value.
I Hope the explanation is somewhat comprehensible.
Title: Re: Changing shape name
Post by: andlop on May 14, 2020, 06:24:01 AM
Understood, and how do I get the shape properties in the page, like its ID?
Title: Re: Changing shape name
Post by: wapperdude on May 14, 2020, 09:02:46 AM
The shape ID resides with the shape, not the page it's on.   You don't really want to added it to the page...That creates a lot of extra, unnecessary work.  It would be like hot gluing your socks to the drawer their in.
Title: Re: Changing shape name
Post by: andlop on May 14, 2020, 11:04:27 AM
But when a create a master, in the master page, the shape as one ID, but if I put that shape in a drawing I can't get the masters ID...
Title: Re: Changing shape name
Post by: Paul Herber on May 14, 2020, 11:27:44 AM
Within the stencil, a master has an index, but once the master shape has been dropped on a page that index is no longer available (nor is it useful or required). The only reference from the shape on the page is to the Master name.
Title: Re: Changing shape name
Post by: andlop on May 14, 2020, 11:38:51 AM
I have used the command MASTERNAME() in the ShapeSheet, to get the masters name when I drop it on the drawing. The thing is, my master name is "Roller conveyor", and the MASTERNAME() output is "Roller conveyor: Roller conveyor". I'm doing a application where I needed to this two names to be the same.
Title: Re: Changing shape name
Post by: Yacine on May 14, 2020, 01:29:22 PM
Understood, and how do I get the shape properties in the page, like its ID?

function getMyShape() as shape

  for each shp in activepage.shapes
    if shp.cellexists("user.MyIdentificator", visexistsanywhere) then
      if shp.cells("user.MyIdentificator").resultstr("") = "I am the right shape" then
        getMyShape = shp
        exit function
    endif
  next shp

end function