Convert Catia parameters into Script Parameters

Gabriel Messager
Gabriel Messager Member, Employee Posts: 56
Second Anniversary 10 Comments 5 Likes Name Dropper
✭✭✭✭
edited June 2023 in 3D Design

Comments

  • Gabriel Messager
    Gabriel Messager Member, Employee Posts: 56
    Second Anniversary 10 Comments 5 Likes Name Dropper
    ✭✭✭✭
    from SpaceClaim.Api.V23 import Command
    
    def is_valid_float(element):
        try:
            float(element)
            return True
        except ValueError:
            return False
    
    
    comp= GetRootPart().Components[0]
    dict_custom_prop = comp.Content.Master.CustomProperties
    keys = dict_custom_prop.Keys
    
    for key in keys:
        value = "".join([ele for ele in dict_custom_prop[key].Value if ele.isdigit() or ele=="."])
        if is_valid_float(value) is True:
            Command.Execute("CreateNamedScriptParameter")
            mygroup = GetActiveWindow().Groups[-1]
            mygroup.SetName(key)
            mygroup.SetDimensionValue(float(value))