BB code in posts seems to be working again!
I haven't turned on every single tag, so please let me know if there are any that are used/needed but not activated.

Main Menu

problem with shape.gluedshapes

Started by perry59, July 07, 2022, 06:32:55 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.


I am working on a routine which will trace an electrical circuit which consists of 2D shapes representing contacts within electrical connectors and 1D shapes (visio connectors) representing wires. It can span multiple sheets and drawings by using a custom "sheet reference" shape which has destination data within the reference shape. It displays the completed circuit as text in a dialog box. I have been happy with it in testing, it successfully displayed a circuit that started with an output signal on one drawing, spanned through a second drawing and ended with the output signal on a third drawing. It displayed all the contacts and wires in order that made up the circuit.
When testing on a simpler scenario, where the whole circuit was on a single drawing but started on one page and ended on another I ran into a problem. The problem came down to the shape.gluedshapes function. I called this function on a (electrical contact) shape which had a wire (visio connector) glued to it. Stepping through the debugger, I have watches for shape names and shape ID's (and shape unique ID's). When the shape.gluedshapes function is called with the electrical contact as its input I can see by my watches it has the right shape. So, it should fill an array with with the shapeID's of any shapes glued to it (the visio doc says they are longs, but I have to use int32 or get compile errors). Looking at the array, there is only one shapeID in there, as expected because there is only one "wire" attached to the shape. This is where it gets weird. The shapeID in the array is 108 which is the ID of the wire (connector) but when I retrieve the unique shape id of the object in the array it is NOT the unique shapeID of the wire! Also, the shape name of the wire is "wire", the shape name of the object in the array is "designator.10", a completely different shape well away from the wire that is glued to the contact which I should be getting.
So how is shape.gluedshapes getting a shape that is NOT glued to it?
Something I dislike about the shape.gluedshapes function is it returns shape.ID's which are not guaranteed to be unique, especially if I am traversing multiple sheets and documents I think it would be much better if it could return uniqueID's. Apparently there is another shape on the sheet in question which has the same ID of the shape that I really want. But I still don't see how the function is returning a shape that is not glued to it!!!
I hope I have explained my problem clearly, I've attached a screenshot of the test drawing which may help.
Does anyone have any insights on what may be going on here?
Thanks for any help
what, me worry?


Never mind, I found the problem, when I was pulling shapeID's from the array I was looking for shapes on the ACTIVE page which was not necessarily the correct page!
I change the offending line of code from:
contactShape = Globals.ThisAddIn.Application.ActivePage.Shapes.ItemFromID(contactIDs(i))       
contactShape = Globals.ThisAddIn.Application.ActiveDocument.Pages(_vsoPage.Name).Shapes.ItemFromID(contactIDs(i))
what, me worry?


Very recognizable for me, the "how did I overlook this simple thing" feeling! Good you found the issue.
Visio 2021 Professional

Browser ID: smf (possibly_robot)
Templates: 4: index (default), Display (default), GenericControls (default), GenericControls (default).
Sub templates: 6: init, html_above, body_above, main, body_below, html_below.
Language files: 4: index+Modifications.english (default), Post.english (default), Editor.english (default), Drafts.english (default).
Style sheets: 4: index.css, attachments.css, jquery.sceditor.css, responsive.css.
Hooks called: 177 (show)
Files included: 34 - 1306KB. (show)
Memory used: 1103KB.
Tokens: post-login.
Cache hits: 14: 0.00132s for 26,766 bytes (show)
Cache misses: 3: (show)
Queries used: 16.

[Show Queries]