-3

I need to get all the shape name from the visio document.(ie) If i have two task shape in visio it automatically rename as

task.1 and task.2 in visio

But i need to get the name "TASK". Is it possible to get that name..

I can get the unique name of a shape by using

foreach (visio.Shape shp in shape.Shapes)
        { shp.NameU // i can get task.1 and task.2 }

But i need to get the name "TASK"

Dah Sra
  • 2,493
  • 2
  • 22
  • 56

2 Answers2

1

You should probably use "master" name and not shape name if you want to figure out the shape "type". That is, try Shape.Master.Name

Shape name (and nameU) is built by Visio automatically from it's master name and it's number of instances.

Nikolay
  • 7,487
  • 2
  • 18
  • 38
  • 1
    But when i try this Shape.Master.Name also am getting the same task.19 only – Dah Sra Mar 03 '15 at 12:38
  • 1
    Ah. then your master is named like that already probably. (Task.19). You can check out the list of masters in the document (Document -> Drawing Explorer) If you just want a marker for your shape, you can just add that as a specific shape-sheet cell for example, so you don't need to rely on names. – Nikolay Mar 03 '15 at 12:39
  • Si it's not possible to get that shape name right.? – Dah Sra Mar 03 '15 at 13:02
  • can you please tellme why in my masters am having both name Task ans Task.13 – Dah Sra Mar 03 '15 at 13:13
  • 1
    It depends on what you mean on "shape name". I.e. in principle you can assign any name to a shape, visio just provides a reasonable default. Name does not identify shape type. About masters "Task" and "Task.13" - when you edit a master and draw a new shape to the drawing, Visio adds new master copy to the document stencil. – Nikolay Mar 03 '15 at 13:27
  • Does it have a chance to add a new master copy to stencil automatically...? – Dah Sra Mar 03 '15 at 13:38
  • Hmm didn't quite get what you mean; Visio documents are self-sufficient, i.e. they contain everything they need and do not depend on each other. For example, a drawing document contains all masters it needs, so it is actually independent from stencils. Every time you drop a shape to a document, it's master is also copied to the document (uless it exists there already). – Nikolay Mar 03 '15 at 13:53
  • my problem is in my Visio document I didn't edit the master name . Even Though name of master get renamed . – Dah Sra Mar 03 '15 at 13:56
0

You can assign your own name. The NameU property of the Shape class pecifies the universal name of a Shape object. You can change it programmatically.

Also you may find the following properties of the Shape class helpful:

  • ID - gets the ID of an object.
  • NameID - returns a unique name for a shape.
Eugene Astafiev
  • 26,795
  • 2
  • 13
  • 31