How to get value in CAD Parameters to python variable?

Lukas
Lukas Member Posts: 11
Name Dropper First Comment
**
edited June 2023 in Structures

Hello,

can you help me to get value of highlighted parameter to python variable? Thank you

Answers

  • Mike.Thompson
    Mike.Thompson Member, Employee Posts: 338
    25 Answers 100 Comments 25 Likes First Anniversary
    ✭✭✭✭

    For properties that are not directly exposed in the API, there is a general work around that often works. In the example below I get the property based on its caption string. You can then get either the InternalValue, or the StringValue and often convert to a usable variable based on simple logic.

    Geometry=ExtAPI.DataModel.Project.Model.Geometry
    PropCaption = "Import Facet Quality"
    for Prop in Geometry.VisibleProperties:
        if Prop.Caption==PropCaption:
            break
    MyProp = Prop
    print MyProp.InternalValue
    print MyProp.StringValue
    
  • Lukas
    Lukas Member Posts: 11
    Name Dropper First Comment
    **

    @Mike.Thompson thank you for your feedback. I tried this way but somehow it returnes wrong value. I was searching for while and figured out it returns value of standart deviation of mesh insted of my CAD Parameter? What do you suspect here?

    Geometry=ExtAPI.DataModel.Project.Model.Geometry

    PropCaption = "Part1:pleat_thickness"

    name=[]

    for Prop in Geometry.VisibleProperties:

      if Prop.Caption==PropCaption:

        break

    MyProp = Prop

    print MyProp.InternalValue

    print MyProp.StringValue

    print(Prop.name)

    #######################################

    It returns this no matter what string I put to PropCaption variable.


    0.219009462339

    0.21901

    MeshMetricSTDV


  • Lukas
    Lukas Member Posts: 11
    Name Dropper First Comment
    **

    @Mike.Thompson

    is there another option? This does not seem to work properly. Thank you