Skip to main content
Ctrl+K
ansys-speos-core 0.4.0 documentation - Home ansys-speos-core 0.4.0 documentation - Home
  • Overview
  • Getting started
  • API reference
  • Examples
  • Contribute
    • Release notes
Ctrl+K
  • GitHub
Ctrl+K
  • Overview
  • Getting started
  • API reference
  • Examples
  • Contribute
  • Release notes
  • GitHub

Section Navigation

Workflow examples

  • How to open result (MS Windows OS only)
  • Moving car example by combining Speos files

Core examples

  • How to create a project
  • How to create an optical property
  • How to create a source
  • How to create a sensor
  • How to create a part
  • How to create a simulation
  • How to preview a light expert result
  • Prism example

Kernel examples

  • How to use an ObjectLink
  • How to use scene and job
  • How to modify scene elements
  • Examples
  • How to use an ObjectLink

Download as Python script

Download as Jupyter notebook

Download example’s assets


How to use an ObjectLink#

This tutorial demonstrates how to use speos objects in layer core.

What is an ObjectLink?#

The ObjectLink is an object that is created from a protobuf message and then stored in the server database.

Which speos objects are used via ObjectLink?#

Almost all speos objects are used via ObjectLink: like sources, sensors, simulations and more. For this tutorial we will use as example the surface optical property (sop)

[1]:
from ansys.speos.core.kernel.sop_template import ProtoSOPTemplate
from ansys.speos.core.speos import Speos

Create connection with speos rpc server

[2]:
speos = Speos(host="localhost", port=50098)

Create an ObjectLink#

Retrieve the access to the database.

[3]:
sop_t_db = speos.client.sop_templates()

Create the protobuf message.

[4]:
sop_t = ProtoSOPTemplate()
sop_t.name = "Mirror_90"
sop_t.mirror.reflectance = 90.0

Create the ObjectLink (here a SOPTemplateLink).

[5]:
mirror_90_link = sop_t_db.create(message=sop_t)
print(mirror_90_link)
ansys.api.speos.sop.v1.SOPTemplate
{
    "name": "Mirror_90",
    "mirror": {
        "reflectance": 90.0
    },
    "description": "",
    "metadata": {}
}

Create another ObjectLink from another protobuf message.

[6]:
sop_t = ProtoSOPTemplate()
sop_t.name = "Mirror_100"
sop_t.mirror.reflectance = 100.0

mirror_100_link = sop_t_db.create(message=sop_t)

Modify an ObjectLink#

Retrieve the protobuf message corresponding to the ObjectLink.

[7]:
mirror_data = mirror_90_link.get()

Modify data locally

[8]:
mirror_data.name = "Mirror_50"
mirror_data.mirror.reflectance = 50

Update on db

[9]:
mirror_90_link.set(data=mirror_data)
print(mirror_90_link)
ansys.api.speos.sop.v1.SOPTemplate
{
    "name": "Mirror_50",
    "mirror": {
        "reflectance": 50.0
    },
    "description": "",
    "metadata": {}
}

Delete an ObjectLink#

This means deleting data in db

[10]:
mirror_100_link.delete()
mirror_90_link.delete()
sop_t_db.list()
[10]:
[]
On this page
  • What is an ObjectLink?
  • Which speos objects are used via ObjectLink?
  • Create an ObjectLink
  • Modify an ObjectLink
  • Delete an ObjectLink
  • Show Source

© Copyright (c) 2025 ANSYS, Inc. All rights reserved.

Created using Sphinx 8.1.3.

Built with the Ansys Sphinx Theme 1.4.2.
Last updated on