AutoCAD Map 3D Developer
Welcome to Autodesk’s AutoCAD Map 3D Developer Forums. Share your knowledge, ask questions, and explore popular AutoCAD Map 3D Developer topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

JSON to dwg

6 REPLIES 6
SOLVED
Reply
Message 1 of 7
fieldguy
4492 Views, 6 Replies

JSON to dwg

fieldguy
Advisor
Advisor

I have some spatial databases and I am able to connect in visual studio with the SQLClient and read point coordinates and create autocad entities.

I also have access to arcgis/rest/services and would like to create query urls and parse the JSON results to create autocad entities.

Can anyone provide an example, or documentation to get me started?  A google search returns several DWG to JSON posts, but I want to go the other way.

I don't want to buy FME Workbench if I don't have to.

TIA

0 Likes

JSON to dwg

I have some spatial databases and I am able to connect in visual studio with the SQLClient and read point coordinates and create autocad entities.

I also have access to arcgis/rest/services and would like to create query urls and parse the JSON results to create autocad entities.

Can anyone provide an example, or documentation to get me started?  A google search returns several DWG to JSON posts, but I want to go the other way.

I don't want to buy FME Workbench if I don't have to.

TIA

6 REPLIES 6
Message 2 of 7
CADaSchtroumpf
in reply to: fieldguy

CADaSchtroumpf
Advisor
Advisor

I'm not sure, but you can try this mapshaper for convert to différent format

0 Likes

I'm not sure, but you can try this mapshaper for convert to différent format

Message 3 of 7
fieldguy
in reply to: CADaSchtroumpf

fieldguy
Advisor
Advisor

Thanks - I have access to FME but that is a last resort.

 

I am going to cross-post this in the .NET forum.   

0 Likes

Thanks - I have access to FME but that is a last resort.

 

I am going to cross-post this in the .NET forum.   

Message 4 of 7
fieldguy
in reply to: fieldguy

fieldguy
Advisor
Advisor
Accepted solution

The answer for me was to convert the JSON data to XML.  All of the information required for creating DWG data is in the <features> node.  <attributes> go to object data, and <geometry> provides the vertices.

I used WebClient to submit the REST services request and download the content, JsonReaderWriterFactory.CreateJsonReader

to read the content, and created an xmldocument from the json reader.  

 

0 Likes

The answer for me was to convert the JSON data to XML.  All of the information required for creating DWG data is in the <features> node.  <attributes> go to object data, and <geometry> provides the vertices.

I used WebClient to submit the REST services request and download the content, JsonReaderWriterFactory.CreateJsonReader

to read the content, and created an xmldocument from the json reader.  

 

Message 5 of 7
ss6153
in reply to: fieldguy

ss6153
Enthusiast
Enthusiast

Hi @fieldguy 
Could you please explain your answer in a bit more detail? I have to convert json data into autocad entities and I am stuck. 
Please could you explain in detail how you went about it?

0 Likes

Hi @fieldguy 
Could you please explain your answer in a bit more detail? I have to convert json data into autocad entities and I am stuck. 
Please could you explain in detail how you went about it?

Message 6 of 7
fieldguy
in reply to: ss6153

fieldguy
Advisor
Advisor

Hi @ss6153.  I do not have access to any autodesk products anymore. Are you able to access the data through a browser interface?  That is what I used to confirm the urls and the results.

 

Is the data in the public domain (can anyone access it)?  Try the code below to see if you get "rootnode".  

 

string url = "the REST data URL"
WebClient wc = new WebClient() // System.Net.WebClient 
string content = wc.DownloadString(url)
XmlDocument xdoc = new XmlDocument() // System.Xml.XmlDocument
using (var reader = JsonReaderWriterFactory.CreateJsonReader(Encoding.UTF8.GetBytes(content), 	XmlDictionaryReaderQuotas.Max)) //  System.Runtime.Serialization.Json 
            {
                XElement xml = XElement.Load(reader) // System.Xml.Linq;
                xdoc.LoadXml(xml.ToString());
                XmlNode rootnode = xdoc.FirstChild;
                }// using reader

 

 

  

0 Likes

Hi @ss6153.  I do not have access to any autodesk products anymore. Are you able to access the data through a browser interface?  That is what I used to confirm the urls and the results.

 

Is the data in the public domain (can anyone access it)?  Try the code below to see if you get "rootnode".  

 

string url = "the REST data URL"
WebClient wc = new WebClient() // System.Net.WebClient 
string content = wc.DownloadString(url)
XmlDocument xdoc = new XmlDocument() // System.Xml.XmlDocument
using (var reader = JsonReaderWriterFactory.CreateJsonReader(Encoding.UTF8.GetBytes(content), 	XmlDictionaryReaderQuotas.Max)) //  System.Runtime.Serialization.Json 
            {
                XElement xml = XElement.Load(reader) // System.Xml.Linq;
                xdoc.LoadXml(xml.ToString());
                XmlNode rootnode = xdoc.FirstChild;
                }// using reader

 

 

  

Message 7 of 7
adam.bihi
in reply to: CADaSchtroumpf

adam.bihi
Enthusiast
Enthusiast

I just tried. It didn't work as it only supports v7 and v8-DGN

0 Likes

I just tried. It didn't work as it only supports v7 and v8-DGN

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report