• Skip to main content
  • Skip to search
  • Skip to footer
Cadence Home
  • This search text may be transcribed, used, stored, or accessed by our third-party service providers per our Cookie Policy and Privacy Policy.

  1. Community Forums
  2. Adams
  3. Python Interface Build Array Style Design Variables

Following Cadence Design Systems’ acquisition of the Design & Engineering (D&E) business, the D&E Community Forum on the Nexus Community Center has been migrated in the Cadence Physical System Simulation Community. For more details and if you have any questions, please refer to the FAQ.

Stats

  • State Not Answered
  • Replies 5
  • Subscribers 3
  • Views 13
  • Members are here 0
More Content

Python Interface Build Array Style Design Variables

michael.w.clarke
michael.w.clarke over 7 years ago
I am trying to dynamically populate a radio_box with the sheetnames from a spreadsheet. As far as I can tell there is no way to interact with gui elements through the Adams python interface. I have a python script that reads the spreadsheet data, so for convenience I tried to store the names in a design variable by using the Python DesignVariables.createString method. I could then use this design variable to populate the radio_box. Unfortunately the python design variable create methods seems to only accept a single string input instead of allowing the user to build an array.
 
The commands below are what I would do in regular command language...is there any way to do this via the python interface? Or better yet, is there any way to modify dialog boxes with the python interface?
 
variable create &
variable_name = DV_SheetList &
string = "123","456","789"
 
DV_SheetList[1] -> "123"
 
interface radio_box modify &
radio_box_name = .gui.radio_sheets &
choices = (eval(DV_SheetList))
  • Sign in to reply
  • Cancel
  • Kent West
    0 Kent West over 7 years ago
    Hi Michael,
     
    There is an existing enhancement/issue open on the fact that design variables are only scalars and need to be vectors from the Python API; hopefully that's sorted out in the future.
     
    In the meantime you can issued cmd language from your Python script in Adams, like this:
    cmd = "variable set variable={} string='{}', '{}', '{}'".format(sheetName, str1, str2, str3)
    Adams.execute_cmd(cmd)
     
    I wonder if building up a cmd string in Python, like above, and then sending to Adams.evaulate_exp() or Adams.execute_cmd() would be appropriate for your application?
     
    HTH,
    Kent
     
    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • MK202610123211
    0 MK202610123211 over 7 years ago
    If you have the appropriate cmd-language expressions/commands, then you're done.
    Simply put 'em in a one line string in Python, use the old import aview_main and
    aview_main.execute_cmd()
     
    A good example would be my personal cre_mod_var() function which doesn't use Kent's build-in format-method but a simple %-formatting.
     
    def db_exists(entity):
     element_exists = 0
     expression = "DB_EXISTS(\"%s\")" % entity
     try:
       element_exists = aview_main.evaluate_exp(expression)
     except:
       element_exists = 0
     # print 'Element %s exists = %d' % (entity,element_exists)
     return element_exists
     
    def cre_mod_pv(pv_name,model,symmetry,typ,value):
     full_pv_name = "%s.pv%s_%s" % (model,symmetry,pv_name)
     if db_exists(full_pv_name):
       cremod = 'modify'
     else:
       cremod = 'create'
     #
     if (typ == 'real'):
        command = "variable %s variable = %s real_value = %s" % (cremod,full_pv_name,str(float(value)))
     if (typ == 'string'):
        command = "variable %s variable = %s string_value = \"%s\"" % (cremod,full_pv_name,str(value))
     if (typ == 'integer'):
        command = "variable %s variable = %s integer_value = %s" % (cremod,full_pv_name,str(int(value)))
     aview_main.execute_cmd(command)
     
     
     
     
    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • michael.w.clarke
    0 michael.w.clarke over 7 years ago
    Thanks guys. I didn't think of building/executing the command language call from python. In that case I can probably just skip setting the design variable and modify the radio box directly using a execute_cmd() call.
     
    @Kent West​  are there any plans to allow direct interaction with gui elements from the python interface in the future?
    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • Kent West
    0 Kent West over 7 years ago
    Hi Michael,
     
    This notion has been 'on the radar' for a long time, yes. Our Product Development group has been looking for a nice way to implement this; I'm not the person to make promises in this area so I'll forward your feedback to our Product Management group.
     
    The current state of the art is:
     
    1. Use standard dbox elements with cmd language. Issue cmd from Python where necessary. So you make the GUI in the standard way with a light cmd macro wrapper layer, then put most of your logic in Python. This works well if you do this full-time like we do; this switching back and forth between languages is likely painful for power users like yourselves..
    2. Another option for those having a zeal for programming & python is to:
      1. Create rough window layout using Qt Creator (en.wikipedia.org/.../Qt_Creator)
      2. Figure out how to get this new window as a child window in View...
      3. Use PyQt tools to create Python code for this. (rk.edu.pl/.../)
     
    You can make really nice GUI elements via the 2nd method but the learning curve is large AND we don't officially support it. (When we upgrade the Qt windowing toolkit in the future things will almost certainly change and you'll have to revisit your GUI code for the latest Qt version).
     
    The standard dbox builder stuff in View, FWIW, is very capable. I personally have tried both methods above and think I'd stick with option #1 unless I really need some advanced GUI element, like a treeview.
     
    Thanks,
    Kent
     
    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • MK202610123211
    0 MK202610123211 over 7 years ago
    Short anecdote to make you giggle:
    Had a colleague who wanted a progress bar for his Python based toolkit. He did go option #2. Took him ages and endless swearing until it worked.
    Years later I had the same desire but neither wanted to use the whole plugin nor cut out the progress bar part.
    Solved it by simply creating a dbox element with a label that has a bitmap file. The trick: Count how many maneuvers you completed and update the dbox-label during macro execution with a different png (I have png's with 0%, 10%, ...., 100%).
     
    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
Cadence Guidelines

Community Guidelines

The Cadence Design Communities support Cadence users and technologists interacting to exchange ideas, news, technical information, and best practices to solve problems and get the most from Cadence technology. The community is open to everyone, and to provide the most value, we require participants to follow our Community Guidelines that facilitate a quality exchange of ideas and information. By accessing, contributing, using or downloading any materials from the site, you agree to be bound by the full Community Guidelines.

© 2026 Cadence Design Systems, Inc. All Rights Reserved.

  • Terms of Use
  • Privacy
  • Cookie Policy
  • US Trademarks
  • Do Not Sell or Share My Personal Information