I have a number non-georeferenced CAD layers (see this question) that have text annotation features. I have created a model to convert the text to points, but after converting the annotation to a Point featureclass, I see that the CAD text anchor points do not coincide with the center of the CAD text (which is where the points belong).
Therefore, I would like to programatically (using ArcPy or ModelBuilder) [move] a feature relative to its current location (delta x,y) using a measured X,Y value that I will provide.
This would allow me to move the GIS points back to where they belong, instead of the offset CAD anchor point.
How can I accomplish this task?
@PolyGeo gave an excellent answer using SHAPE@XY IN 10.1, but currently I am running 10.0. Any 10.0 ideas?
Answer
I credit @artwork21 for leading me to my final solution. I actually found a nearly complete script in the ArcGIS 10.0 online help article called "Calculate Field examples", listed under the subcategory "Code samples—geometry" and "For a point feature class, shift the x coordinate of each point by 100"
The final script that I used within the ModelBuilder "Calculate Field" tool was:
Expression:
shiftXYCoordinates(!SHAPE!,%ShiftX%,%ShiftY%)
where ShiftX and ShiftY are variables (as parameters) defined on the ModelBuilder canvas.
Expression Type:
PYTHON_9.3
Code Block:
def shiftXYCoordinates(shape,x_shift,y_shift):
point = shape.getPart(0)
point.X += float(x_shift)
point.Y += float(y_shift)
return point
Since all models work on a selected set, you should also be able to create this as a generic tool that will work in conjunction with other models/tools in other modelbuilder sessions. The very simple model I created (as a "plugin" to other models to shift coordinate values) looks like this. That way I can control the shift on a per-selection-set basis (as defined in other models):
It worked like a charm, thank you all for your input!
No comments:
Post a Comment