Author Topic: Set text on EventDrop  (Read 1075 times)

0 Members and 1 Guest are viewing this topic.

Soundstorm

  • Jr. Member
  • **
  • Posts: 15
Set text on EventDrop
« on: August 05, 2022, 08:32:23 AM »
Hi

As I'm working on making a complete template for all our flow diagrams, I find a lot of cool things I can do with Visio, but I also seem to stumble upon some issues.

I have a shape for a valve. I want a piece of text next to it with a tag number. The shapes we used before had the automatic numbering thing included in Visio, but we have now decides on using a different numbering scheme. That scheme requires manual input of the tag number. So I included "V-xxxx" in the master shape. If you select the shape, you start typing and you can change the tag number to whatever you want. This is great and exactly what we want.

Now if we would copy/paste this shape, it would also copy the tag number. The chance of duplicates becomes high, because you have to pay attention when pasting shapes, especially when pasting large groups of shapes.

So my idea was to add a function in the EventDrop to set the text value back to "V-xxxx". But I'm running into some issues.
I know you can get the text value into the Shapesheet. I also know you can use fields to input text from within the Shapesheet.
But the field sections disappear once you start typing your own tag number, so all the formulas get lost or lose their references.

I was thinking of placing a function to rewrite everything in the TheText event, but that doesn't work either.

Any tips on how to proceed with this?

Thanks!

wapperdude

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4479
  • Ideas Visio-lized into solutions
Re: Set text on EventDrop
« Reply #1 on: August 05, 2022, 09:14:51 AM »
It's been awhile since I posted this, but it might give you some hints:  Of Field Insert Text: with / without VBA

Basically, what comes to mind id:
1) create a Shapedata entry for the tag number.  This will be the only means that a user can make an entry.
2) lock the text from editting. 
3) use the field insert to display the Shapedata entry.
4) on drop, it might be possible to clear the data entry.
5) set the DblClick event cell to Docmd(1312).  This will invoke the Shapedata window and prompt for tag number.

There are variations to this approach. 
Visio 2019 Pro

Paul Herber

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3310
    • Paul Herber's website
Re: Set text on EventDrop
« Reply #2 on: August 05, 2022, 10:27:12 AM »
Visio has a built-in addon that handles all the processing for P&ID shapes, including keeping track of and setting the shape IDs in the text.
Electronic and Electrical engineering, business and software stencils and applications for Visio -

https://www.paulherber.co.uk/

Surrogate

  • Hero Member
  • *****
  • Posts: 1639
    • ShapeSheet™ Knowledge Base
Re: Set text on EventDrop
« Reply #3 on: August 05, 2022, 10:40:11 AM »
Visio has a built-in addon that handles all the processing for P&ID shapes, including keeping track of and setting the shape IDs in the text.
This add on named Number Shapes

Paul Herber

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3310
    • Paul Herber's website
Re: Set text on EventDrop
« Reply #4 on: August 05, 2022, 10:55:33 AM »
No, it's called PESolution.
Electronic and Electrical engineering, business and software stencils and applications for Visio -

https://www.paulherber.co.uk/

Surrogate

  • Hero Member
  • *****
  • Posts: 1639
    • ShapeSheet™ Knowledge Base
Re: Set text on EventDrop
« Reply #5 on: August 05, 2022, 01:47:44 PM »
No, it's called PESolution.
Never met it. Find list of add-ons in this ancient thread  ;D

wapperdude

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4479
  • Ideas Visio-lized into solutions
Re: Set text on EventDrop
« Reply #6 on: August 05, 2022, 02:04:31 PM »
Not sure these addins provide the desired solution.  The "undertood" need is:
1) custom, "arbitrary" numbers.
2) numbers are not linked to their sequential placement on drawing page, thus not automatically created.  Manual is OK, but...
3) existing number must be reset in a copy/paste scenario.  No duplicates!!!
Visio 2019 Pro

vojo

  • Hero Member
  • *****
  • Posts: 1678
Re: Set text on EventDrop
« Reply #7 on: August 06, 2022, 09:14:06 AM »
for 1 and 2 and 3

user.unique_id = rand() + ID()    // I believe would make the number WW unique...you can replace with desired number
                                        // also since ID is the sheet.<ID>, copy and paste would make number different for new shape
                                        // if you manually update number, then would need to update manually after copy paste

could also do
user.id = id()
user.hdr = "<some header text>"   // can put in props.cell to use GUI ==> trigger to edit would be DOCMD(1312).
user.wholeID = concat(user.hdr, user.id)

use user.wholeID for whatever you want


wapperdude

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4479
  • Ideas Visio-lized into solutions
Re: Set text on EventDrop
« Reply #8 on: August 06, 2022, 11:08:56 AM »
I didn't intend to put words in the ops mouth, but it does seem I may have inadvertently created confusuion. 
@Vojo:  the numbers in (1) are not shape IDs.  As I interpret, these might be product numbers.   Thus, they are not random numbers.   In (2), the user does manually enter the number.  In (3), the user is allowed to copy/paste.  Then, the previously entered number of the copy must be edited.  No duplicate numbers.  So, (3) would reset this value upon drop/paste, forcing the user to edit/update the value.

It's not that complicated.  The OP just wants the reset to work on drop.
Visio 2019 Pro

vojo

  • Hero Member
  • *****
  • Posts: 1678
Re: Set text on EventDrop
« Reply #9 on: August 06, 2022, 04:41:25 PM »
ZZZZZZZZ... thanks for playing!!!

check the shapesheet function ID() in all the docs

basically, a shape name is sheet<sheet number>.<id number>

sheet1.1 = is first shape droppe.....id() = 1
sheet1.9876 = the 9,876 shape dropped....id() = 9876

Yacine

  • Hero Member
  • *****
  • Posts: 3005
Re: Set text on EventDrop
« Reply #10 on: August 07, 2022, 03:26:21 AM »
I'm very late to join, but I may drop my 2 cents too.

There are two aspects to this post. The exact answer to OP's question and the elaboration on his real needs.

Getting just a unique number as Vojo suggests would work to answer the question. But this is not how PFDs work. (1) It's the whole tag, that needs to be unique and (2) you don't want to have weird numbers completely separated from any sorting order.

The tag can be something short, like V-xxx for valves or P-xxx for pumps.
But more often you - actually the electricians and the programmers - will want to subdivide the drawing into functional groups. So you'll add a code in front the "part type" and "number" to get something like 815-V-13.

And if the equipment gets bigger (several machines = several electrical cabinets) and bigger (several lines) you can end up with:
  location code / line code / machine or cabinet code / function code / part code / number.

The PESolution that Paul suggested does already answer OP's question. It has a "renumbering" function that will eliminate duplicates.
It includes also some features to change the tagging category, etc.

Unfortunately it lacks the long tagging option. This long prefix could be written as "dumb" text in a corner of the drawing to allocate all the shapes to this one group.

My advice would be:
- if you draw PFDs only occasionaly stick with PESolution.
- if you want to get serious with tagging write your own code! I can provide some support if needed.

Resources - You may want to have a look at the following norms
- EN 81346
- EN 62424
- ISA 5.1 (https://vdocuments.net/isa-51.html)






Some additional thoughts about a custom implementation.


- When renumbering, collect first all the prefixes - every thing that's in front of the number, then do the actual renumbering for each prefix.
- Think of improving the readability for instance by sorting the shapes by columns (ranges of x coordinates) and rows (y coordinates). So knowing your number you can visually find the shape much faster.
- When preparing the prefixes, think about grouping some. eg: say you have different valve types with different drives VP (pneumatical v.), VE (electrical), VM (manual). But to avoid renumbering when you want to change a drive, you would better number over all Vx - regardless of the drive type. Or in other words, don't number of sub-groups.
- The actual tagging - assigning values to different grouping fields - is only indirectly connected to the displayed text. When the tags get too long (over 7-8 characters), you'll want to de-clutter the drawing by surrounding shapes of a same group by a frame displaying the group's text. The shapes themselves would only display the last part of the tag. Thus the setting of the text displayed needs to be easily adjustable.
- When adding new numbers, consider if you want to use the gaps the numbering or only append to current numbering.
- You may also consider a differentiation between standard parts and project specific ones. e.g.: new parts start from 100.
- When renumbering you may think about preserving already existing sorting orders. Think about changes made in project in progress. Don't modify already allocated tags, unless there is very important reason for it and you documented it properly!!!


You see the list of considerations is quite big and it's only the ones I put up in 10 minutes.
« Last Edit: August 07, 2022, 04:10:05 AM by Yacine »
Yacine

Soundstorm

  • Jr. Member
  • **
  • Posts: 15
Re: Set text on EventDrop
« Reply #11 on: August 08, 2022, 02:10:31 AM »
Wow, that's a lot of replies and insights! I didn't have time over the weekend to look into this, but I did think about a solution.

I'll elaborate the issue I have first:

We are building test skids that are used in a University laboratory. These things are 'living entities', so they get changed a lot.
Up to last year, we have always been using the built in Visio numbering mechanism, where a valve would be V-xxx, and the number just keeps incrementing. This becomes really difficult once you start adding V-209 right after V-035 on page 2, and on page 5 there is V-208 and V-210. Sometimes Visio also manages to duplicate numbers, and you have to go look for those manually. At that point, you can't use the renumber function anymore, because there are valves in the field tags attached.

We now came up with a numbering solution that should work properly:
XX-ABC
Where XX is the device type, A is the section of the setup (1 digit), B the subsection (2 digits) and C is the unique identifier.
By doing this, we get the benefit that we might have a tank, with heating, pressure measurement, level measurement,... Those would all have the same tag number, making it more easy to organise all documentation and identifying on the diagram.

So adding a tag number will be a manual action for sure. You can't link to any shape ID, because that wouldn't help at all. I also want it to be clear that the tag number hasn't been given yet, so a newly dropped or copied shape should always have XXXX.
You can instruct to always drop from the stencils (so you don't copy the tag numbers), but sometimes you have made an assembly of shapes that need to be duplicated. And at that point, you would duplicate the tag number.

So wapperdude his summary is correct
Not sure these addins provide the desired solution.  The "undertood" need is:
1) custom, "arbitrary" numbers.
2) numbers are not linked to their sequential placement on drawing page, thus not automatically created.  Manual is OK, but...
3) existing number must be reset in a copy/paste scenario.  No duplicates!!!

Having the tag number in the shape data would indeed give more solutions. But the ease of workflow when just have to select a shape, and start typing is something we need. There is of course shape data to be filled in (part numbers etc), but that is mostly at a later stage.

The solution I have in mind, and will give a try today is the following:
- Add a text shape to the group, this shows text from a user field
- Hide the text of the shape
- Add a function the event TheText to update the user field to whatever that was entered
- Add a function to the event EventDrop to set the user field to V-xxxx

I may add a menu item to restore an old tag number, in case you did a cut/paste action. Then it's just a right and left click to restore the number instead of having to retype.

Soundstorm

  • Jr. Member
  • **
  • Posts: 15
Re: Set text on EventDrop
« Reply #12 on: August 08, 2022, 03:26:09 AM »
Ok, that doesn't work  ::)

It seems that when dropping the shape, it does both events, and TheText event is the last one it does...

vojo

  • Hero Member
  • *****
  • Posts: 1678
Re: Set text on EventDrop
« Reply #13 on: August 08, 2022, 07:45:45 AM »
works fine

Attached is the ensence of what I believe you want to do
Look at shapesheet for details

wapperdude

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4479
  • Ideas Visio-lized into solutions
Re: Set text on EventDrop
« Reply #14 on: August 08, 2022, 08:01:16 AM »
It's early, coffee hasn't kicked in yet...  so, I haven't processed your latest implementation approach.

Nonetheless, couple of points.  Instead of using both events, you might try catenating commands in the event drop cell.  For example, =setf(getref(User.tag),"V-xxxx")  + Docmd(1312).  Both commands, sequentially, push text into user.tag, and field insert displays the current value.  You can add more commands, e.g., show/hide text.  The idea being, haven't tried this out, is that on drop the tag text is reset and then the Shapedata UI form is invoked allowing new info to be added.  (Although, Shapedata can be called on drop ( I don't normally do this), and, I think, it can be set to default to the reset text.  That is, both commands are built-in.  But for sake of example, I wanted to show catenations that are applicable.
« Last Edit: August 08, 2022, 08:08:01 AM by wapperdude »
Visio 2019 Pro