Section-relative location of a segment
Posted: Sat Apr 13, 2024 7:56 pm
Hi.
I have not been able to find a simple, pythonic way of extracting the section-relative location of a segment. I find it quite surprising that I have not found it considering the location is available from the segment object's string representation. Good thing that it is, because that is what my current solution relies on. However, I believe there must be better way, which is why I came here.
Hope to hear from someone soon!
I have not been able to find a simple, pythonic way of extracting the section-relative location of a segment. I find it quite surprising that I have not found it considering the location is available from the segment object's string representation. Good thing that it is, because that is what my current solution relies on. However, I believe there must be better way, which is why I came here.
Code: Select all
section = h.Section("sec")
section.nseg = 3
segment = section(0.5)
#print(segment) will be sec(0.5), therefore split at parentheses
location_string = str(segment)
parts = location_string.split("(")
location = float(parts[1].rstrip(")"))