Hello @kng_ito,
thank you for reaching out to us. The solution to your problem is that you should get the cache of op
instead of the real spline. But this seems to be some kind of regression. The underlying reason is that GetSegmentCount()
does nothing else than counting the number of data blocks for the first Tsegment
tag present on the Spline/LineObject
it is being called on. The problem is: That tag is not present for splines with a segment count less than two.
For this scene,

and this script:
import c4d
op: c4d.BaseObject
def main():
"""
"""
if op is None:
return
print (f"\nData for {op.GetName()}:\n")
for label, node in [(f"{op.GetName()}", op),
(f"{op.GetName()}(Cache)", op.GetCache())]:
if node is None:
continue
print (f"\t{label}.GetSegmentCount() = {node.GetSegmentCount()}")
tags: list[c4d.BaseTag] = node.GetTags()
print (f"\t{label}.GetTags() = [")
for tag in tags:
print (f"\t\t{tag}")
print ("\t\t]\n")
if __name__ == '__main__':
main()
running the script for both the spline objects A (red, one segment) and B (blue, two segements) will spit out the following output (minus the comments :) ) :
Data for A:
A.GetSegmentCount() = 0
A.GetTags() = [
# This is the problem here, there is no Tsgement tag on the spline and GetSegmentCount(),
# its underlying generic implementation, will therefore return `0` as it cannot find that tag.
<c4d.PointTag object called with ID 5600 at 1823374312960>
]
A(Cache).GetSegmentCount() = 1
A(Cache).GetTags() = [
<c4d.VariableTag object called with ID 5712 at 1823374308864>
<c4d.VariableTag object called with ID 5680 at 1823374308992>
<c4d.SegmentTag object called with ID 5672 at 1823374306048>
<c4d.PointTag object called with ID 5600 at 1823374305856>
]
Data for B:
B.GetSegmentCount() = 2
B.GetTags() = [
<c4d.SegmentTag object called with ID 5672 at 1823374290496>
<c4d.PointTag object called with ID 5600 at 1823374290368>
]
B(Cache).GetSegmentCount() = 2
B(Cache).GetTags() = [
<c4d.VariableTag object called with ID 5712 at 1823374286016>
<c4d.VariableTag object called with ID 5680 at 1823374283264>
<c4d.SegmentTag object called with ID 5672 at 1823374283072>
<c4d.PointTag object called with ID 5600 at 1823374281216>
]
So, for now, you should call GetSegmentCount()
on the LineObject
in the cache of the SplineObject
. But as I said, I personally would consider this a regression/bug. I will talk with the developers, but I faintly remember that with Tsgement
some oddities were intended because of the new modelling kernel. So we might consider this behavior intended. I will keep this thread updated.
edit: So, I briefly talked with one of the devs, and they somewhat consider this intended, so this will likely not be changed in the close future.
Cheers,
Ferdinand