2

I am using Python 2.6 and ArcObjects in ArcGIS 10.0 to build and draw, among other things, graphic text on the current display. At one point I need to use the ITextSymbol.GetTextSize method. In a function called BuildSignGraphic() have the following:

def BuildSignGraphic(pFeature, annoFC):
    .
    .
    pTextSymbol.GetTextSize(pDisplay.hDC, pDisplay.DisplayTransformation, txt, dblX, dblY)
    .
    .

When I run my code I get a name error:

NameError: global name 'dblX' is not defined

In VB.NET, the dblX variable would be explicitly declared, but Python doesn't do this.

Because the dblX and dblY variables are input and get populated by the method, how do I go about defining these two variables so that Python can recognize them?

This is an uncommon syntax for a method in ArcObjects, but I think it does occur elsewhere in ArcObjects.

1 Answer 1

6

Out params behave differently in comtypes, they come in the return value of the call:

dblx, dbly = pTextSymbol.GetTextSize(pDisplay.hDC, pDisplay.DisplayTransformation, txt)
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.