Skip to content

HFSS variable assignment! #3671

Closed Answered by Samuelopez-ansys
Abhi-SimuTech asked this question in Q&A
Discussion options

You must be logged in to vote

Hi @Abhi-SimuTech ,

Please next time provide the code, instead of a screenshot, because it takes time to write the code.

About the issue, this is a python escape character problem, you need to add the explicit quotes with the backslash ().

m1[key] = '["' + value + '"]'

Then the final code is:

import pyaedt

m1 = pyaedt.Hfss(specified_version="2023.2", new_desktop_session=False)

params = {"gapZ": 0, "prefix": "_a1_"}

m1["prefix"] = '["_a1_"]'

for key, value in params.items():
    if not isinstance(value, str):
        m1[key] = "{}{}".format(value, "mm")
    else:
        m1[key] = '[\"' + value + '\"]' 

m1.release_desktop(False, False)

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by Samuelopez-ansys
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants