How to update material settings using the material database from Python?
-
The function you are looking for is LinkMaterialWithDatabase().
This is how you can add new material settings with properties taken from the database
import s4l_v1.document as document import s4l_v1.model as model sim = document.AllSimulations[0] for ent in model.AllEntities(): mats = sim.AddMaterialSettings([ent]) mats.Name = ent.Name sim.LinkMaterialWithDatabase(mats, str(ent.MaterialName))To modify the settings of an existing simulation and update their properties, you can do something like this:
import s4l_v1.simulation as simulation material_settings = [s for s in sim.AllSettings if isinstance(s, simulation.fdtd.MaterialSettings)] for mats in material_settings: material_name = mats.Name sim.LinkMaterialWithDatabase(mats, material_name) -
D dbsim4 referenced this topic on
-
D dbsim4 referenced this topic on
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login