Main Menu

Recent posts

#21
ShapeSheet & Smart Shapes / Re: SETATREF(Height) / EventXF...
Last post by wapperdude - April 23, 2024, 07:40:28 PM
Couple additional notes: 
>  Your usage of SETATREF is not correct.  The cell reference is intended to be the target for action, not the trigger.  Instead, use CALLTHIS("ConnPtAdjust")+DEPENDSON("Height").  For reference, see https://learn.microsoft.com/en-us/office/client-developer/visio/setatref-function and https://visguy.com/vgforum/index.php?topic=6383.msg26308#msg26308  This applies to all 3 of your SETATREF formulae.

>  I'm having trouble getting the code to run manually, but don't have time to investigate.  However, I recommend deconstructiong it, without the error stuff and without the auto-triggering.  Just add rows and delete.  You can step thru using <F8>, and you can set execution breakpoints.  There should not be any re-triggering.  Keep the control point count low.  I'm not convinced the code fully restricts adding / deleting.  Then, add the +Dependson statement in shapesheet.  Keep breakpoints in code.  See if behavior is as desired.  Finally, remove breakpoints and let code fully run.

>  As resizing the height is the trigger, moving should not be an issue.  Also, duplicating should not be an issue if the code is properly checking row count and connection position. There should not be any retriggering, or if there is, it's of no consequence.
#22
General Visio / Re: Why does Visio show two di...
Last post by Surrogate - April 23, 2024, 06:44:49 PM
Quote from: wapperdude on April 23, 2024, 04:15:07 PMThere was a discussion, not too long ago, related to this, but don't recall specifics.
Do you mean this thread?
#23
ShapeSheet & Smart Shapes / Re: SETATREF(Height) / EventXF...
Last post by Yacine - April 23, 2024, 06:00:50 PM
Your observation is right. When you drag something (shape or size handle) the event gets fired multiple times. You can observe this if you run the events manager.

Why not put the macro on an action command (right button menu, then deliberately run the command)

Other option, but slightly more complex. Let the macro know that you've finished the resizing.
Define a general variable to hold the time. You're macro checks first the time between the current call and the value stored. If difference is small (threshold), it stores the current time in the global variable and leaves, otherwise it runs the actually intended code.

'*******************************
Public lastcall As Double
'*******************************


Sub ConnPtAdjust(shp As Visio.Shape)
    ' this will add remove conection points from some shapes - Box, Device, EGSE after shape is resized
    ' this macro is called from the shapesheet of the resized shape
    ' shp is passed into this routine from when it is called within the shapesheet
   
    ' connections points for these shapes are defined from the top down (connection point 1 and 2 are top/bot mid; cp3,4 is upper most left/right; cp5,6 are cps below 3,4
    ' additional connection points req to be added if last connection point Y value is >= 0.875 inches
    ' connection points req to be deleted if last connection point Y values is < 0.875 inches
   
    Dim connPtRow As Integer    ' row identifier of last connection point
    Dim UndoScopeID1 As Long
    Dim lastCPYVal As Single    ' y value of last connection point (zero based)
    Dim rowsToAdd As Integer    ' number of connection point rows we need to add to vba formula is 0 based. for shapesheet formulas it is one-based
    Dim rowNew As Integer      ' the row we just added
    Dim i As Integer
       
    Dim currentTime As Date
    Dim milliseconds As Double
    currentTime = Now()
'*******************************
    If Timer - lastcall < 100 Then
      lastcall = Timer
      Exit Sub
    End If
'*******************************

....

#24
ShapeSheet & Smart Shapes / Re: SETATREF(Height) / EventXF...
Last post by MacGyver - April 23, 2024, 05:14:48 PM
Another weird characteristic I've noticed is that when my macro is run multiple times. The various routine's appear to be running in parallel. As in one the first run of the routine may not have finished running before the second instance of the routine is executed.

I added code to debug.print start/stop times of an otherwise empty macro.  I then added some code that throws an intentional error.  The debug window shows that the macro started 6 times, and only ended once.  If the intentional error is removed, the macro was started some random number of times and ended some random number of times.
#25
ShapeSheet & Smart Shapes / SETATREF(Height) / EventXFMod ...
Last post by MacGyver - April 23, 2024, 04:19:25 PM
I'm attempting to run a macro when height of a shape is changed to dynamically adjust connection points.  I'm running into an issue that appears others have run into (similar topic)

I've attempted using CALLTHIS in a user cell like such:
=SETATREF(Height,CALLTHIS("ConnPtAdjust"))And the ConnPtAdjust macro gets executed anywhere from 4-20 times.  I've attempted moving the code to the EventXFMod Behavior as well and same result - code is executed multiple times. 

The real oddity is if i toss a break in there for debug purposes, code functionality works exactly as expected.  If no break, it executes between 4 and 20 times.  Even adjusted my code so that called routine only debug prints the time to verify it wasn't my code causing the error and same results.

I changed from CALLTHIS to use RUNMACRO (and forgot to remove the visShape as input) and it errored out multiple times.  I have added various wait times to my code which also doesn't fix the issue.  Attached the drawing with shape in question, and included code that gets executed.

Any thoughts/tips would be greatly appreciated!
#26
General Visio / Re: Why does Visio show two di...
Last post by wapperdude - April 23, 2024, 04:15:07 PM
Technically, yes.  But it would be expected as decimal separator is always a period in English system.  I suspect that since Visio internally uses English system, then, within shapesheet enties, it would expect the period. Haven't tried to change the language and/or the separator.  There was a discussion, not too long ago, related to this, but don't recall specifics.
#27
General Visio / Re: Multi line shape
Last post by wapperdude - April 23, 2024, 04:02:40 PM
...and another option, Draw line a --> c, then use pencil tool to grab (add) a mid- inflection point to the line, and drag to point b. 
#28
General Visio / Re: Why does Visio show two di...
Last post by Surrogate - April 23, 2024, 03:23:26 PM
Quote from: Visisthebest on April 23, 2024, 02:01:40 PMIt is a bit confusing because if you enter say a 0,50 in to the shape data shapesheet cell I do get an error.
I use Visio and MS Windows with Russian interface. I get same error too!
What about peoples with EN-US locale? 
#29
General Visio / Why does Visio show two differ...
Last post by Visisthebest - April 23, 2024, 02:01:40 PM
I notice in the shapesheet Visio converts a cell reference in a user cell with say 0.25 (so 1/4) to a 0,25 in the shape data cell that references the cell. This is in the shapesheet not just in the shape data editor.

It is a bit confusing because if you enter say a 0,50 in to the shape data shapesheet cell I do get an error.

It uses commas yet you will get an error if you do so as well in a shape data shapesheet cell.

I think I overlooked this before, I wonder if it could cause issues I'm not anticipating but should be aware of.
#30
General Visio / Re: Multi line shape
Last post by Nikolay - April 23, 2024, 08:45:11 AM
Draw A => B then C => B then select both segments and use Join button. Visio way  :-\