move command changes the order of shapes in visio

Started by david, November 09, 2010, 03:25:15 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

david

hi guys,
i hope you can help me with this problem.

i have a vsd file with several shapes. by code i copy-paste each shape to a different vsd file. since the paste command throw the shape to an arbitrary position, i use the Selection.move command to move the shape to the same position as in the original vsd file. at the end, the file indeed looks the same as the original file but the problem is the order of the shapes. when i do the move command, the moved shape jumps to be the first shape (shapes.getItemU(1)). so eventually the order of the shapes in both files is not the same even though they look the same. it's important for the code that the order will remain the same. any idea how to make it work?

thanks in advance.
David

vojo

tower of hanoi ;)

I would copy all 4...note them as needed....then on the new do the select/move/fwd/backward in the original shape order (reverse order to the copy/paste).
copy 1,2,3,4    and move / bring to front    4,3,2,1.......will yeild 1,2,3,4

david


david

i would just like to move a shape without changing its order in shapes. is that possible?

wapperdude

#4
By order, do you mean "id", e.g., sheet.1, sheet.2, or order in the "z-direction", i.e., which shape appears on top of another?  

For example, if you select shape, sheet.6, and place it in on a new page in either new file or existing file, and if it is the 1st placed on that page, it will become sheet.1 and the "lowest" z-direction order.  If shape, sheet.4 is selected next and placed, it will become sheet.2, and will be on top of sheet.1 on the new page.  Two potential issues, then:  1.) shape id's get changed and re-ordered, and 2.) z-direction ordering is changed.  (But, should match the placement order.)

I haven't done this with code, so I don't know if the selection.move command works differently, but it would be surprising if it did.  It should only react to the order as created on the page in question.


Have you given thought to selecting and pasting all shapes?  That would preserve the id, order, and position.  Then, if needed, go thru and eliminate what is unwanted?  Yeah, assumes there isn't a lot of shapes.

Something to consider...


Wapperdude



Visio 2019 Pro

david

hi Wapperdude,
selecting and pasting all shapes won't work since the paste function drops the shapes in an arbitrary place, i need to use the move command for all the shapes at once. i tried it and they all move to the same spot. definitelly not what i meant.
the way i see it, i have to copy-paste each shape.

by order, i meant that shapes.get_itemU(i) in both vsd files will be the same shape for every i.

still stuck with it.
anyone has any idea?

vojo

id is not guarenteed to be linear.   You should really look at doing in order of the shape selections

this is an order problem like the towers of hanoi.   Read up on that and you will see what you have to do

Something like

Do while shapes in selection
   pick a shape
      copy
      paste
      move
      remember the shape ...aka asign to a temp variable....1 per shape
next shape

do while temp shape
   pick last shape in list
      set priority (front back or whatever)
previous temp shape

end

this should set the same precedence as found on the first shape...regardless of ID numbers or ordering on top of each other

Jumpy

#7
Hello,

some suggestions:

1)
Don't use the ShapeID like you do! Like vojo answer implied, Visio can change thoose at will.
You should give your shapes a user defined cell, where you place an selfmade ID number. Use that to identify the shape.

2)
In your code, you can then copy all shapes at once and compare the originals and copies with that number and apoint the PinX and PinY of the originals to the copies.

-----------

3) If you really want to stick with the shape IDs, you look at a real lot of fun in coding and got no guaranty it works:

- Make an Integer array to store the IDs of every original shape.
- Go through all original shapes and store theire IDs in the array.
- Sort the array from small to big.
- Make a loop from (0 or 1?) to the max ID value
-- For each number in the loop:
-- Look if that number is in the array
--- If Yes: Copy (and move) the shape with that ID
--- If No:  Copy a dummy shape (that is later deleted)
- After the loop delete all dummy shapes, hopefully the shapeIDs from all the other shapes don't get sorted anew by visio.
(- If you haven't already moved the shapes, do it know)


Browser ID: smf (is_webkit)
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: 255 (show)
Files included: 34 - 1321KB. (show)
Memory used: 1156KB.
Tokens: post-login.
Cache hits: 12: 0.16661s for 26,583 bytes (show)
Cache misses: 1: (show)
Queries used: 14.

[Show Queries]