STK Objects - Frequently Asked Questions

How do I translate .NET color into Object Model compatible colors?

What is the proper way to embed STK Object Model in an HTML page?

Question:

How do I translate .NET color into Object Model compatible colors?

Answer:

This can be handled using the regular .Net framework OLE color conversion routines. For example:

r.Color = System.Convert.ToUInt32(System.Drawing.ColorTranslator.ToOle(System.Drawing.Color.Red));

Question:

I have a reference to the STK Object Model embedded in my HTML page, but some properties don't work. What am I doing wrong?

Answer:

Embedding objects using an <object> tag in fact creates two objects instead of one: one is an HTML element called "Application", and the other one, wrapped by the HTML element, represents the actual Object Model Root object whose classid was specified. Since any HTML element has a property "Children", the script was calling the HTML element's children property and not the object model one . To work around the issue, you can use a special property, "Object", to access the object behind the HTML element. Below is an example of how to access the Children collection exposed by the object "Application" (notice the Application.Object notation):

<!-- Application is an HTML element, not the Object Model Root!-->
<object name="Application" classid="CLSID:209CCD34-5CAF-486B-A092-A112C46C4DF2"></object>
<script language="VBScript">
' Get an object named "Planet1". To access the Children collection exposed
' by the IAgStkObject, first we have to get the real object model root object by
' calling the property "Object" on the Application HTML element.
Set planet = Application.Object.Children(0).Children("Planet1")
' Voila!

STK 11.2.1 Programming Interface