Export Sketch Properties Table

2833
5
04-16-2014 06:31 AM
AngelikaGruhn
New Contributor
Dear Forum-User,

I am looking for a possibility or tool to export a sketch properties table. I have a polyline with coordinates and heights at each vertex of this polyline. I can access these properties via the sketch properties. For my futher processings I need to export this sketch properties table. So, does anybody know a possibility to export this table?

Thank you very much in advance!!!
Tags (2)
0 Kudos
5 Replies
RichardFairhurst
MVP Honored Contributor
As far as I know you would have to create your own table tool using Python.  You can read the geometry table data using the script in the help for reading polyline geometries posted here.  Basicallly you would have to integrate the creation of a table with the correct schema and an insert cursor and would replace the print statements in the code below with statements that wrote attributes to a new row that would be inserted into the table.

import arcpy

infc = arcpy.GetParameterAsText(0)

# Enter for loop for each feature
#
for row in arcpy.da.SearchCursor(infc, ["OID@", "SHAPE@"]):
    # Print the current multipoint's ID
    #
    print("Feature {0}:".format(row[0]))
    partnum = 0

    # Step through each part of the feature
    #
    for part in row[1]:
        # Print the part number
        #
        print("Part {0}:".format(partnum))

        # Step through each vertex in the feature
        #
        for pnt in part:
            if pnt:
                # Print x,y,z coordinates of current point
                #
                print("{0}, {1}, {2}".format(pnt.X, pnt.Y, pnt.Z))
            else:
                # If pnt is None, this represents an interior ring
                #
                print("Interior Ring:")
        partnum += 1
0 Kudos
JimCousins
MVP Regular Contributor
There was a sample script in v9.x to write to text file (Generate format). Perhaps this will get you most of the way there.
Regards,
Jim



'''----------------------------------------------------------------------------------
 Tool Name:     WriteFeaturesFromTextFile
 Source Name:   WriteFeaturesFromTextFile.py
 Version:       ArcGIS 9.1
 Author:        Environmental Systems Research Institute Inc.
 Required Argumuments:  An input feature class 
                        An output text file
                        An input decimal separator character that indicates what character
                        should be used to separate the whole number from its decimal.
 Description:   Writes the features of a feature class out to a text file.
----------------------------------------------------------------------------------'''

import string, os, sys, locale, arcgisscripting
gp = arcgisscripting.create()
gp.overwriteoutput = 1

msgNotEnoughParams = "Incorrect number of input parameters."
msgUseValidDecimalPointSep = "Please use one of the valid decimal point separators."

try:

    if len(sys.argv) < 4: raise Exception, msgNotEnoughParams
    inputFC = sys.argv[1]
    outFile = open(sys.argv[2], "w")
    
    arg3poss = ['default python output', 'locale decimal point', 'comma', 'period', '$sep$']
    if sys.argv[3].lower() not in arg3poss: raise Exception, msgUseValidDecimalPointSep

    if sys.argv[3].lower() == arg3poss[1]:
        locale.setlocale(locale.LC_ALL, '')
        sepchar = locale.localeconv()['decimal_point']
    elif sys.argv[3].lower() == arg3poss[2]: sepchar = ','
    elif sys.argv[3].lower() == arg3poss[3]: sepchar = '.'
    elif sys.argv[3].lower() == arg3poss[4]: sepchar = '$SEP$'
    elif sys.argv[3].lower() == arg3poss[0]: sepchar = ""
    
    inDesc = gp.describe(inputFC)

    inRows = gp.searchcursor(inputFC)
    inRow = inRows.next()
    outFile.write(inDesc.ShapeType + "\n")

    while inRow:
        feat = inRow.GetValue(inDesc.ShapeFieldName)
        if inDesc.ShapeType.lower() == "point":
            pnt = feat.getpart()
            outLine = str(inRow.GetValue(inDesc.OIDFieldName)) + " " + str(pnt.x) + " " + str(pnt.y) + " " + str(pnt.z) + " " + str(pnt.m) + "\n"
            if sepchar == "": outFile.write(outLine)
            else: outFile.write(outLine.replace(".", sepchar))
            
        elif inDesc.ShapeType.lower() == "multipoint":
            partnum = 0
            partcount = feat.partcount
            outFile.write(str(inRow.GetValue(inDesc.OIDFieldName)) + " " + str(partnum) + "\n")
            while partnum < partcount:
                pnt = feat.getpart(partnum)
                outLine = str(partnum) + " " + str(pnt.x) + " " + str(pnt.y) + " " + str(pnt.z) + " " + str(pnt.m) + "\n"
                if sepchar == "": outFile.write(outLine)
                else: outFile.write(outLine.replace(".", sepchar))
                partnum += 1

        else:
            partnum = 0
            partcount = feat.partcount
            while partnum < partcount:
                outFile.write(str(inRow.GetValue(inDesc.OIDFieldName)) + " " + str(partnum) + "\n")
                part = feat.getpart(partnum)
                part.reset()
                pnt = part.next()
                pnt_count = 0
                while pnt:
                    outLine = str(pnt_count) + " " + str(pnt.x) + " " + str(pnt.y) + " " + str(pnt.z) + " " + str(pnt.m) + "\n"
                    if sepchar == "": outFile.write(outLine)
                    else: outFile.write(outLine.replace(".", sepchar))
                    pnt = part.next()
                    pnt_count += 1
                    if not pnt:
                        pnt = part.next()
                        if pnt:
                            outFile.write("InteriorRing\n")

                partnum += 1
        inRow = inRows.next()
    outFile.write("END")
    outFile.flush()
    outFile.close()
    
except Exception, ErrorDesc:
    gp.AddError(ErrorDesc[0])
    if outFile: outFile.close()
    gp.AddError(gp.getmessages(2))
0 Kudos
AngelikaGruhn
New Contributor
Hello together,

It worked well with the provides codes.
So, thank you very much again.

Very best regrads.
0 Kudos
RichardFairhurst
MVP Honored Contributor
Hello together,

It worked well with the provides codes.
So, thank you very much again.

Very best regrads.


If you want to thank us you can up vote our posts and mark the answer to the thread.  See this link for more information.
0 Kudos
KatayounMesgarian
New Contributor III
hello there,

I have got the same problem, and I have very little coding experience. can anybody help me sort this out please?

I know i need to tweak the code a bit, but have noooo idea how!

many thanks,
Katy
0 Kudos