#RTCNA wish 5 granted! Toposurface from Sokkia SDR file

Ken asked “Can an api help to use Sokkia survey data collection files (.sdr) directly into Revit topo’s without 3rd party conversions?”

There may be some tweaks needed to how the XYZ values are read from the SDR file, but this seems to come close

RESULTS FROM SAMPLE FILE

Capture

POINTS EXTRACTED FROM SDR FILE

(168.400000000, 88.900000000, 270.000000000)
(274.500000000, 91.300000000, 120.000000000)
(3101.000000000, 91.000000000, 93.300000000)
(471.300000000, 89.100000000, 272.000000000)
(591.100000000, 89.100000000, 246.000000000)
(6101.000000000, 89.200000000, 246.000000000)
(777.300000000, 89.400000000, 246.000000000)
(841.800000000, 90.300000000, 16.700000000)
(936.100000000, 89.600000000, 241.000000000)
(121.000000000, 90.100000000, 317.000000000)
(136.400000000, 88.700000000, 308.000000000)
public void topoFromSdrFile()
{
    Document doc = this.ActiveUIDocument.Document;
    List<XYZ> points = new List<XYZ>();
    using (StreamReader sr = new StreamReader(@"C:\Users\harry_000\Desktop\USPS-Eville.sdr"))
    {
        string line = "";
        while ((line = sr.ReadLine()) != null)
        {
            if (line.Contains("-") || line.Contains(":"))
                continue;
            if (line.Length < 40)
                continue;
            line = line.Substring(11);
            double x = 0;
            Double.TryParse(line.Substring(0, 5), out x);
            double y = 0;
            Double.TryParse(line.Substring(11, 4), out y);
            double z = 0;
            Double.TryParse(line.Substring(21,4), out z);
            if (x != 0 && y != 0 && z != 0)
                points.Add(new XYZ(x, y, z));
        }
    }
    
    // write to a file the results of parsing the input file for testing/validation
    string output = Path.Combine(Path.GetTempPath(),"points.txt");
    using (StreamWriter sw = new StreamWriter(output, false))
    {
        foreach (XYZ xyz in points)
        {
            sw.WriteLine(xyz.ToString());
        }
    }
    Process.Start(output);
    
    // create the toposurface
    using (Transaction t = new Transaction(doc, "create topo"))
    {
        t.Start();
        TopographySurface.Create(doc, points);
        t.Commit();
    }
}
Advertisements

3 thoughts on “#RTCNA wish 5 granted! Toposurface from Sokkia SDR file

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s