dave-howard / vsdx

vsdx - A python library for processing .vsdx files
BSD 3-Clause "New" or "Revised" License
67 stars 25 forks source link

Problems with connectors and page size #37

Open freeholod opened 2 years ago

freeholod commented 2 years ago

Hello, I ran into problems with displaying a tree in vsdx.

When opening a file,

firstly: links are displayed incorrectly until you move some figure or select auto-fit on the designer tab. on_start_view

Secondly: the shapes go beyond the dimensions of the template page, this is also corrected when you click the autofit button on the design tab.

After pressing autosize button, i got good result: after_auto_size

Please tell me how to fix this? How can I achieve this through python? I tried to do it through pure xml but all attempts failed. Also I can't use vsdm :-(

freeholod commented 2 years ago

Below is my simple code that is used to add elements and links to the visio tree: Снимок экрана 2022-02-01 в 13 40 10

dave-howard commented 2 years ago

Hi @freeholod - With regards to connectors: you do not appear to be doing anything incorrect.

The dynamic connector shape is not placed correctly by the package as it is today, until a shape is moved at which point Visio moves the connector ends to the correct location. This is a known issue to be resolved (related to #10 ) this is in progress but the XML processing required is quite complex. The Geometry class and Shape.geometry property were added to support this but more work is needed before that issue is resolved.

With regards to page size - that is a concept I need to add:

Kind regards Dave

freeholod commented 2 years ago

Hi @freeholod - With regards to connectors: you do not appear to be doing anything incorrect.

The dynamic connector shape is not placed correctly by the package as it is today, until a shape is moved at which point Visio moves the connector ends to the correct location. This is a known issue to be resolved (related to #10 ) this is in progress but the XML processing required is quite complex. The Geometry class and Shape.geometry property were added to support this but more work is needed before that issue is resolved.

With regards to page size - that is a concept I need to add:

  • [ ] to add a property to get/set page size
  • [ ] to auto-resize the page (or add a function to auto-resize on demand) based on shape bounds. I expect/hope this will be simpler than the dynamic connector shape! I'll update here if I make progress on either.

Kind regards Dave

Hey Dave! Thanks for the answer. I really hope that you succeed in everything you have planned. Because I analyzed and realized that it was difficult for me to deal with this.

dave-howard commented 2 years ago

Hi @freeholod - I have just released v0.4.18 which includes Page.height and width properties - hopefully these are helpful / work as expected

Dave

freeholod commented 2 years ago

Hi @freeholod - I have just released v0.4.18 which includes Page.height and width properties - hopefully these are helpful / work as expected

Dave

Hey, @dave-howard! Thanks for the new version!

In general, width and height properties work as expected, although I had to correct the coordinates of the shapes, but it's simple. But for some reason, the Autosize button for connectors stopped working. Now connectors are drawn only if you move the shapes in the visio editor.

z3ndrag0n commented 2 years ago

@dave-howard with 0.4.18 I'm using Connect.create to connect two shapes which I've read in from an existing vsdx (called, imaginatively, "template.vsdx") however the shapes have a None geometry attribute, hence I get a traceback like so:

File "c:/Users/blah/Downloads/REN_nw/rancid_visio.py", line 168, in (df0, df1, df2, hostname) = ConfigParse(ConfigName=str(ConfigPath), ConfigSyntax='asa') File "c:/Users/blah/Downloads/REN_nw/rancid_visio.py", line 109, in ConfigParse Connect.create(page=page1, from_shape=shape1, to_shape=shape3) File "C:\Users\blah\AppData\Roaming\Python\Python37\site-packages\vsdx\connectors.py", line 37, in create connector_shape = media.straight_connector.copy(page) # default to straight connector File "C:\Users\blah\AppData\Roaming\Python\Python37\site-packages\vsdx\shapes.py", line 165, in copy return Shape(xml=new_shape_xml, parent=parent, page=dst_page) File "C:\Users\blah\AppData\Roaming\Python\Python37\site-packages\vsdx\shapes.py", line 119, in init self.geometry = vsdx.Geometry(xml=geometry, shape=self) File "C:\Users\blah\AppData\Roaming\Python\Python37\site-packages\vsdx\geometry.py", line 20, in init self.cells = shape.master_shape.geometry.cells AttributeError: 'NoneType' object has no attribute 'cells'

Guessing this is something I'm doing but can't get a handle on what!

dave-howard commented 2 years ago

Hi @freeholod - connector positioning should be improved with v0.4.19. Regards the Autosoze button - I expect there are some other changes that need to be made elsewhere in vsdx file at same time as page size. I'll see if I can re-create that issue.

z3ndrag0n commented 2 years ago

@dave-howard have tested and I get the same traceback with 0.4.19 - seems like it thinks don't have a geometry object which doesn't seem to cause problems until I go to create a connector using code such as: shape1 = page1.find_shape_by_text('firewall') # type: VisioFile.Shape shape1a = page1.find_shape_by_text('switch') # type: VisioFile.Shape Connect.create(page=page1, from_shape=shape1, to_shape=shape1a)

dave-howard commented 2 years ago

Thank you @z3ndrag0n for testing - I expect that your firewall and switch shapes are complex / compound shapes - and I haven't tested connecting anything other than simple shapes. Let me add some tests which I expect will fail and re-release once resolved. Cheers Dave

freeholod commented 1 year ago

Hello! Are there any updates on this issue?