How to Get CAJoint points Counts(Bone Display Set : Polygon)



  • Bone Display Set:Polygon,i can change CAJoint point postion in Point Edit Mode.But how can i get more info or change,i can not use the function of PointObject to get a CAJoint info.
    How can I handle CAJoint like a PointObject?(My goal is to change the number of Points and Polygons of CAJoint.)
    Thanks for any help!



  • Hi @chuanzhen

    The CAJoint is registered as PolygonObject, unfortunately, due to the nature of python, is not possible to cast this CAJoint to a PolygonObject, while in C++ you could use the ToPoly macro to convert it.

    With that's said, you can still access the PolygonData/PointData with the hidden VariableTag: PointTag and PolygonTag.
    Here a quick example:

    import c4d
    
    # Main function
    def main():
        if not op:
            return
        
        tag = op.GetTag(c4d.Tpoint)
        if not tag:
            return
        
        pos = tag.GetAllHighlevelData()
        pos[0] = c4d.Vector(100, 0, 0)
        tag.SetAllHighlevelData(pos)
        op.Message(c4d.MSG_UPDATE)
        c4d.EventAdd()
    
    # Execute main()
    if __name__=='__main__':
        main()
    

    Of course, Tpoint and Tpolygon have no safety mechanism like ensure the VertexId are consistent and so on, so please be careful with the data you write since you can easily screw up the scene.

    Cheers,
    Maxime.



  • @m_adam Thanks


Log in to reply