-
-
December 12, 2024 at 12:32 am
yasuhiro.ogawa.j4a
Subscriber・ANSYS WorkbenchのMechanicalにおいて、ジオメトリ内のすべてのボディにコマンドを挿入したい。 ・挿入したコマンドには「mat1=matid」と設定したい。数字の"1"の部分はボディの数だけ1,2,3,・・・と連番とする。 ・ボディの数が多いのでスクリプティングで自動化したいです。 全てのボディのID取得から考えましたが、うまくいかずでしたので、質問させていただきます。よろしくお願いいたします。
-
December 12, 2024 at 11:59 am
Ashish Khemka
Forum ModeratorTranslated: - In ANSYS Workbench Mechanical, I want to insert a command into all bodies in the geometry. - I want to set the inserted command to "mat1 = matid". The number "1" is numbered sequentially by the number of bodies, such as 1, 2, 3, and so on. ・ Since there are many bodies, I want to automate it by scripting.Are. I thought about getting IDs for all bodies, but it didn't work, so I'd like to ask a question. Best regards.
-
December 12, 2024 at 12:20 pm
Aniket
Forum Moderatoryou can traverse tree as shown in code snippet below:
https://ansyshelp.ansys.com/public/account/secured?returnurl=/Views/Secured/corp/v242/en/act_script/act_script_examples_get_GeoData.htmlonly first line is important, you can list all the children of each part by changing the number. now next part would be adding command snippets that can be done using following:
https://ansyshelp.ansys.com/public/account/secured?returnurl=/Views/Secured/corp/v242/en/act_script/mech_apis_CommandSnippets.html-Aniket
-
-
December 13, 2024 at 5:59 am
yasuhiro.ogawa.j4a
SubscriberThank you for your response. Based on your comments, I was able to accomplish what I wanted to do. FYI, I am attaching the code.
# Creating the content to write in the command
mat_list = []
for i in range(1, 100):
mat_list.append("mat{}".format(i))# Creating the command and writing the contents
for num in range(1, 100):treeBody = Model.Geometry.Children[0].Children[num-1]
cs = treeBody.AddCommandSnippet()
cs.AppendText(mat_list[num-1])
-
- このトピックに返信するには、ログインする必要があります。
-
1932
-
823
-
599
-
591
-
366
© 2025 Copyright ANSYS, Inc. All rights reserved.