Convert SVG arc to Visio and back

Started by bsculley, August 18, 2016, 12:48:11 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

bsculley

I am developing a Visio add-in in C#.  The purpose of the add-in is to allow an SVG file to be edited in Visio, but not using Visio's SVG import/export.  The SVG file contains private namespace data and some other specialized stuff that must be preserved, so the normal SVG open/save process cannot be used.  The add-in reads the SVG as XML and creates the Visio shapes programmatically, then reverses the process when the file is saved.

The problem I am encountering with this is that I can't figure out how to convert elliptical arcs.  The SVG format uses a starting and ending point with two radii to specify the arc, while Visio uses a different basis for defining the arc.  I know the equations to convert back and forth exist because the SVG is rendered correctly if I just open the file using Visio, but I have searched extensively and can't find anything that addresses my question, "how can I convert an SVG path arc to Visio and back again?"

Anyone out there familiar with Visio internals (or very good with geometry) that can provide the necessary equations?

Thanks
Bob

vojo

This is really about translating center points to major/minor axis.

Perhaps these might help to understand how to:
Top is regular arc (right click)
bottom is elliptical arc (right click)

Then you can look at the shape sheet for conversion approach.

bsculley

Thanks, I think I understand the concept, but I am still struggling with the execution.

Here is the SVG path I'm dealing with:  <path d="M12 19 A6 6 236.1413 0 0 5 30" />
This decodes as "move to x=12, y=19", "arc with radii 6,6 to x=5, y=30"  The parameters between "6 6" and "5 30" are not relevant to this exercise.

Here is the geometry that Visio generates for this shape when it opens the SVG file:





NameXYABCD
RelMoveTo1.00001.0000
RelEllipticalArcTo0.22220.00000.00000.81820.00001.0000

What I would really like is an explanation (preferably with examples) of how to get from point A to point B.  Sorry, but my math skills are not up to the task.

Thanks,
Bob

JuneTheSecond

I have a shape of elliptical arc.
I hope this may help you.
Best Regards,

Junichi Yoda
http://june.minibird.jp/

bsculley

Hello, and thank you.  I appreciate your efforts. 

I can see the relationships at work here, but what I am lacking are the specific calculations required to implement the transformation that I need, which is to represent an SVG path arc in Visio, and then reverse the process.

If anyone has actual code that can accomplish this I would be grateful if you could share it.

Bob

JuneTheSecond

I am sorry I cannot understand what do you mean.
Best Regards,

Junichi Yoda
http://june.minibird.jp/

Yacine

@Bob, with June you've certainly met the best possible specialist to solve your issue.
The problem is, we're all very Visio focused here at the visguy forum, so if YOU could provide the formulas to describe a SVG arc, then June will certainly find a way to translate it back and forth betwenn Visio and SVG.

My 2 cents, Y.
Yacine

JuneTheSecond

I think Visio can open SVG file.
The following is a simple test.
1. Insert a simple SVG file that contain an elliptical arc only that is made with Visio and saved as SVG file.
2. Ungroup the inserted elliptical arc 3 times, and get the Visio alliptical arc.
3. you can edit directly on the drawing page, or on shapesheet.

You can make a macro of  this proccess using macro recorder.
Best Regards,

Junichi Yoda
http://june.minibird.jp/

Yacine

Bob is looking for formulas to convert by code Visio arcs into SVG and back. Description of SVG arc: https://www.w3.org/TR/SVG/paths.html#PathDataEllipticalArcCommands
Yacine

bsculley

Yes!  Thank you Yacine.  I guess I wasn't being clear enough.

I need some help with the actual coding of the transformations using .Net 4.5 and C#.

Bob

JuneTheSecond

#10
There are already the converters in the web.
Please search in the web with the keywords like svg2vsd and vsd2svg.
It seems here you can download the source code.
http://dia-installer.de/vsd2svg/index.html.en
I think Visio includes sub program like these.
Best Regards,

Junichi Yoda
http://june.minibird.jp/

bsculley

Thank you everyone for your patience.  I have located the code to convert a Visio elliptical arc to SVG (VSD2SVG).

Unfortunately, there is no reciprocal function that I can find.  I have searched SVG2VSD and all similar and related ideas, but with no luck.

I would appreciate any help anyone can provide on the conversion of an SVG path arc to a Visio EllipticalArcTo.  Is the Visio source open?  If it is I couldn't find it. 

I'm sure the equations are there since Visio can open an SVG file and render the arcs correctly.  As I mentioned at the beginning, I can't use the native Visio capability because there is private namespace material in the SVG file.

Bob

JuneTheSecond

#12
Quote
I am developing a Visio add-in in C#.
Why don't you use many powerful tools in Visio such as Visio mehods, properties, etc. in your add-in in your c#?
It might be much easier than you develop your own unique codes.
Best Regards,

Junichi Yoda
http://june.minibird.jp/

bsculley

Hi Junichi,

A good suggestion.  Presented with an SVG arc path (M from-x, from-y A rx, ry, x-axis-rotation, large-arc-flag, sweep-flag, to-x, to-y) what Visio tool(s) should I apply to create a corresponding shape?

Thanks again,
Bob

JuneTheSecond

Quote
I think Visio can open SVG file.
The following is a simple test.
1. Insert a simple SVG file that contain an elliptical arc only that is made with Visio and saved as SVG file.
2. Ungroup the inserted elliptical arc 3 times, and get the Visio alliptical arc.
3. you can edit directly on the drawing page, or on shapesheet.

You can make a macro of  this proccess using macro recorder.

I think Visio is one of the best converter.
Best Regards,

Junichi Yoda
http://june.minibird.jp/