Author Topic: SVG loader  (Read 11417 times)

Offline EddyCurrent

  • CNC Jedi
  • *****
  • Posts: 5211
  • Made in England
    • View Profile
Re: SVG loader
« Reply #15 on: March 12, 2022, 15:29:19 pm »
David,

I got this from GitLab, it said, updated 3 hours ago.

Edit, I tried your involute gear cb file and it works okay with this new version.
« Last Edit: March 12, 2022, 15:52:25 pm by EddyCurrent »
Filmed in Supermarionation

Offline EddyCurrent

  • CNC Jedi
  • *****
  • Posts: 5211
  • Made in England
    • View Profile
Re: SVG loader
« Reply #16 on: March 12, 2022, 15:41:50 pm »
Two suggestions.

1. It needs a call to, RefreshView() at the end.
2. It would better in the, File->Import, menu.
Filmed in Supermarionation

Offline maot0341

  • Ewok
  • *
  • Posts: 12
    • View Profile
Re: SVG loader
« Reply #17 on: March 16, 2022, 16:10:03 pm »
here you are: [url][https://gitlab.com/maot0341/SVG-Import/-/blob/master/SVG-Loader/bin/Release/SVG-Loader.dll]
in repo path: SVG-Loader/bin/Release
« Last Edit: March 16, 2022, 16:21:05 pm by maot0341 »

Offline maot0341

  • Ewok
  • *
  • Posts: 12
    • View Profile
Re: SVG loader
« Reply #18 on: March 16, 2022, 16:28:51 pm »
Two suggestions.

1. It needs a call to, RefreshView() at the end.
2. It would better in the, File->Import, menu.

1.) Does it already. Out of sight? My be your view port / zoom dosn't match.
2.) There is no such menu in my version: File->Import. Use File->Open instead. You can open SVG like a CB-File. Drag&Drop works as well.

Offline EddyCurrent

  • CNC Jedi
  • *****
  • Posts: 5211
  • Made in England
    • View Profile
Re: SVG loader
« Reply #19 on: March 16, 2022, 21:49:55 pm »
Two suggestions.

1. It needs a call to, RefreshView() at the end.
2. It would better in the, File->Import, menu.

1.) Does it already. Out of sight? My be your view port / zoom dosn't match.
2.) There is no such menu in my version: File->Import. Use File->Open instead. You can open SVG like a CB-File. Drag&Drop works as well.

It needs a call to RefreshView() because after I run the plugin, import a file,  nothing happens until I mouse click in the window.
I know that it's because the view was not refreshed.
Filmed in Supermarionation

Offline EddyCurrent

  • CNC Jedi
  • *****
  • Posts: 5211
  • Made in England
    • View Profile
Re: SVG loader
« Reply #20 on: March 18, 2022, 16:14:27 pm »
I tried File->Open and that worked okay.
I tried Drag&Drop and that worked okay.
I tried Plugin->SVG-Loader import and that DID NOT work, nothing appeared until I clicked in the drawing area.

It looks like the first two use an override method but the plugin menu option does not.
It therefore needs a call to RefreshView() at the end as in the code below.

Code: [Select]
static void OpenSVG_Click (object sender, EventArgs e)
{
string path = string.Empty;
string title = string.Format ("SVG Loader version {0}", version());

OpenFileDialog dlg = new OpenFileDialog();
dlg.Title = title;
dlg.Filter = "SVG files (*.svg)|*.svg|All files (*.*)|*.*";
if (dlg.ShowDialog () != DialogResult.OK)
return;
path = dlg.FileName;
OutputCAD output = new OutputCAD (Plugin._ui);
XmlDocument xml = new XmlDocument ();
xml.Load (path);
Graphics graphics = new Graphics (output);
graphics.draw (xml);

                        CamBamUI.MainUI.ActiveView.RefreshView();
        }
Filmed in Supermarionation

Offline GeoffreyGRoy

  • Wookie
  • ****
  • Posts: 266
    • View Profile
Re: SVG loader
« Reply #21 on: March 19, 2022, 03:18:00 am »
I have tied to use the DLL (Vers 1.0.141.22339), but no success at running it (CB1.0 64bit). When I try to load an SVG file, all I get is a spinning cursor then nothing - I have to kill the CamBam procees to escape!

Geoff

Offline dave benson

  • CNC Jedi
  • *****
  • Posts: 1790
    • View Profile
Re: SVG loader
« Reply #22 on: March 19, 2022, 06:29:08 am »
Hi Geoff\Eddy

A few weeks ago now, I  test drove the winx64 CB ver1, and it had
performed the same as the win64 CB v1 on my laptop (rubbish) , where I just reinstalled
the CB Ver1 32 bit and it fixed all the problems I was having which mimic
the ones you have described.

I looked into it some (I really wanted to use the X64 ver1) and the problem
is the video drivers, switching to GDI with no shaders made the screen responsive
again, of course you can’t see the model clearly anymore switching  back to openGL
I could see the model render properly but the UI response time went back to minutes
per click.
Even a single poly line drawn in the interface caused the slow down.
I did notice that when importing an stl (I new the dimensions were small)  in a brief moment
before they disappeared CB’s screen dimensions would appear to indicate that I was attempting
to import a model of the known universe.
I’m now using the 32 bit CB ver1 on my Win10pro 64bit system and it works well.

Dave

Offline EddyCurrent

  • CNC Jedi
  • *****
  • Posts: 5211
  • Made in England
    • View Profile
Re: SVG loader
« Reply #23 on: March 19, 2022, 15:33:19 pm »
There are some test SVG files in the GitLab project here; https://gitlab.com/maot0341/SVG-Import/-/tree/master/data
Filmed in Supermarionation

Offline GeoffreyGRoy

  • Wookie
  • ****
  • Posts: 266
    • View Profile
Re: SVG loader
« Reply #24 on: March 19, 2022, 23:58:40 pm »
I have tied the example files, they all work without problems.  The attached file (that loads correctly in Inkscape) does not. the reported exception is (in part)

----------------
See the end of this message for details on invoking
just-in-time (JIT) debugging instead of this dialog box.

************** Exception Text **************
System.Net.WebException: The underlying connection was closed: An unexpected error occurred on a receive. ---> System.IO.IOException: Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host. ---> System.Net.Sockets.SocketException: An existing connection was forcibly closed by the remote host
   at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)
   --- End of inner exception stack trace ---
   at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)
   at System.Net.PooledStream.Read(Byte[] buffer, Int32 offset, Int32 size)
   at System.Net.Connection.SyncRead(HttpWebRequest request, Boolean userRetrievedStream, Boolean probeRead)
   --- End of inner exception stack trace ---
   at System.Net.HttpWebRequest.GetResponse()
   at System.Xml.XmlDownloadManager.GetNonFileStream(Uri uri, ICredentials credentials, IWebProxy proxy, RequestCachePolicy cachePolicy)
   at System.Xml.XmlUrlResolver.GetEntity(Uri absoluteUri, String role, Type ofObjectToReturn)
   at System.Xml.XmlTextReaderImpl.OpenAndPush(Uri uri)
   at System.Xml.XmlTextReaderImpl.PushExternalEntityOrSubset(String publicId, String systemId, Uri baseUri, String entityName)
   at System.Xml.XmlTextReaderImpl.DtdParserProxy_PushExternalSubset(String systemId, String publicId)
   at System.Xml.DtdParser.ParseExternalSubset()
   at System.Xml.DtdParser.ParseInDocumentDtd(Boolean saveInternalSubset)
   at System.Xml.DtdParser.Parse(Boolean saveInternalSubset)
   at System.Xml.DtdParser.System.Xml.IDtdParser.ParseInternalDtd(IDtdParserAdapter adapter, Boolean saveInternalSubset)
   at System.Xml.XmlTextReaderImpl.ParseDtd()
   at System.Xml.XmlTextReaderImpl.ParseDoctypeDecl()
   at System.Xml.XmlTextReaderImpl.ParseDocumentContent()
   at System.Xml.XmlLoader.LoadNode(Boolean skipOverWhitespace)
   at System.Xml.XmlLoader.LoadDocSequence(XmlDocument parentDoc)
   at System.Xml.XmlDocument.Load(XmlReader reader)
   at System.Xml.XmlDocument.Load(String filename)
   at SVGLoader.Plugin.OpenSVG_Click(Object sender, EventArgs e)
   at System.Windows.Forms.ToolStripItem.RaiseEvent(Object key, EventArgs e)
   at System.Windows.Forms.ToolStripMenuItem.OnClick(EventArgs e)
   at System.Windows.Forms.ToolStripItem.HandleClick(EventArgs e)
   at System.Windows.Forms.ToolStripItem.HandleMouseUp(MouseEventArgs e)
   at System.Windows.Forms.ToolStrip.OnMouseUp(MouseEventArgs mea)
   at System.Windows.Forms.ToolStripDropDown.OnMouseUp(MouseEventArgs mea)
   at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
   at System.Windows.Forms.Control.WndProc(Message& m)
   at System.Windows.Forms.ToolStrip.WndProc(Message& m)
   at System.Windows.Forms.ToolStripDropDown.WndProc(Message& m)
   at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)


************** Loaded Assemblies **************
mscorlib
    Assembly Version: 4.0.0.0
    Win32 Version: 4.8.4470.0 built by: NET48REL1LAST_C
    CodeBase: file:///C:/Windows/Microsoft.NET/Framework64/v4.0.30319/mscorlib.dll
----------------------------------------
CamBam
    Assembly Version: 1.0.7389.20589
    Win32 Version: 1.0.7389.20589
    CodeBase: file:///C:/Program%20Files/CamBam%20plus%201.0/CamBam.exe
----------------------------------------
System.Windows.Forms
    Assembly Version: 4.0.0.0
    Win32 Version: 4.8.4400.0 built by: NET48REL1LAST_C
    CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System.Windows.Forms/v4.0_4.0.0.0__b77a5c561934e089/System.Windows.Forms.dll
----------------------------------------
System
    Assembly Version: 4.0.0.0
    Win32 Version: 4.8.4360.0 built by: NET48REL1LAST_C
    CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System/v4.0_4.0.0.0__b77a5c561934e089/System.dll
----------------------------------------
System.Drawing
    Assembly Version: 4.0.0.0
    Win32 Version: 4.8.4395.0 built by: NET48REL1LAST_B
    CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System.Drawing/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll
----------------------------------------
CamBam.CAD
    Assembly Version: 1.0.7389.20585
    Win32 Version: 1.0.7389.20585
    CodeBase: file:///C:/Program%20Files/CamBam%20plus%201.0/CamBam.CAD.DLL
----------------------------------------
CamBam.Geom
    Assembly Version: 1.0.7389.20153
    Win32 Version: 1.0.7389.20153
    CodeBase: file:///C:/Program%20Files/CamBam%20plus%201.0/CamBam.Geom.DLL
----------------------------------------
System.Xml
    Assembly Version: 4.0.0.0
    Win32 Version: 4.8.4161.0 built by: NET48REL1
    CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System.Xml/v4.0_4.0.0.0__b77a5c561934e089/System.Xml.dll
----------------------------------------
System.Configuration
    Assembly Version: 4.0.0.0
    Win32 Version: 4.8.4341.0 built by: NET48REL1LAST_C
    CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System.Configuration/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Configuration.dll
----------------------------------------
System.Core
    Assembly Version: 4.0.0.0
    Win32 Version: 4.8.4470.0 built by: NET48REL1LAST_C
    CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System.Core/v4.0_4.0.0.0__b77a5c561934e089/System.Core.dll
-----------------

Any thoughts.

Geoff

Offline dave benson

  • CNC Jedi
  • *****
  • Posts: 1790
    • View Profile
Re: SVG loader
« Reply #25 on: March 21, 2022, 00:43:06 am »
Looks like you were trying to access a file on a network drive
and this has failed.
The maze program is producing a truncated header
and where the letter 'A' for arcs is like this A123.753 instead of A 123.753.
this was causing a parsing error.
After going here:
https://validator.w3.org/check
there were two warnings, I repaired the header.
and saved then reloaded it into Inscape-> then saved the file in svg and dxf.
dxf worked fine R12 and R14 which CB works well with, however the svg failed as you
can see the arcs center points are missing and CB is inserting a straight line
instead of an arc.
probably because of this
http://tavmjong.free.fr/INKSCAPE/MANUAL/html/Web.html
Quote
non-compliant HTML will usually render, but each browser vendor handles the invalid content in different ways leading to non-consistent results
The svg spec is a bit murky, and as a drawing exchange format for cad programs its a shocker.

Dave

Offline GeoffreyGRoy

  • Wookie
  • ****
  • Posts: 266
    • View Profile
Re: SVG loader
« Reply #26 on: March 21, 2022, 07:55:22 am »
Dear Dave
Many thanks for your efforts- but could you please explain:

(1) when I tried the validation tool at https://validator.w3.org, the only message all I get is a warning about "No Character encoding declared at document level", nothing else.
(2) what changes did you actually make to the file I posted? As far as I can tell the <path> sections in my file are like this:

  <path d="M 106.02943725152286,139.97056274847714 A 24,24 0 1,1 123,147" />
    <path d="M 107.69266270539639,86.044818699548543 A 40,40 0 0,1 151.2842712474619,94.7157287525381" />
    <path d="M 159.95518130045147,107.6926627053964 A 40,40 0 0,1 159.95518130045147,138.3073372946036" />

     where the A and the next digits are spaced.

(3) could you please post the edited (working) file.
(4) I was not using a network drive - only  a local drive.

thanks

Geoff

Offline dave benson

  • CNC Jedi
  • *****
  • Posts: 1790
    • View Profile
Re: SVG loader
« Reply #27 on: March 21, 2022, 11:42:28 am »
HI Geoff

Quote
1. System.Net.WebException: The underlying connection was closed: An unexpected error occurred on a receive. ---> System.IO.IOException: Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host. ---> System.Net.Sockets.SocketException: An existing connection was forcibly closed by the remote host

That error is why I thought you might have issues with a remote system, however the .svg files
do have embedded links in them (maybe) to tell the browser how to decode them and one
of them is corrupt or outdated, I know the specs for common CAD files and their exchange
formats pretty well but .svg and other formats intended for web transport very little.

Quote
2.  what changes did you actually make to the file I posted?

Huge amount, as I wasn’t interested in the content,  so I used the file as a scratch file
first removing all but the header then slowly adding content until the error showed up.
Then rewriting the file so that the browsers and Inkscape would accept it with one
geometric entity at a time all worked rectangles, circles  etc but the pesky arcs kept showing
up as two straight lines.

I’ve included all the files I used, because I had many versions of CB open at the same time
and copied and pasted the geometry between there are some with names like untitled10 or
Something? So if I find some more I’ll post them I’ve also included a pic of the line or I think it’s that line.

I also went to the maze website and looked at one of the tuts (I think the only one) and then loaded
the maze into Inkscape and exported it as a .dxf and then imported it into CB this is how I do it
and it’s pretty well bullet proof, if you are not wedded to the idea of using svg then this is
a better option.
SVG has a checkered history, it wasn’t the people at svg but the
browser companies who could not settle on a spec and this is why it’s a dogs breakfast.


Dave

Offline GeoffreyGRoy

  • Wookie
  • ****
  • Posts: 266
    • View Profile
Re: SVG loader
« Reply #28 on: March 22, 2022, 00:00:33 am »
Dear Dave

Thanks for the effort.  I did, in fact, use Inkscape to solve the original problem- to create a dxf for import into CamBam - this works fine - your comments about SVG file formats are most useful

Geoff

Offline GeoffreyGRoy

  • Wookie
  • ****
  • Posts: 266
    • View Profile
Re: SVG loader
« Reply #29 on: March 22, 2022, 04:43:14 am »
Dear Dave

My curiosity got the better of me and I been looking at my problem SVG (xml) file again.  I found that if I simply deleted the first 2 lines, i.e:

-------------
<?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
----------------------------

and leaving the rest untouched, the file could be read successfully.  I appreciate that these header lines may well be important in some instances, but it seems that there is something in them in this case that causes the XML loader to fail.

Any thoughts?

Geoff