Page 1 of 1

getting distance without using currently accessed section

Posted: Tue Nov 09, 2010 11:53 am
by vellamike
Hi,

I'd like to find the distance of a node from the origin without using the currently accessed section functionality. Is there a way to do this in Python?

Mike

Re: getting distance without using currently accessed section

Posted: Tue Nov 09, 2010 7:47 pm
by ted
vellamike wrote:I'd like to find the distance of a node from the origin without using the currently accessed section functionality. Is there a way to do this in Python?
Sounds like a contradiction in terms to me, whether in Python or any other language. The section to which a node belongs is part of what distinguishes it from any other node in a model cell. But maybe somebody else will have an answer, in which case I'll learn something new (for the nth time today . . . )

Re: getting distance without using currently accessed section

Posted: Wed Nov 10, 2010 7:55 am
by hines
To use the "distance" function you need to specify the section, either implicitly as in a
for sec in h.allsec():
for seg in sec:
print h.distance(seg.x)
or explicitly as in
print h.distance(dend(.5).x, sec=dend)

However, this is certainly one of those functions that cries out for greater pythonicity as in
print h.distance(dend(.5))
which presents all the informatin needed to compute the distance (from the origin).
This is one of a number of such cases, many of which have already been modified to have a pythonic variant (i.e. take a segment arg instead
of a section, x pair.) I need to look into the possibility of doing this generically.