-
-
September 5, 2023 at 1:16 pm
Berker Yilmaz
Subscriber
I want to assign different materials to different objects, with a single command.
This is the command for assigning a material to an object:
oEditor.ChangeProperty(["NAME:AllTabs",["NAME:Geometry3DAttributeTab",["NAME:PropServers","Object_1"],["NAME:ChangedProps",["NAME:Material","Value:=" , "Material_1"]]]])
I know that I can add other objects i.e. Object_2, Object_3 etc. to the "NAME:PropServers" part on script above. And "Material_1" will be assigned to multiple objects with a single command. Instead, I want to assign "Material_1" to "Object_1", and "Material_2" to "Object_2", and so on...
I have defined object and material name arrays to be assigned. But I have +1000 objects to assign, therefore running this command in a for loop result in a very long time of individual material assignment.
Is there any trick to make all assignments without a for loop on each object? -
September 7, 2023 at 12:57 pm
HDLI
Ansys EmployeeHello Berker,
We could select all the objects that have same materail and assign material properties at one time, like:
"NAME:PropServers",
"object1","object2","object3",...
Thus, we could use use a array here.
I also suggest you to use pyaedt, that is open source in Github. https://github.com/ansys/pyaedt/releases
or in https://aedt.docs.pyansys.com/version/stable/, that you could share or submit issues.
Thanks.
HDLI
-
September 7, 2023 at 1:26 pm
Berker Yilmaz
SubscriberHello HDLI
Thank you for the reply, but I am afraid that is not the answer I was looking for.
As I explained on the question, I know it is possible to add other objects to "NAME:PropServers" section. But that would assign the same material to defined objects.
I want to define individual material definitions, such as material[index1], material[index2] etc. to control the material on each object seperately by indexes. ( There are 1000+ subdomain objects) And as i said, if I use a for loop, that takes a lot of time just for assigning materials.
-
-
September 7, 2023 at 1:45 pm
HDLI
Ansys EmployeeHello Berker,
There are many loops to run about 1000+, you spend lots of time to assign materials because you want to assign one by one.
If you group them to assign materials like above, you do not need to run many loops that could save time.
Do you have 1000+ different materials? If Yes, it is what it is, and there is no way to skip it.
HDLI
-
September 7, 2023 at 1:55 pm
Berker Yilmaz
SubscriberI do not have 1000+ different materials, I only have 2 different materials. But I want to parametrize each object for either assigning or not assigning a certain material to it, and use optimetrics to utilize parallel simulation, for an emag topology optimization.
I also realized even if I assign materials with a for loop, there is a bigger problem. Optimetrics is not good at handling the 1000+ parameter sweep. The simulation slows a lot, I assume due to reading a lot of the variables.
I am not sure if there is any other easier way to do it on pyaedt?
-
-
- You must be logged in to reply to this topic.

Boost Ansys Fluent Simulations with AWS
Computational Fluid Dynamics (CFD) helps engineers design products in which the flow of fluid components is a significant challenge. These different use cases often require large complex models to solve on a traditional workstation. Click here to join this event to learn how to leverage Ansys Fluids on the cloud, thanks to Ansys Gateway powered by AWS.

Earth Rescue – An Ansys Online Series
The climate crisis is here. But so is the human ingenuity to fight it. Earth Rescue reveals what visionary companies are doing today to engineer radical new ideas in the fight against climate change. Click here to watch the first episode.

Ansys Blog
Subscribe to the Ansys Blog to get great new content about the power of simulation delivered right to your email on a weekly basis. With content from Ansys experts, partners and customers you will learn about product development advances, thought leadership and trends and tips to better use Ansys tools. Sign up here.
- simulation completed with execution error on server
- Maxwell, HFSS or Q3D?
- Unable to assign correctly the excitations in a coil
- How to export Ansys Maxwell simulation results for post-processing in matlab or in .csv file
- Intersect errors with model with complex structure
- Running ANSYS HFSS on the HPC (it runs on Linux only)
- Process ‘3dtds’ terminated abnormally
- Error while solving Optimetrics
- Error
- Concept of Interpolation Sweep in HFSS
-
7582
-
4426
-
2949
-
1422
-
1322
© 2023 Copyright ANSYS, Inc. All rights reserved.