How can I assign a material to multiple bodies in Spaceclaim?

Gabriel Messager
Gabriel Messager Member, Employee Posts: 43
10 Comments First Anniversary Ansys Employee Photogenic
edited June 21 in 3D Design

How can I assign a material to multiple bodies in Spaceclaim?

The material can be in the Local Materials or in the Library


Comments

  • Gabriel Messager
    Gabriel Messager Member, Employee Posts: 43
    10 Comments First Anniversary Ansys Employee Photogenic
    material_name = "Gray Cast Iron"
    succ_local, local_mat = Window.ActiveWindow.Document.Materials.TryGetValue(material_name)
    if not succ_local:
        succ, mat = LibraryMaterial.Library.TryGetValue(material_name)
        local_mat = DocumentMaterial.Copy(Window.ActiveWindow.Document, mat)
    for body in GetRootPart().GetAllBodies():
        body2.Material = local_mat
    
  • Nikos Kallitsis
    Nikos Kallitsis Member, Employee Posts: 18
    10 Comments Ansys Employee Name Dropper Photogenic

    @Gabriel Messager , the LibraryMaterial and DocumentMaterial libraries are available if accessed using SC release's API. For example, for V20:

    material_name = "Gray Cast Iron"
    succ_local, local_mat = Window.ActiveWindow.Document.Materials.TryGetValue(material_name)
    if not succ_local:
    succ, mat = SpaceClaim.Api.V20.LibraryMaterial.Library.TryGetValue(material_name)
    local_mat = SpaceClaim.Api.V20.DocumentMaterial.Copy(Window.ActiveWindow.Document, mat)
    for body in GetRootPart().GetAllBodies():
    body.Material = local_mat