How to get value in CAD Parameters to python variable?

Member Posts: 13
First Anniversary 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

Welcome!

It looks like you're new here. Sign in or register to get started.

Answers

  • Member, Employee Posts: 385
    25 Answers 100 Comments Second Anniversary 25 Likes
    ✭✭✭✭

    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.

    1. Geometry=ExtAPI.DataModel.Project.Model.Geometry
    2. PropCaption = "Import Facet Quality"
    3. for Prop in Geometry.VisibleProperties:
    4.     if Prop.Caption==PropCaption:
    5.         break
    6. MyProp = Prop
    7. print MyProp.InternalValue
    8. print MyProp.StringValue
  • Member Posts: 13
    First Anniversary 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


  • Member Posts: 13
    First Anniversary Name Dropper First Comment
    **

    @Mike.Thompson

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

Welcome!

It looks like you're new here. Sign in or register to get started.