News:

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

Accept dropped shapes behavior

Started by Yacine, April 05, 2024, 08:35:02 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Yacine

Hello guys,

I am playing with my Process Flow Diagram project and set up a shape that can accept dropped shapes and be itself droppable on other shapes.
My issue is, that the range at which the shape accepts dropped shapes is much larger than itself. Is there a property that defines the boundaries of a shape outside the obvious visible one?

I enclose my file to let you inspect it. Try dropping the mixer or the sensor on the container and watch at which distance the container reacts to the shapes to drop.

Cheers,
Yacine

You cannot view this attachment.
Yacine

wapperdude

#1
Hmmm. Some questions and observations:
  1) The hexagonal shape... is that a group or container?  It is lacking container definition entries is the User section.
  2)  Where did the shape come from?
  3). I see this capture from afar phenomena for those 2 shapes and other shapes.
  4). Not every dropped shape exhibits this remote capture property, and, those shapes that do,  don't exhibit this with other containers, it seems likely, there might be some embedded code that uses spatial neighborhood functionality in conjunction with some shape identifying property.

But, other than spacial neighborhood, not aware of any other Visio mechanism.

Visio 2019 Pro

Yacine

#2
Hi Wayne,
I appreciate you looking in my problem.
1) The hexagonal shape represents a container and is a grouped smartshape. Actually a revised version of the tank I uploaded back in 2015.
2) Where it came from? Well I wrote it.
3) No comment
4) No, there is no code involved. Only plain shapesheeet functionality.

5) yes, but spatial neighborhood does not explain the extension of the boundarries.

There must be something else involved.

BTW: I added an "action" option to switch the "accept dropped shapes" behavior. It works, but it is a workaround.
Yacine

wapperdude

Add new page.  Did copy / paste.  Behavior replicates. 

Created new Visio doc, did copy / paste, behavior is gone.
Visio 2019 Pro

Yacine

#4
Yes, same result on my side.
And this re-enforces me in asking, what are the boundaries of the drop range? Where is that stored? How can I edit it?

(Since I need to edit my drawing automatically - without the hack of creating a new drawing)
Yacine

wapperdude

Hmmm.  My interpretation is that what you're experiencing is not normal.  Would seem to be an issue with your file.  To make my point, I created a new stencil with all of your shapes, plus the smart shape, as is.  I saved this stencil.  Next, I opened up a new Visio document.  First, I dropped the smart shape.  Then, I drag and dropped a variety of the other shapes.  There was no far reaching capture by the smart shape.  This phenomena only happens in your file. That is to say, normally, for a container to capture, the shape must, at minimum, touch the container. Your file has abnormal behavior.   
Visio 2019 Pro

wapperdude

Quote from: Yacine on April 05, 2024, 10:51:38 PMWhere is that stored? How can I edit it?

AFAIK it is built-in, nothing to edit, nothing stored.  Something is broken in your current file, don't know how to fix it.  Sharpen your axe.  Not knowing how big your file is, perhaps a bit of code to copy contents on a per page basis, and paste into new, blank file???   Sounds like a PowerShell script file.
Visio 2019 Pro

Yacine

Your broken file explanation is good enough for me.
Knowing that I can just copy my shapes in a new document is fine.
Thank you Wayne
Yacine

wapperdude

Because I love to program and write code ... 👀 🤔😜😲 ... I do have a PowerShell script file that will copy pages from 1 file to a new file.  But, not at my PC.  Will post in an hour or so.
Visio 2019 Pro

wapperdude

#9
Here's the PowerShell script.  It's been tested on a couple of different Visio files.  Also, ran it on Windows PowerShell ISE and PowerShell 7.

By reconstructing the original file on a per page basis, the new file is free of the issue here.    However, I do see some potential problems, e.g., inter-page link formulae may (will) be broken.  Also, doc stencil is not copied. 

Things to note:
1)  Path to original file to be copied is hard coded.
2)  The code will pause when complete...with message.  This allows you to do SaveAS for new Visio file.  No other steps needed.  Go back to the active PowerShell window and hit <Enter>.  The script will close the Visio application, clearing memory.
3)  The new Visio document will have a blank 1st page.  Delete it if you want.

Import-Module Visio
$NewDoc = New-VisioDocument

$origDoc = Open-VisioDocument "C:\Users\wappe\OneDrive\Documents\Visio\Forum\GroupPlaceBehavior.vsdx"
$visApp = Get-VisioApplication

foreach($pG in $origDoc.Pages) {
    $visApp.ActiveWindow.Page = $pG
    Copy-VisioPage -ToDocument $newDoc
}

write-host "Save new Visio file.  Then hit <Enter> to contine"
Pause
Close-VisioApplication
Visio 2019 Pro

Yacine

It's nice seeing you code.
I can unfortunately not jump on this train.
Unlike Python, our IT guys think that Powershell is dangerous. So it is completely blocked on the computer where I have Visio.
By the way, cudos for this choice. Powershell is much more cryptic than Python.
Yacine

wapperdude

#11
I wouldn't have given PowerShell a thought, except for previous post, https://visguy.com/vgforum/index.php?topic=10329.msg48374;topicseen#msg48374 about adding images to stencil.  Had to learn from 0 knowledge.  Still very difficult for me to get working syntax.  I can see with good reason why IT frowns upon PowerShell.
Visio 2019 Pro

wapperdude

I know this is a deadend task, but the lingering blank page was annoying me.  Here's updated script with 2 methods to remove the blank page, and to renumber the remaining pages.

Import-Module Visio
$newDoc = New-VisioDocument #Default activepage = Page-1

$origDoc = Open-VisioDocument "C:\Users\wappe\OneDrive\Documents\Visio\Forum\GroupPlaceBehavior.vsdx"
$visApp = Get-VisioApplication

foreach($pG in $origDoc.Pages) {
$visApp.ActiveWindow.Page = $pG
Copy-VisioPage -ToDocument $newDoc
}

Close-VisioDocument -Document $origDoc

#Delete page and renumber
#Method1:
#$visPg = $newDoc.Pages.Item(1)
#$visApp.ActiveWindow.Page = $visPg
#Remove-VisioPage -Renumber #deletes ActivePage and renumbers

#Method2:
$visPg = Get-VisioPage -name 'Page-1' #Grabs specified page, not necessarily active
Remove-VisioPage -Page($visPg) -Renumber

Write-Host ""
Write-Host "Save the new Visio file."
Write-Host "Then press <Enter>, below, in PowerShell window to finish. Visio will be closed."

Pause
Write-Host "Code execution completed.  Bye."
Close-VisioApplication


Visio 2019 Pro

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: 350 (show)
Files included: 32 - 1207KB. (show)
Memory used: 1205KB.
Tokens: post-login.
Cache hits: 13: 0.00193s for 26,740 bytes (show)
Cache misses: 3: (show)
Queries used: 17.

[Show Queries]