(Using: Cinema 4D 2025.1.1)
Hi there,
My Issue: I'm developing a Python script in Cinema 4D 2025.1.1 to filter the current edge selection based on a minimum length threshold. The goal is to keep only edges that are equal to or longer than the specified length.
Problem: While using the c4d.utils.Neighbor
class, several essential methods required for accurate edge mapping are missing in my environment, resulting in AttributeError. Specifically, the following methods are unavailable:
- GetEdgeID(polyIndex, localEdgeIndex)
- GetEdgeInfo(edgeID, pointsArray, polysArray)
- GetEdgePolygonPoints(polyIndex, localEdgeIndex)
- GetEdgePoints(edgeID)
Only GetPolyInfo(polyIndex) and GetEdgePolys(a, b) are accessible, leading to duplicate edge references and inaccurate filtering.
Holy Grail: I need the following Neighbor class methods to achieve precise edge filtering:
- GetEdgeID(polyIndex, localEdgeIndex)
- Purpose: Maps a polygon's local edge to Cinema 4D's global edge ID.
- GetEdgePolygonPoints(polyIndex, localEdgeIndex)
- Purpose: Retrieves the two point indices defining the edge.
These methods are crucial for eliminating indexing mismatches and ensuring each selected edge is measured accurately in global space.
Diagnostic Script: Below is a script that tests all kinds of Neighbor methods to identify which ones are available in my Cinema 4D 2025.1.1 environment.
import c4d
from c4d import gui, utils
def TestNeighborMethods():
doc = c4d.documents.GetActiveDocument()
obj = doc.GetActiveObject()
if not obj or not obj.IsInstanceOf(c4d.Opolygon):
gui.MessageDialog("Please select a Polygon Object first.")
return
neighbor = utils.Neighbor()
if not neighbor.Init(obj):
gui.MessageDialog("Failed to initialize Neighbor.")
return
polyCount = obj.GetPolygonCount()
print("========================================================")
print("Testing Neighbor methods on the selected object...")
print(f"Object: {obj.GetName() or 'Unnamed'}, Polygons: {polyCount}")
print("--------------------------------------------------------")
# List of Neighbor methods to test
methods = [
("GetPolyInfo", lambda: neighbor.GetPolyInfo(0)),
("GetEdgeID", lambda: neighbor.GetEdgeID(0, 0)),
("GetEdgeInfo", lambda: neighbor.GetEdgeInfo(0, [-1, -1], [-1, -1])),
("GetEdgePolygonPoints", lambda: neighbor.GetEdgePolygonPoints(0, 0)),
("GetEdgePoints", lambda: neighbor.GetEdgePoints(0)),
("GetEdgePolys", lambda: neighbor.GetEdgePolys(0, 1))
]
for name, func in methods:
try:
result = func()
print(f"{name}: Succeeded. Returned: {result}")
except AttributeError as e:
print(f"{name}: [FAILED] AttributeError: {e}")
except Exception as ex:
print(f"{name}: [FAILED] {ex}")
print("========================================================\n")
def main():
TestNeighborMethods()
if __name__ == "__main__":
main()
Request: Given that only GetPolyInfo() and GetEdgePolys(a, b) are available, how can I accurately map global edge IDs to their corresponding point indices to achieve precise edge filtering? Are there alternative methods or workarounds to obtain the necessary mappings without the missing Neighbor methods?
Thank You! Any insights or solutions from the community on accessing the necessary Neighbor methods or alternative approaches to achieve accurate edge filtering would be greatly appreciated!