speos caa v5 based automation - optis...

43
SPEOS CAA V5 Based Automation V16.1

Upload: docong

Post on 06-Mar-2018

597 views

Category:

Documents


24 download

TRANSCRIPT

SPEOS CAA V5 Based

Automation

V16.1

Table of Contents

What is Automation .................................................................................................. 4

Automation in SPEOS CAA V5 Based .............................................................................. 5

APIs ...................................................................................................................... 6 SPEOS CAA V5 Based .......................................................................................... 6

Object Hierarchy....................................................................................... 6 Obsolete Interfaces ................................................................................... 6 Interfaces ............................................................................................... 7 Methods................................................................................................. 16 Properties .............................................................................................. 19

SPEOS Core .................................................................................................... 29 Using SPEOS Core Automation ...................................................................... 29 Methods................................................................................................. 30

Tutorial ............................................................................................................... 33 Lesson 1: Creating the Macro ............................................................................... 33 Lesson 2: Recording Operations ............................................................................ 33 Lesson 3: Getting the Simulation Object ................................................................. 33 Lesson 4: Editing the Macro ................................................................................ 34 Lesson 5: Running the Macro ............................................................................... 35 Lesson 6: Creating the Second Macro ..................................................................... 35 Lesson 7: Writing the Optimization Algorithm .......................................................... 36 Lesson 8: Running the Optimization ....................................................................... 38 1st Macro - Automation Tutorial ........................................................................... 39 2nd Macro - Automation Tutorial .......................................................................... 40

Page 4 of 43 SPEOS CAA V5 Based Automation User Guide

WHAT IS AUTOMATION

General Description

With Automation, you can communicate with any Windows applications.

Automation can replace the old specific macro way method for writing script.

With automation you can:

Write script using any language compatible with Automation (VB Script, C++...),

Directly access results data without knowing specific format (like XMP file),

Write your own HTML reports that automatically analyze the results,

Write your own optimization code...

Technical Description

Automation is based on COM (Component Object Model).

This is a standard way to describe the interface exposed by a Windows application to other Windows applications.

The interface is described using the IDL (Interface Description Language).

This interface is used to give the description of all data and functions (and their parameters) that can be called from

another application.

The exposed data are called Properties.

The exposed functions are called Methods.

Development Tools

If you want to use Automation, you need to decide which language to use depending on your needs.

For basic needs the VB Script or VBA language is the easiest to understand and to use for a non-developer.

You can use VB Script in HTML file.

You can use FrontPage for editing the HTML file.

VB Script or VBA is also included in a lot of software.

When you write a macro with this software, the VB Script language is used.

So it is very easy to write macro that mix CAD VB Script or VBA instructions and Virtual Photometric Lab VB Script

instructions : using your own merit function you have your own optimization tool.

For more complex needs, you must use C++, which is a more difficult language to learn for non developers.

If you want to have advices, code fraction and API functions' examples, you can view these APIs

(http://www.solidworks.com/api).

Automation in SPEOS CAA V5 Based Page 5 of 43

AUTOMATION IN SPEOS CAA V5 BASED

What You Can Do with Automation in SPEOS CAA V5 Based

You can launch simulations, get the results and load them.

SPEOS CAA V5 Based Automation includes functions giving access to data.

This section of the SPEOS CAA V5 Based Automation help includes:

A Tutorial section that gives you an overview of what SPEOS CAA V5 Based Automation can achieve with 2

examples of Visual Basic script

The description of all the SPEOS CAA V5 Based Automation APIs (see page 6).

The description of all the SPEOS CAA V5 Based Standalone Automation APIs (see page 29).

What SPEOS CAA V5 Based APIs Can Achieve

Changing sources' configuration (for example flux, type of spectrum...) for luminaire sources.

Launching illuminance and luminance simulations (Direct and Inverse simulations).

SPEOS CAA V5 Based and SPEOS Core Automation APIs can be used with OPTIS Labs Automation to analyze the

results (you can view OPTIS Labs Automation Index page or OPTIS Labs Automation).

Basic Tasks

Getting a SPEOS CAA V5 Based Object

This method gets the object related to the Simulation. int GetItem ();

1. From Microsoft Visual Basic, select Insert, Object resolution.

-Or -

From the Macros Editor, select Edit, Insert object resolution.

2. Select the simulation in the specification tree, and the following code is created.

'---- Begin resolution script for object: simu

Dim productDocument1 As productDocument

Set productDocument1 = CATIA.ActiveDocument

Dim product1 As product

Set product1 = productDocument1.product

Dim speosNodeRoot1 As speosNodeRoot

Set speosNodeRoot1 = product1.GetItem("OPTVBExtension").SpeosCAA()

Dim speosNodeSimulation1 As speosNodeSimulation

Set speosNodeSimulation1 = speosNodeRoot1.Item("Simulations")

Dim simuDirect1 As SimuDirect

Set simuDirect1 = speosNodeSimulation1.Item("Simu")

'---- End resolution script

Updating a SPEOS CAA V5 Based Object

This method updates the object related to the Simulation. Boolean Update (); Returns a Boolean that can be used to

check if the simulation runs correctly.

Dim bUpdate As Boolean bUpdate = Simu.Update

Page 6 of 43 SPEOS CAA V5 Based Automation User Guide

APIS

SPEOS CAA V5 Based

Object Hierarchy

IUnknown

+---IDispatch

+---CATBaseUnknown

+---CATBaseDispatch

+---AnyObject

+---OPTSpeosCAAProduct (see page 11) (SpeosCAAProduct (see page 11))*

+---OPTSpeosFeature (see page 11) (SpeosFeature (see page 11))*

+---OPTSimu (see page 7) (Simu (see page 7))*

+---OPTSimuDirect (see page 7) (SimuDirect (see page 7))*

+---OPTSimuInteractive (see page 8) (SimuInteractive (see page 8))*

+---OPTSimuInverse (see page 8) (SimuInverse (see page 8))*

+---Collection

+---OPTSpeosNode (see page 12) (SpeosNode (see page 12))*

+---OPTSpeosNodeMeasure (see page 12) (SpeosNodeMeasure (see page 12))*

+---OPTSpeosNodeOpticalProperties (see page 13) (SpeosNodeOpticalProperties (see

page 13))*

+---OPTSpeosNodeRoot (see page 13) (SpeosNodeRoot (see page 13))*

+---OPTSpeosNodeSensor (see page 14) (SpeosNodeSensor (see page 14))*

+---OPTSpeosNodeSimulation (see page 15) (SpeosNodeSimulation (see page 15))*

+---OPTSpeosNodeSource (see page 15) (SpeosNodeSource (see page 15))*

+---OPTSourceBase (see page 9)

+---OPTSourceLuminaire (see page 10)

+---OPTSpeosNodeWindshield (see page 16) (SpeosNodeWindshield (see page 16))*

()* Obsolete Interfaces available before version 6.0

Obsolete Interfaces

SpeosCAAProduct has been replaced by OPTSpeosCAAProduct (see page 11)

SpeosFeature has been replaced by OPTSpeosFeature (see page 11)

Simu has been replaced by OPTSimu (see page 7)

SimuDirect has been replaced by OPTSimuDirect (see page 7)

SimuInteractive has been replaced by OPTSimuInteractive (see page 8)

SimuInverse has been replaced by OPSimuInverse (see page 8)

SpeosNode has been replaced by OPTSpeosNode (see page 12)

SpeosNodeMeasure has been replaced by OPTSpeosNodeMeasure (see page 12)

APIs Page 7 of 43

SpeosNodeOpticalProperties has been replaced by OPTSpeosNodeOpticalProperties (see page 13)

SpeosNodeRoot has been replaced by OPTSpeosNodeRoot (see page 13)

SpeosNodeSensor has been replaced by OPTSpeosNodeSensor (see page 14)

SpeosNodeSimulation has been replaced by OPTSpeosNodeSimulation (see page 15)

SpeosNodeSource has been replaced by OPTSpeosNodeSource (see page 15)

SpeosNodeWindshield has been replaced by OPTSpeosNodeWindshield (see page 16)

Interfaces

OPTSimu Interface

SpeosFeature (see page 11)

+---OPTSimu (Simu)

Description

With the Simulation Interface, you can manage a simulation. It is part of CATIA V5 OPTSimuInterfaces Object Library.

Property Index

Application (see page 19)

Name (see page 21)

Parent (see page 22)

Method Index

GetItem (see page 17)

Update (see page 19)

Example

Dim speosCAAProduct1 As OPTSpeosCAAProduct

Dim speosNode1 As OPTSpeosNode

Dim speosNodeSimulation1 As OPTSpeosNodeSimulation

Dim simu1 As OPTSimu

Set speosCAAProduct1 = product1.GetItem("OPTVBExtension")

Set speosNode1 = speosCAAProduct1.SpeosCAA

Set speosNodeSimulation1 = speosNode1.Item("Simulations")

Set simu1 = speosNodeSimulation1.Item("Inverse simulation.1")

simu1.Update

OPTSimDirect Interface

SpeosFeature (see page 11)

+---OPTSimu (see page 7) (Simu)

+---OPTSimuDirect (SimuDirect)

Description

With the OPTSimuDirect Interface, you can manage a direct simulation. It is part of CATIA V5 OPTSimuInterfaces

Object Library.

Property Index

Application (see page 19)

Name (see page 21)

Page 8 of 43 SPEOS CAA V5 Based Automation User Guide

Parent (see page 22)

Method Index

GetItem (see page 17)

Update (see page 19)

Example

Dim speosCAAProduct1 As OPTSpeosCAAProduct

Dim speosNode1 As OPTSpeosNode

Dim speosNodeSimulation1 As OPTSpeosNodeSimulation

Dim simu1 As OPTSimuDirect

Set speosCAAProduct1 = product1.GetItem("OPTVBExtension")

Set speosNode1 = speosCAAProduct1.SpeosCAA

Set speosNodeSimulation1 = speosNode1.Item("Simulations")

Set simu1 = speosNodeSimulation1.Item("Direct simulation.1")

simu1.Update

OPTSimuInteractive Interface

SpeosFeature (see page 11)

+---OPTSimu (see page 7) (Simu)

+---OPTSimuInteractive (SimuInteractive)

Description

With the OPTSimuInteractive Interface, you can manage an interactive simulation. It is part of CATIA V5

OPTSimuInterfaces Object Library.

Property Index

Application (see page 19)

Name (see page 21)

Parent (see page 22)

Method Index

GetItem (see page 17)

Update (see page 19)

Example

Dim speosCAAProduct1 As OPTSpeosCAAProduct

Dim speosNode1 As OPTSpeosNode

Dim speosNodeSimulation1 As OPTSpeosNodeSimulation

Dim simu1 As OPTSimuInteractive

Set speosCAAProduct1 = product1.GetItem("OPTVBExtension")

Set speosNode1 = speosCAAProduct1.SpeosCAA

Set speosNodeSimulation1 = speosNode1.Item("Simulations")

Set simu1 = speosNodeSimulation1.Item("Interactive simulation.1")

simu1.Update

OPTSimuInverse Interface

SpeosFeature (see page 11)

+---OPTSimu (see page 7) (Simu)

APIs Page 9 of 43

SpeosFeature (see page 11)

+---OPTSimuInverse (SimuInverse)

Description

With the OPTSimuInverse Interface, you can manage a inverse simulation. It is part of CATIA V5 OPTSimuInterfaces

Object Library.

Property Index

Application (see page 19)

Name (see page 21)

Parent (see page 22)

Method Index

GetItem (see page 17)

Update (see page 19)

Example

Dim speosCAAProduct1 As OPTSpeosCAAProduct

Dim speosNode1 As OPTSpeosNode

Dim speosNodeSimulation1 As OPTSpeosNodeSimulation

Dim simu1 As OPTSimuInverse

Set speosCAAProduct1 = product1.GetItem("OPTVBExtension")

Set speosNode1 = speosCAAProduct1.SpeosCAA

Set speosNodeSimulation1 = speosNode1.Item("Simulations")

Set simu1 = speosNodeSimulation1.Item("Inverse simulation.1")

simu1.Update

OPTSourceBase Interface

OPTSpeosNode (see page 12) (SpeosNode)

+---OPTSpeosNodeSource (see page 15) (SpeosNodeSource)

+---OPTSourceBase

Description

With the OPTSourceBase Interface, you can manage basic sources (except luminary sources). It is part of CATIA V5

OPTSourceInterfaces Object Library.

Property Index

Application (see page 19)

Name (see page 21)

Parent (see page 22)

Method Index

GetItem (see page 17)

Update (see page 19)

Example

Dim productDocument1 As ProductDocument

Dim product1 As Product

Dim documents1 As Documents

Dim speosNodeRoot1 As OPTSpeosNodeRoot

Page 10 of 43 SPEOS CAA V5 Based Automation User Guide

Dim speosNodeSource1 As OPTSpeosNodeSource

Dim SourceBase1 As OPTSourceBase

Set documents1 = CATIA.Documents

Set productDocument1 = CATIA.ActiveDocument

Set product1 = productDocument1.Product

Set speosNodeRoot1 = product1.GetItem("OPTVBExtension").speosCaa()

Set speosNodeSource1 = speosNodeRoot1.Item("Sources")

Set SourceBase1 = speosNodeSource1.Item("MySource")

OPTSourceLuminaire Interface

OPTSpeosNode (see page 12) (SpeosNode)

+---OPTSpeosNodeSource (see page 15) (SpeosNodeSource)

+---OPTSourceLuminaire

Description

With the OPTSourceLuminaire Interface, you can manage luminary sources. It is part of CATIA V5

OPTSourceInterfaces Object Library.

Property Index

Application (see page 19)

IntensityFile (see page 20)

Name (see page 21)

Origin (see page 21)

Parent (see page 22)

RayNumber (see page 22)

SpectrumBlackBody (see page 23)

SpectrumFile (see page 24)

SpectrumType (see page 25)

XDirection (see page 26)

XReverse (see page 27)

YDirection (see page 28)

YReverse (see page 29)

Method Index

GetItem (see page 17)

Update (see page 19)

Example

Dim productDocument1 As ProductDocument

Dim product1 As Product

Dim documents1 As Documents

Dim speosNodeRoot1 As OPTSpeosNodeRoot

Dim speosNodeSource1 As OPTSpeosNodeSource

Dim SourceLuminaire1 As OPTSourceLuminaire

Set documents1 = CATIA.Documents

Set productDocument1 = CATIA.ActiveDocument

Set product1 = productDocument1.Product

APIs Page 11 of 43

Set speosNodeRoot1 = product1.GetItem("OPTVBExtension").speosCaa()

Set speosNodeSource1 = speosNodeRoot1.Item("Sources")

Set SourceLuminaire1 = speosNodeSource1.AddNewLuminaireSource()

OPTSpeosCAAProduct Interface

AnyObject

+---OPTSpeosCAAProduct (SpeosCAAProduct)

Description

With the OPTSpeosCAAProduct Interface, you can manage the SPEOS CAA V5 Based node. It is part of CATIA V5

OPTSpeosInterfaces Object Library.

Property Index

Application (see page 19)

Name (see page 21)

Parent (see page 22)

Method Index

GetItem (see page 17)

SpeosCAA (see page 19)

Example

Dim productDocument1 As ProductDocument

Dim product1 As Product

Dim speosCAAProduct1 As OPTSpeosCAAProduct

Dim speosNodeRoot1 As OPTSpeosNodeRoot

Set productDocument1 = CATIA.ActiveDocument

Set product1 = productDocument1.Product

Set speosCAAProduct1 = product1.GetItem("OPTVBExtension")

Set speosNodeRoot1 = speosCAAProduct1.SpeosCAA

OPTSpeosFeature Interface

AnyObject

+---OPTSpeosFeature (SpeosFeature)

Description

The OPTSpeosFeature Interface is part of CATIA V5 OPTSpeosInterfaces Object Library.

Property Index

Application (see page 19)

Name (see page 21)

Parent (see page 22)

Method Index

GetItem (see page 17)

Update (see page 19)

Page 12 of 43 SPEOS CAA V5 Based Automation User Guide

OPTSpeosNode Interface

Collection

+---OPTSpeosNode (SpeosNode)

Description

The OPTSpeosNode Interface is part of CATIA V5 OPTSpeosInterfaces Object Library.

Property Index

Application (see page 19)

Count (see page 20)

Name (see page 21)

Parent (see page 22)

Method Index

GetItem (see page 17)

Item (see page 18)

Example

Dim productDocument1 As ProductDocument

Dim product1 As Product

Dim speosCAAProduct1 As OPTSpeosCAAProduct

Dim speosNode As OPTSpeosNode

Set productDocument1 = CATIA.ActiveDocument

Set product1 = productDocument1.Product

Set speosCAAProduct1 = product1.GetItem("OPTVBExtension")

Set speosNode1 = speosCAAProduct1.SpeosCAA

OPTSpeosNodeMeasure Interface

OPTSpeosNode (see page 12) (SpeosNode)

+---OPTSpeosNodeMeasure (SpeosNodeMeasure)

Description

With the OPTSpeosNodeMeasure Interface, you can manage the measure node. It is part of CATIA V5

OPTSpeosInterfaces Object Library.

Property Index

Application (see page 19)

Count (see page 20)

Name (see page 21)

Parent (see page 22)

Method Index

GetItem (see page 17)

Item (see page 18)

Example

Dim productDocument1 As ProductDocument

Dim product1 As Product

Dim speosCAAProduct1 As OPTSpeosCAAProduct

APIs Page 13 of 43

Dim speosNode1 As OPTSpeosNode

Dim speosNodeMeasure1 As OPTSpeosNodeMeasure

Set productDocument1 = CATIA.ActiveDocument

Set product1 = productDocument1.Product

Set speosCAAProduct1 = product1.GetItem("OPTVBExtension")

Set speosNode1 = speosCAAProduct1.SpeosCAA

Set speosNodeMeasure1 = speosNode1.Item("Measures")

OPTSpeosNodeOpticalProperties Interface

OPTSpeosNode (see page 12) (SpeosNode)

+---OPTSpeosNodeOpticalProperties (SpeosNodeOpticalProperties)

Description

WIth the OPTSpeosNodeOpticalProperties Interface, you can manage the optical properties node. It is part of CATIA

V5 OPTSpeosInterfaces Object Library.

Property Index

Application (see page 19)

Count (see page 20)

Name (see page 21)

Parent (see page 22)

Method Index

GetItem (see page 17)

Item (see page 18)

Example

Dim productDocument1 As ProductDocument

Dim product1 As Product

Dim speosCAAProduct1 As OPTSpeosCAAProduct

Dim speosNode1 As OPTSpeosNode

Dim speosNodeOpticalProperties1 As OPTSpeosNodeOpticalProperties

Set productDocument1 = CATIA.ActiveDocument

Set product1 = productDocument1.Product

Set speosCAAProduct1 = product1.GetItem("OPTVBExtension")

Set speosNode1 = speosCAAProduct1.SpeosCAA

Set speosNodeOpticalProperties1 = speosNode1.Item("Optical Properties")

OPTSpeosNodeRoot Interface

OPTSpeosNode (see page 12) (SpeosNode)

+---OPTSpeosNodeRoot (SpeosNodeRoot)

Description

The OPTSpeosNodeRoot Interface is part of CATIA V5 OPTSpeosInterfaces Object Library.

Property Index

Application (see page 19)

Page 14 of 43 SPEOS CAA V5 Based Automation User Guide

Count (see page 20)

Name (see page 21)

Parent (see page 22)

Method Index

GetItem (see page 17)

Item (see page 18)

Example

Dim productDocument1 As ProductDocument

Dim product1 As Product

Dim speosCAAProduct1 As OPTSpeosCAAProduct

Dim speosNodeRoot1 As OPTSpeosNodeRoot

Set productDocument1 = CATIA.ActiveDocument

Set product1 = productDocument1.Product

Set speosCAAProduct1 = product1.GetItem("OPTVBExtension")

Set speosNodeRoot1 = speosCAAProduct1.SpeosCAA

OPTSpeosNodeSensor Interface

OPTSpeosNode (see page 12) (SpeosNode)

+---OPTSpeosNodeSensor (SpeosNodeSensor)

Description

WIth the OPTSpeosNodeSensor Interface, you can manage the Sensor node. It is part of CATIA V5

OPTSpeosInterfaces Object Library.

Property Index

Application (see page 19)

Count (see page 20)

Name (see page 21)

Parent (see page 22)

Method Index

GetItem (see page 17)

Item (see page 18)

Example

Dim productDocument1 As ProductDocument

Dim product1 As Product

Dim speosCAAProduct1 As OPTSpeosCAAProduct

Dim speosNode1 As OPTSpeosNode

Dim speosNodeSensor1 As OPTSpeosNodeSensor

Set productDocument1 = CATIA.ActiveDocument

Set product1 = productDocument1.Product

Set speosCAAProduct1 = product1.GetItem("OPTVBExtension")

Set speosNode1 = speosCAAProduct1.SpeosCAA

Set speosNodeSensor1 = speosNode1.Item("Sensors")

APIs Page 15 of 43

OPTSpeosNodeSimulation Interface

OPTSpeosNode (see page 12) (SpeosNode)

+---OPTSpeosNodeSimulation (SpeosNodeSimulation)

Description

With the OPTSpeosNodeSimulation Interface, you can manage the simulation node. It is part of CATIA V5

OPTSpeosInterfaces Object Library.

Property Index

Application (see page 19)

Count (see page 20)

Name (see page 21)

Parent (see page 22)

Method Index

GetItem (see page 17)

Item (see page 18)

Example

Dim productDocument1 As ProductDocument

Dim product1 As Product

Dim speosCAAProduct1 As OPTSpeosCAAProduct

Dim speosNode1 As OPTSpeosNode

Dim speosNodeSimulation1 As OPTSpeosNodeSimulation

Set productDocument1 = CATIA.ActiveDocument

Set product1 = productDocument1.Product

Set speosCAAProduct1 = product1.GetItem("OPTVBExtension")

Set speosNode1 = speosCAAProduct1.SpeosCAA

Set speosNodeSimulation1 = speosNode1.Item("Simulations")

OPTSpeosNodeSource Interface

OPTSpeosNode (see page 12) (SpeosNode)

+---OPTSpeosNodeSource (SpeosNodeSource)

Description

With the OPTSpeosNodeSource Interface, you can manage the source node. It is part of CATIA V5

OPTSourceInterfaces Object Library.

Property Index

Application (see page 19)

Count (see page 20)

Name (see page 21)

Parent (see page 22)

Method Index

AddNewLuminaireSource (see page 16)

GetItem (see page 17)

Item (see page 18)

Page 16 of 43 SPEOS CAA V5 Based Automation User Guide

Example

Dim productDocument1 As ProductDocument

Dim product1 As Product

Dim speosCAAProduct1 As OPTSpeosCAAProduct

Dim speosNode1 As OPTSpeosNode

Dim speosNodeSource1 As OPTSpeosNodeSource

Set productDocument1 = CATIA.ActiveDocument

Set product1 = productDocument1.Product

Set speosCAAProduct1 = product1.GetItem("OPTVBExtension")

Set speosNode1 = speosCAAProduct1.SpeosCAA

Set speosNodeSource1 = speosNode1.Item("Sources")

OPTSpeosNodeWindshield Interface

OPTSpeosNode (see page 12) (SpeosNode)

+---OPTSpeosNodeWindshield (SpeosNodeWindshield)

Description

With the OPTSpeosNodeWindshield Interface, you can manage the windshield node. It is part of CATIA V5

OPTSpeosInterfaces Object Library.

Property Index

Application (see page 19)

Count (see page 20)

Name (see page 21)

Parent (see page 22)

Method Index

GetItem (see page 17)

Item (see page 18)

Example

Dim productDocument1 As ProductDocument

Dim product1 As Product

Dim speosCAAProduct1 As OPTSpeosCAAProduct

Dim speosNode1 As OPTSpeosNode

Dim speosNodeWindshield1 As OPTSpeosNodeWindshield

Set productDocument1 = CATIA.ActiveDocument

Set product1 = productDocument1.Product

Set speosCAAProduct1 = product1.GetItem("OPTVBExtension")

Set speosNode1 = speosCAAProduct1.SpeosCAA

Set speosNodeWindshield1 = speosNode1.Item("Windshield Analysis")

Methods

AddNewLuminary

Description

It adds a new luminaire type source to the Speos source node.

APIs Page 17 of 43

Syntax

Method AddNewLuminaireSource( ) As OPTSourceLuminaire

Example

Dim productDocument1 As ProductDocument

Dim product1 As Product

Dim documents1 As Documents

Dim speosNodeRoot1 As OPTSpeosNodeRoot

Dim speosNodeSource1 As OPTSpeosNodeSource

Dim SourceLuminaire1 As OPTSourceLuminaire

Set documents1 = CATIA.Documents

Set productDocument1 = CATIA.ActiveDocument

Set product1 = productDocument1.Product

Set speosNodeRoot1 = product1.GetItem("OPTVBExtension").speosCaa()

Set speosNodeSource1 = speosNodeRoot1.Item("Sources")

Set SourceLuminaire1 = speosNodeSource1.AddNewLuminaireSource()

Export

Description

It exports the object.

Syntax

Function Export(ibstrDirectoryName As String) As Boolean

ibstrDirectoryName: directory name including complete path

Returned value: True if succeeded

Example

Dim speosCAAProduct1 As OPTSpeosCAAProduct

Dim speosNode1 As OPTSpeosNode

Dim speosNodeSimulation1 As OPTspeosNodeSimulation

Dim simuDirect1 As OPTSimuDirect

Set speosCAAProduct1 = product1.GetItem("OPTVBExtension")

Set speosNode1 = speosCAAProduct1.SpeosCAA

Set speosNodeSimulation1 = speosNode1.Item("Simulations")

Set simuDirect1 = speosNodeSimulation1.Item("Direct simulation.1")

simuDirect1.Export("C:\MySimulationFolder\MyExportedSimulation")

GetItem

Description

It returns an object from its name. Role: To retrieve an object when only its name is available.

Syntax

Func GetItem(CATBSTR IDName) As CATBaseDispatch

IDName: the searched object name

Returned value: the searched object

Isolate

Description

It isolates the object.

Syntax

Function Isolate() As Boolean

Page 18 of 43 SPEOS CAA V5 Based Automation User Guide

Returned value: True if succeeded

Example

Dim speosCAAProduct1 As OPTSpeosCAAProduct

Dim speosNode1 As OPTSpeosNode

Dim speosNodeSimulation1 As OPTspeosNodeSimulation

Dim simuDirect1 As OPTSimuDirect

Set speosCAAProduct1 = product1.GetItem("OPTVBExtension")

Set speosNode1 = speosCAAProduct1.SpeosCAA

Set speosNodeSimulation1 = speosNode1.Item("Simulations")

Set simuDirect1 = speosNodeSimulation1.Item("Direct simulation.1")

simuDirect1.Isolate

IsolateAndExport

Description

It isolates and exports the object.

Syntax

Function IsolateAndExport() As Boolean

Returned value: True if succeeded

Example

Dim speosCAAProduct1 As OPTSpeosCAAProduct

Dim speosNode1 As OPTSpeosNode

Dim speosNodeSimulation1 As OPTspeosNodeSimulation

Dim simuDirect1 As OPTSimuDirect

Set speosCAAProduct1 = product1.GetItem("OPTVBExtension")

Set speosNode1 = speosCAAProduct1.SpeosCAA

Set speosNodeSimulation1 = speosNode1.Item("Simulations")

Set simuDirect1 = speosNodeSimulation1.Item("Direct simulation.1")

simuDirect1.IsolateAndExport

Item

Description

it returns an object from its index or its name.

Syntax

Function Item ( iIndex As Variant) As CATBaseDispatch

iIndex: index or name of the object

Returned value: object with the corresponding index or name

NetworkUpdate

Description

It does a network update of the object.

Syntax

Function NetworkUpdate() As Boolean

Returned value: True if succeeded

Example

Dim speosCAAProduct1 As OPTSpeosCAAProduct

Dim speosNode1 As OPTSpeosNode

APIs Page 19 of 43

Dim speosNodeSimulation1 As OPTspeosNodeSimulation

Dim simuDirect1 As OPTSimuDirect

Set speosCAAProduct1 = product1.GetItem("OPTVBExtension")

Set speosNode1 = speosCAAProduct1.SpeosCAA

Set speosNodeSimulation1 = speosNode1.Item("Simulations")

Set simuDirect1 = speosNodeSimulation1.Item("Direct simulation.1")

simuDirect1.NetworkUpdate

SpeosCAA

Description

It returns a SpeosNode Interface object on the root SPEOS CAA V5 Based node.

Syntax

Function SpeosCAA() As SpeosNode

Returned value: SpeosNode Interface object on the root SPEOS CAA V5 Based node

Example

Dim speosCAAProduct1 As SpeosCAAProduct

Dim speosNode1 As SpeosNode

Set speosCAAProduct1 = product1.GetItem("OPTVBExtension")

Set speosNode1 = speosCAAProduct1.SpeosCAA

Update

Description

It updates the object.

Syntax

Function Update() As Boolean

Returned value: 0 if succeeded

Example

Dim speosCAAProduct1 As OPTSpeosCAAProduct

Dim speosNode1 As OPTSpeosNode

Dim speosNodeSimulation1 As OPTspeosNodeSimulation

Dim simuDirect1 As OPTSimuDirect

Set speosCAAProduct1 = product1.GetItem("OPTVBExtension")

Set speosNode1 = speosCAAProduct1.SpeosCAA

Set speosNodeSimulation1 = speosNode1.Item("Simulations")

Set simuDirect1 = speosNodeSimulation1.Item("Direct simulation.1")

simuDirect1.Update

Properties

Application

Description

It returns the application. The application is the root object of the object structure and can be retrieved from any

object in this object structure using the Application property. The root object, also called top-level object, is the

object located at the top of the application's object structure. It is used by clients to retrieve and navigate across all

the application's subordinate objects. If the client runs in-process, it retrieves the object at the top of the object

structure. If the client runs out-process, it should call the GetApplication method to retrieve the object at the top of

the object structure, which is the only object accessible from outside. The Application property is thus the way to

jump from any object up to the root of the object structure, allowing then to navigate downwards. For in-process

Page 20 of 43 SPEOS CAA V5 Based Automation User Guide

scripting, the application is always referred to as CATIA. Note that the Application property of the Application object

returns the Application object itself.

Syntax

Property Application( ) As CATIAApplication (Read Only)

Returned value: the application object

Example

This example retrieves in CurrentApplication the application object, root of the object structure, from a given object

of this structure: a document refered to using the MyDoc variable.

Dim CurrentApplication As Application

Set CurrentApplication = MyDoc.Application

Count

Description

It returns the number of objects in the collection. This is handy to scan all the objects in a collection.

Syntax

Property Count( ) As long (Read Only)

Returned value: number of objects in the collection.

Example

This example retrieves in ObjectNumber the number of objects currently gathered in MyCollection.

ObjectNumber = MyCollection.Count

IntensityFile

Description

It sets the intensity file of a luminary source.

Syntax

Property IntensityFile( ) As String

Example

This example creates and defines a luminary source.

Sub CATMain()

Dim productDocument1 As ProductDocument

Dim product1 As Product

Dim documents1 As Documents

Dim partDocument1 As PartDocument

Dim part1 As Part

Dim Point1 As HybridShapePointCoord

Dim Line1 As HybridShapeLinePtPt

Dim Line2 As HybridShapeLinePtPt

Dim speosNodeRoot1 As OPTSpeosNodeRoot

Dim speosNodeSource1 As OPTSpeosNodeSource

Dim SourceLuminary1 As OPTSourceLuminary

Set documents1 = CATIA.Documents

Set partDocument1 = documents1.Item("source.CATPart")

Set part1 = partDocument1.Part

Set productDocument1 = CATIA.ActiveDocument

Set product1 = productDocument1.Product

Set Point1 = part1.FindObjectByName("Point.1")

APIs Page 21 of 43

Set Line1 = part1.FindObjectByName("Line.1")

Set Line2 = part1.FindObjectByName("Line.2")

Set speosNodeRoot1 = product1.GetItem("OPTVBExtension").speosCaa()

Set speosNodeSource1 = speosNodeRoot1.Item("Sources")

Set SourceLuminary1 = speosNodeSource1.AddNewLuminaireSource()

SourceLuminary1.Name = "MyNewSource"

SourceLuminary1.IntensityFile = "C:\MyIES.ies"

SourceLuminary1.RayNumber = 1000

SourceLuminary1.SpectrumType = optBlackbody

SourceLuminary1.SpectrumBlackBody = 6000

SourceLuminary1.Origin = Point1

SourceLuminary1.XDirection = Line1

SourceLuminary1.YDirection = Line2

SourceLuminary1.Update

End Sub

Name

Description

It returns or sets the name of the object. The name is a character string automatically assigned to any object to

handle it easier. Even if the Name property allows you to reassign an object name, this is not advised. Many objects,

such as the application and the collections, have names that you must not change, and it's safer to use Name as a

read only property. When an object is part of a collection, the object name can often be used in place of the object

rank to retrieve or remove the object, providing the Item and Remove methods of the collection feature an

argument with the Variant type. A name must start with a letter. It can include numbers, but it can't include spaces.

If the object has no name set, the default name returned is the object type. For example, the Name property of a

Viewer3D object with no name set returns Viewer3D.

Syntax

Property Name( ) As CATBSTR

Returned value: object name

Example

This example retrieves in MyObjectName the name of the MyObject object.

MyObjectName = MyObject.Name

Origin

Description

It sets the origin of a luminary source.

Syntax

Property Origin( ) As Reference

Example

This example creates and defines a luminary source.

Sub CATMain()

Dim productDocument1 As ProductDocument

Dim product1 As Product

Dim documents1 As Documents

Dim partDocument1 As PartDocument

Dim part1 As Part

Dim Point1 As HybridShapePointCoord

Page 22 of 43 SPEOS CAA V5 Based Automation User Guide

Dim Line1 As HybridShapeLinePtPt

Dim Line2 As HybridShapeLinePtPt

Dim speosNodeRoot1 As OPTSpeosNodeRoot

Dim speosNodeSource1 As OPTSpeosNodeSource

Dim SourceLuminary1 As OPTSourceLuminary

Set documents1 = CATIA.Documents

Set partDocument1 = documents1.Item("source.CATPart")

Set part1 = partDocument1.Part

Set productDocument1 = CATIA.ActiveDocument

Set product1 = productDocument1.Product

Set Point1 = part1.FindObjectByName("Point.1")

Set Line1 = part1.FindObjectByName("Line.1")

Set Line2 = part1.FindObjectByName("Line.2")

Set speosNodeRoot1 = product1.GetItem("OPTVBExtension").speosCaa()

Set speosNodeSource1 = speosNodeRoot1.Item("Sources")

Set SourceLuminary1 = speosNodeSource1.AddNewLuminaireSource()

SourceLuminary1.Name = "MyNewSource"

SourceLuminary1.IntensityFile = "C:\MyIES.ies"

SourceLuminary1.RayNumber = 1000

SourceLuminary1.SpectrumType = optBlackbody

SourceLuminary1.SpectrumBlackBody = 6000

SourceLuminary1.Origin = Point1

SourceLuminary1.XDirection = Line1

SourceLuminary1.YDirection = Line2

SourceLuminary1.Update

End Sub

Parent

Description

It returns the parent object. The parent object of a given object is the object just above in the object structure,

usually the object that created this object and that aggregates it. In the case of an object part of a collection, the

parent object is not the collection object itself, but the object that aggregates the collection object. The Parent

property is the way to step upwards in the object structure. Note that the Parent property of the Application object

returns the Application object itself.

Syntax

Property Parent( ) As CATBaseDispatch (Read Only)

Returned value: parent object

Example

This example retrieves in ParentObject the parent object of the GivenObject object.

Dim ParentObject As AnyObject

Set ParentObject = GivenObject.Parent

RayNumber

Description

It sets the number of rays of a luminary source.

Syntax

Property RayNumber( ) As Long

APIs Page 23 of 43

Example

This example creates and defines a luminary source.

Sub CATMain()

Dim productDocument1 As ProductDocument

Dim product1 As Product

Dim documents1 As Documents

Dim partDocument1 As PartDocument

Dim part1 As Part

Dim Point1 As HybridShapePointCoord

Dim Line1 As HybridShapeLinePtPt

Dim Line2 As HybridShapeLinePtPt

Dim speosNodeRoot1 As OPTSpeosNodeRoot

Dim speosNodeSource1 As OPTSpeosNodeSource

Dim SourceLuminary1 As OPTSourceLuminary

Set documents1 = CATIA.Documents

Set partDocument1 = documents1.Item("source.CATPart")

Set part1 = partDocument1.Part

Set productDocument1 = CATIA.ActiveDocument

Set product1 = productDocument1.Product

Set Point1 = part1.FindObjectByName("Point.1")

Set Line1 = part1.FindObjectByName("Line.1")

Set Line2 = part1.FindObjectByName("Line.2")

Set speosNodeRoot1 = product1.GetItem("OPTVBExtension").speosCaa()

Set speosNodeSource1 = speosNodeRoot1.Item("Sources")

Set SourceLuminary1 = speosNodeSource1.AddNewLuminaireSource()

SourceLuminary1.Name = "MyNewSource"

SourceLuminary1.IntensityFile = "C:\MyIES.ies"

SourceLuminary1.RayNumber = 1000

SourceLuminary1.SpectrumType = optBlackbody

SourceLuminary1.SpectrumBlackBody = 6000

SourceLuminary1.Origin = Point1

SourceLuminary1.XDirection = Line1

SourceLuminary1.YDirection = Line2

SourceLuminary1.Update

End Sub

SpectrumBlackBody

Description

It sets the temperature of a blackbody type spectrum of a luminary source.

Syntax

Property SpectrumBlackbody( ) As Double

Example

This example creates and defines a luminary source.

Sub CATMain()

Dim productDocument1 As ProductDocument

Dim product1 As Product

Dim documents1 As Documents

Page 24 of 43 SPEOS CAA V5 Based Automation User Guide

Dim partDocument1 As PartDocument

Dim part1 As Part

Dim Point1 As HybridShapePointCoord

Dim Line1 As HybridShapeLinePtPt

Dim Line2 As HybridShapeLinePtPt

Dim speosNodeRoot1 As OPTSpeosNodeRoot

Dim speosNodeSource1 As OPTSpeosNodeSource

Dim SourceLuminary1 As OPTSourceLuminary

Set documents1 = CATIA.Documents

Set partDocument1 = documents1.Item("source.CATPart")

Set part1 = partDocument1.Part

Set productDocument1 = CATIA.ActiveDocument

Set product1 = productDocument1.Product

Set Point1 = part1.FindObjectByName("Point.1")

Set Line1 = part1.FindObjectByName("Line.1")

Set Line2 = part1.FindObjectByName("Line.2")

Set speosNodeRoot1 = product1.GetItem("OPTVBExtension").speosCaa()

Set speosNodeSource1 = speosNodeRoot1.Item("Sources")

Set SourceLuminary1 = speosNodeSource1.AddNewLuminaireSource()

SourceLuminary1.Name = "MyNewSource"

SourceLuminary1.IntensityFile = "C:\MyIES.ies"

SourceLuminary1.RayNumber = 1000

SourceLuminary1.SpectrumType = optBlackbody

SourceLuminary1.SpectrumBlackBody = 6000

SourceLuminary1.Origin = Point1

SourceLuminary1.XDirection = Line1

SourceLuminary1.YDirection = Line2

SourceLuminary1.Update

End Sub

SpectrumFile

Description

It sets the spectrum file of library type spectrum of a luminary source.

Syntax

Property SpectrumFile( ) As String

Example

This example creates and defines a luminary source.

Sub CATMain()

Dim productDocument1 As ProductDocument

Dim product1 As Product

Dim documents1 As Documents

Dim partDocument1 As PartDocument

Dim part1 As Part

Dim Point1 As HybridShapePointCoord

Dim Line1 As HybridShapeLinePtPt

Dim Line2 As HybridShapeLinePtPt

Dim speosNodeRoot1 As OPTSpeosNodeRoot

APIs Page 25 of 43

Dim speosNodeSource1 As OPTSpeosNodeSource

Dim SourceLuminary1 As OPTSourceLuminary

Set documents1 = CATIA.Documents

Set partDocument1 = documents1.Item("source.CATPart")

Set part1 = partDocument1.Part

Set productDocument1 = CATIA.ActiveDocument

Set product1 = productDocument1.Product

Set Point1 = part1.FindObjectByName("Point.1")

Set Line1 = part1.FindObjectByName("Line.1")

Set Line2 = part1.FindObjectByName("Line.2")

Set speosNodeRoot1 = product1.GetItem("OPTVBExtension").speosCaa()

Set speosNodeSource1 = speosNodeRoot1.Item("Sources")

Set SourceLuminary1 = speosNodeSource1.AddNewLuminaireSource()

SourceLuminary1.Name = "MyNewSource"

SourceLuminary1.IntensityFile = "C:\MyIES.ies"

SourceLuminary1.RayNumber = 1000

SourceLuminary1.SpectrumType = optBlackbody

SourceLuminary1.SpectrumBlackBody = 6000

SourceLuminary1.Origin = Point1

SourceLuminary1.XDirection = Line1

SourceLuminary1.YDirection = Line2

SourceLuminary1.Update

End Sub

SpectrumType

Description

It sets the type of spectrum of a luminary source.

Syntax

Property SpectrumType( ) As OPTSourceSpectrumType2

See also: OPTSourceSpectrumType2

Example

This example creates and defines a luminary source.

Sub CATMain()

Dim productDocument1 As ProductDocument

Dim product1 As Product

Dim documents1 As Documents

Dim partDocument1 As PartDocument

Dim part1 As Part

Dim Point1 As HybridShapePointCoord

Dim Line1 As HybridShapeLinePtPt

Dim Line2 As HybridShapeLinePtPt

Dim speosNodeRoot1 As OPTSpeosNodeRoot

Dim speosNodeSource1 As OPTSpeosNodeSource

Dim SourceLuminary1 As OPTSourceLuminary

Set documents1 = CATIA.Documents

Set partDocument1 = documents1.Item("source.CATPart")

Set part1 = partDocument1.Part

Page 26 of 43 SPEOS CAA V5 Based Automation User Guide

Set productDocument1 = CATIA.ActiveDocument

Set product1 = productDocument1.Product

Set Point1 = part1.FindObjectByName("Point.1")

Set Line1 = part1.FindObjectByName("Line.1")

Set Line2 = part1.FindObjectByName("Line.2")

Set speosNodeRoot1 = product1.GetItem("OPTVBExtension").speosCaa()

Set speosNodeSource1 = speosNodeRoot1.Item("Sources")

Set SourceLuminary1 = speosNodeSource1.AddNewLuminaireSource()

SourceLuminary1.Name = "MyNewSource"

SourceLuminary1.IntensityFile = "C:\MyIES.ies"

SourceLuminary1.RayNumber = 1000

SourceLuminary1.SpectrumType = optBlackbody

SourceLuminary1.SpectrumBlackBody = 6000

SourceLuminary1.Origin = Point1

SourceLuminary1.XDirection = Line1

SourceLuminary1.YDirection = Line2

SourceLuminary1.Update

End Sub

XDirection

Description

It sets the X direction of a luminary source.

Syntax

Property XDirection( ) As Reference

Example

This example creates and defines a luminary source.

Sub CATMain()

Dim productDocument1 As ProductDocument

Dim product1 As Product

Dim documents1 As Documents

Dim partDocument1 As PartDocument

Dim part1 As Part

Dim Point1 As HybridShapePointCoord

Dim Line1 As HybridShapeLinePtPt

Dim Line2 As HybridShapeLinePtPt

Dim speosNodeRoot1 As OPTSpeosNodeRoot

Dim speosNodeSource1 As OPTSpeosNodeSource

Dim SourceLuminary1 As OPTSourceLuminary

Set documents1 = CATIA.Documents

Set partDocument1 = documents1.Item("source.CATPart")

Set part1 = partDocument1.Part

Set productDocument1 = CATIA.ActiveDocument

Set product1 = productDocument1.Product

Set Point1 = part1.FindObjectByName("Point.1")

Set Line1 = part1.FindObjectByName("Line.1")

Set Line2 = part1.FindObjectByName("Line.2")

Set speosNodeRoot1 = product1.GetItem("OPTVBExtension").speosCaa()

APIs Page 27 of 43

Set speosNodeSource1 = speosNodeRoot1.Item("Sources")

Set SourceLuminary1 = speosNodeSource1.AddNewLuminaireSource()

SourceLuminary1.Name = "MyNewSource"

SourceLuminary1.IntensityFile = "C:\MyIES.ies"

SourceLuminary1.RayNumber = 1000

SourceLuminary1.SpectrumType = optBlackbody

SourceLuminary1.SpectrumBlackBody = 6000

SourceLuminary1.Origin = Point1

SourceLuminary1.XDirection = Line1

SourceLuminary1.YDirection = Line2

SourceLuminary1.Update

End Sub

XReverse

Description

It sets the X orientation of a luminary source in the reverse direction.

Syntax

Property XReverse( ) As Boolean

Example

This example creates and defines a luminary source.

Sub CATMain()

Dim productDocument1 As ProductDocument

Dim product1 As Product

Dim documents1 As Documents

Dim partDocument1 As PartDocument

Dim part1 As Part

Dim Point1 As HybridShapePointCoord

Dim Line1 As HybridShapeLinePtPt

Dim Line2 As HybridShapeLinePtPt

Dim speosNodeRoot1 As OPTSpeosNodeRoot

Dim speosNodeSource1 As OPTSpeosNodeSource

Dim SourceLuminary1 As OPTSourceLuminary

Set documents1 = CATIA.Documents

Set partDocument1 = documents1.Item("source.CATPart")

Set part1 = partDocument1.Part

Set productDocument1 = CATIA.ActiveDocument

Set product1 = productDocument1.Product

Set Point1 = part1.FindObjectByName("Point.1")

Set Line1 = part1.FindObjectByName("Line.1")

Set Line2 = part1.FindObjectByName("Line.2")

Set speosNodeRoot1 = product1.GetItem("OPTVBExtension").speosCaa()

Set speosNodeSource1 = speosNodeRoot1.Item("Sources")

Set SourceLuminary1 = speosNodeSource1.AddNewLuminaireSource()

SourceLuminary1.Name = "MyNewSource"

SourceLuminary1.IntensityFile = "C:\MyIES.ies"

SourceLuminary1.RayNumber = 1000

SourceLuminary1.SpectrumType = optBlackbody

Page 28 of 43 SPEOS CAA V5 Based Automation User Guide

SourceLuminary1.SpectrumBlackBody = 6000

SourceLuminary1.Origin = Point1

SourceLuminary1.XDirection = Line1

SourceLuminary1.YDirection = Line2

SourceLuminary1.Update

End Sub

YDirection

Description

It sets the Y direction of a luminary source.

Syntax

Property YDirection( ) As Reference

Example

This example creates and defines a luminary source.

Sub CATMain()

Dim productDocument1 As ProductDocument

Dim product1 As Product

Dim documents1 As Documents

Dim partDocument1 As PartDocument

Dim part1 As Part

Dim Point1 As HybridShapePointCoord

Dim Line1 As HybridShapeLinePtPt

Dim Line2 As HybridShapeLinePtPt

Dim speosNodeRoot1 As OPTSpeosNodeRoot

Dim speosNodeSource1 As OPTSpeosNodeSource

Dim SourceLuminary1 As OPTSourceLuminary

Set documents1 = CATIA.Documents

Set partDocument1 = documents1.Item("source.CATPart")

Set part1 = partDocument1.Part

Set productDocument1 = CATIA.ActiveDocument

Set product1 = productDocument1.Product

Set Point1 = part1.FindObjectByName("Point.1")

Set Line1 = part1.FindObjectByName("Line.1")

Set Line2 = part1.FindObjectByName("Line.2")

Set speosNodeRoot1 = product1.GetItem("OPTVBExtension").speosCaa()

Set speosNodeSource1 = speosNodeRoot1.Item("Sources")

Set SourceLuminary1 = speosNodeSource1.AddNewLuminaireSource()

SourceLuminary1.Name = "MyNewSource"

SourceLuminary1.IntensityFile = "C:\MyIES.ies"

SourceLuminary1.RayNumber = 1000

SourceLuminary1.SpectrumType = optBlackbody

SourceLuminary1.SpectrumBlackBody = 6000

SourceLuminary1.Origin = Point1

SourceLuminary1.XDirection = Line1

SourceLuminary1.YDirection = Line2

SourceLuminary1.Update

End Sub

APIs Page 29 of 43

YReverse

Description

It sets the Y orientation of a luminary source in the reverse direction.

Syntax

Property YReverse( ) As Boolean

Example

This example creates and defines a luminary source.

Sub CATMain()

Dim productDocument1 As ProductDocument

Dim product1 As Product

Dim documents1 As Documents

Dim partDocument1 As PartDocument

Dim part1 As Part

Dim Point1 As HybridShapePointCoord

Dim Line1 As HybridShapeLinePtPt

Dim Line2 As HybridShapeLinePtPt

Dim speosNodeRoot1 As OPTSpeosNodeRoot

Dim speosNodeSource1 As OPTSpeosNodeSource

Dim SourceLuminary1 As OPTSourceLuminary

Set documents1 = CATIA.Documents

Set partDocument1 = documents1.Item("source.CATPart")

Set part1 = partDocument1.Part

Set productDocument1 = CATIA.ActiveDocument

Set product1 = productDocument1.Product

Set Point1 = part1.FindObjectByName("Point.1")

Set Line1 = part1.FindObjectByName("Line.1")

Set Line2 = part1.FindObjectByName("Line.2")

Set speosNodeRoot1 = product1.GetItem("OPTVBExtension").speosCaa()

Set speosNodeSource1 = speosNodeRoot1.Item("Sources")

Set SourceLuminary1 = speosNodeSource1.AddNewLuminaireSource()

SourceLuminary1.Name = "MyNewSource"

SourceLuminary1.IntensityFile = "C:\MyIES.ies"

SourceLuminary1.RayNumber = 1000

SourceLuminary1.SpectrumType = optBlackbody

SourceLuminary1.SpectrumBlackBody = 6000

SourceLuminary1.Origin = Point1

SourceLuminary1.XDirection = Line1

SourceLuminary1.YDirection = Line2

SourceLuminary1.Update

End Sub

SPEOS Core

Using SPEOS Core Automation

General Description

With automation in SPEOS Core, you can launch simulations (.sv5 files), get the results and load them.

All examples are given using VB Script language but any other language compatible with Automation can be used.

Page 30 of 43 SPEOS CAA V5 Based Automation User Guide

Using SPEOS Automation APIs

How to Call SPEOS

Before any call to the SPEOS Core methods, you should use the following instruction:

Dim SPEOSCAA As Object

Set SPEOSCAA = CreateObject("SV5.document")

This instruction automatically runs SPEOS Core (creates an instance of the application).

The other uses of SPEOS Core should refer to the variable SPEOSCAA which has been initialized with this instance.

You could notice that there is no reference to the path where SPEOS Core is on the disk.

As it is an automation application, it has been registered in the Windows registry and Windows understands which

application you want to instantiate just with SV5.document.

How to Call a Method

Calling a method is very simple: just write SPEOSCAA followed by a . then by the name of the method and

parameters between "(" and ")", each separated by ",".

For example for running an irradiance simulation just write the following instructions:

Dim MyVar

MyVar = SPEOSCAA.RunSimulation(0, commandline)

The RunSimulation method takes two parameters: the first one is the simulation index (here, 0) and the second is a

command line. The variable MyVar holds the result of the method (success or failure in this case).

All the available methods match something existing in the graphic user interface of SPEOS Core.

Syntax Description

All the available methods are described below using the following syntax: [number] return_type

Method_Name(parameter 1, parameter 2,...) ; with:

[number]: Ordinal number of the method (not to be used in most cases).

return_type: type of the return value (BOOL for Boolean value, short for integer value, double for floating point

value, BSTR for string...).

Method_Name: name of the method.

Parameter n: A keyword for the type of the parameter followed by the parameter name.

Methods

OpenFile (see page 30)

RunSimulation (see page 31)

ShowWindow (see page 32)

Methods

OpenFile

Description

It opens a .sv5 file and returns 0 if succeeded.

Syntax

object.OpenFile(bstrFileName As String, bstrCommandLine As String) As Integer

object: SV5.Document object

bstrFileName: .sv5 filename, including the path

APIs Page 31 of 43

bstrCommandLine: command line

Returned value: 0 if no error.

Example

Dim SpeosCAA As Object

Set SpeosCAA = CreateObject("sv5.document")

Filename = "C:\MyPath\test.sv5"

commandline = ""

retval = SpeosCAA.OpenFile(Filename, commandline)

RunSimulation

Description

It runs a simulation and returns 0 if succeeded.

Syntax

object.RunSimulation(nSimulationIndex As Integer, bstrCommandLine As String) As Integer

object: SV5.Document object

nSimulationIndex: Simulation index, 0 by default

bstrCommandLine: command line

Returned value: 0 if no error.

Example

Dim SpeosCAA As Object

Page 32 of 43 SPEOS CAA V5 Based Automation User Guide

Set SpeosCAA = CreateObject("sv5.document")

Filename = "C:\MyPath\test.sv5"

commandline = ""

retval = SpeosCAA.OpenFile(Filename, commandline)

retval = SpeosCAA.RunSimulation(0, commandline)

ShowWindow

Description

It displays the SPEOS Core window.

Syntax

object.ShowWindow(nShowWindow As Integer) As Integer

object: SV5.Document object

nShowWindow : 1 to show the window, 0 to hide it

Returned value: 0 if no error.

Example

Dim SpeosCAA As Object

Set SpeosCAA = CreateObject("sv5.document")

retval = SpeosCAA.ShowWindow(1)

Tutorial Page 33 of 43

TUTORIAL

You must have the S_SV5_LM2 solution with the O_SV5_COL and O_SV5_OPTIM1 options for the first scenario.

- Or-

You must have the S_SV5_VE1 solution with the O_SV5_OPTIM1 option for the first scenario.

The aim of the following tutorial is to give you a first experience of what the OPTIM1 option of SPEOS CAA V5 Based can achieve.

You are about to learn how to access to an existing SPEOS CAA V5 Based simulation feature and how to update it from a script, as well as controlling the OPTIS Virtual Photometric Lab application using a script. Finally, this tutorial shows how to interact between CATIA V5, SPEOS CAA V5 Based and the OPTIS Virtual Photometric Lab in the same script.

1 hour 30 minutes

You are going to generate a first macro from scratches creating the image of a blackbody at different temperature from 500K to 1200K.

Then with a second script, you are going to optimize the temperature of a blackbody to reduce the difference between its color and a given color.

Lesson 1: Creating the Macro

1. Copy SV5_Tutorials_Automation_R17V11.zip

(http://portal.optis-world.com/documentation/UG/SV5/ZIP/SV5_Tutorials_Automation_R17V11.zip) in a local

directory and extract it.

2. From your recent created folder, open the Automation.CATProduct file.

3. Click Tools, Macro, Macros....

4. Click Macro libraries....

5. From the Library type list, select VBA projects.

6. Click Create new library....

7. Enter your working directory +\SV5_Tutorials_Automation_R17V11\Automation.catvba as name of the project.

8. Click OK.

9. Click Close.

10. Click Close.

Lesson 2: Recording Operations

1. Click Tools, Macro, Start Recording....

2. In the Macro name box, type Automation.

3. Click Start.

4. From CATIA's tree, expand the Parameters node, and then double-click Temperature.

5. Set the value to 500.

6. Click OK.

7. Click Stop Recording .

Lesson 3: Getting the Simulation Object

1. Click Tools, Macro, Macros....

2. Click Edit....

Page 34 of 43 SPEOS CAA V5 Based Automation User Guide

The Visual Basic editor appears. Have a look at the generated code.

Note that you can delete some duplicated lines.

3. Click Insert, Object resolution..., and then from the specification tree select Simu.

The following code is generated.

4. Delete the part of the generated code that already exist and keep this part of the code.

Lesson 4: Editing the Macro

This step shows how to update the macro to:

Create a loop

Modify the temperature parameter

Update the simulation

Open the result

Export the result as an image

Tutorial Page 35 of 43

1. Add the following code before End Sub to create a loop.

2. Add the following code in the loop to modify the Temperature parameter.

3. Add the following code in the loop to update the simulation.

4. Add the following code before the loop to use the OPTIS Virtual Photometric Lab application in the script and to

set result file path name.

5. Add the following code after the simulation update to open the simulation result and export it as an image file.

The code of the macro is here (see page 39).

6. Click File, Save to save the macro.

Lesson 5: Running the Macro

1. Click Run, Run Sub/UserForm F5 to launch the macro.

2. From your recent created folder, open the Images folder.

The images with the colors of each blackbody from 500K to 12500K appear.

Lesson 6: Creating the Second Macro

1. Click Tools, Macro, Macros....

Page 36 of 43 SPEOS CAA V5 Based Automation User Guide

2. Click Create..., and then in the Macro name box, type Automation2.

3. Click OK.

4. Click Edit....

Lesson 7: Writing the Optimization Algorithm

This step shows how to update the macro to:

Create a measurement procedure

Create a minimization procedure

Write an optimization loop

Export results in a file

1. Move the following existing variables before Sub CATMain() in order to define them as global variable and thus

use it in procedure.

2. Declare the following variable useful for optimization algorithm.

3. Add this procedure after global variables declaration.

You can update the source and the simulation if necessary, the measurement of the color and the calculation of

DeltaE the color difference between the measured color and the target color. Temperature parameter is used as

input, it defines the temperature of the blackbody. DeltaE is used as output parameter, it is computed by the

procedure. Simu is used as input and output, it indicates if the result is already know by the optimization

algorithm avoiding by this way to redo a useless simulation.

Tutorial Page 37 of 43

4. Add this procedure.

It is the core of the optimization , thanks to 3 points Inf, Mid, Sup defined by their coordinates (X, Y) the

algorithm reduces the range between Inf and Sup around the minimum. The boolean parameters are used to

avoid useless evaluation of Y when X is changed.

5. Initialize optimization parameters.

XTarget and YTarget is the coordinates of color target. These value is those of a 5555Kdeg blackbody.

TemperatureInf, TemperatureSup indicated the range of search. SimuXXX indicates that no simulation is

updated at this step.

6. Create the optimization loop.

Page 38 of 43 SPEOS CAA V5 Based Automation User Guide

The stop criteria is defined by the size of the current range.

7. Add code to export optimization parameter.

This code placed in the initialization part creates the export file.

This code placed in the loop writes current parameter values.

This code placed after the optimization computes the result and closes the file.

The code of the macro is here (see page 40).

Lesson 8: Running the Optimization

1. Click Run, Run Sub/UserForm F5 to launch the macro.

2. Have a look on the result in the CATIA's tree.

The exact result is 5555Kdeg.

3. Open Microsoft Excel, and then open the Export.txt file.

Roughly 22 optimization steps were done.

4. Select columns A, B and C.

5. Click Insert, Other Charts, and then select the Hight-Low-Close Stock chart.

Tutorial Page 39 of 43

The following chart appears.

This chart shows how the temperature range is reduced around the final value.

6. Select column D.

7. Click Insert, Line, and then select the Line with Markers 2-D Line.

The following chart appears.

This chart shows how the color difference DeltaE approaches 0.

1st Macro - Automation Tutorial

Page 40 of 43 SPEOS CAA V5 Based Automation User Guide

Sub CATMain()

Dim productDocument1 As ProductDocument

Set productDocument1 = CATIA.ActiveDocument

Dim product1 As Product

Set product1 = productDocument1.Product

Dim parameters1 As Parameters

Set parameters1 = product1.Parameters

Dim dimension1 As Dimension

Set dimension1 = parameters1.Item("Temperature")

'---- Begin resolution script for object: Simu

Dim speosNodeRoot1 As OPTSpeosNodeRoot

Set speosNodeRoot1 = product1.GetItem("OPTVBExtension").SpeosCAA()

Dim speosNodeSimulation1 As OPTSpeosNodeSimulation

Set speosNodeSimulation1 = speosNodeRoot1.Item("Simulations")

Dim simuInverse1 As OPTSimuInverse

Set simuInverse1 = speosNodeSimulation1.Item("Simu")

'---- End resolution script

Set OPTISViewer = CreateObject("XMPViewer.Application")

strFileOpen = productDocument1.Path + "\SPEOS output files\Automation.Simu.Sensor.xmp"

For Temperature = 500 To 12500 Step 500

dimension1.Value = Temperature

If (simuInverse1.Update = False) Then

MsgBox ("Error")

Exit For

End If

OPTISViewer.OpenFile strFileOpen

strFileSave = productDocument1.Path + "\Images\" + Format(Temperature, "00000") + ".jpg"

Ret = OPTISViewer.ExportXMPImage(strFileSave, 3) '3 -> JPEG

Next Temperature

End Sub

2nd Macro - Automation Tutorial

Dim dimension1 As Dimension

Dim simuInverse1 As OPTSimuInverse

Dim OPTISViewer

Dim strFileOpen As String

Dim XTarget As Double, YTarget As Double

Dim TemperatureInf As Double, TemperatureMid As Double, TemperatureSup As Double

Tutorial Page 41 of 43

Dim DeltaEInf As Double, DeltaEMid As Double, DeltaESup As Double

Dim SimuInf As Boolean, SimuMid As Boolean, SimuSup As Boolean

Sub CalcDeltaE(Temperature As Double, DeltaE As Double, Simu As Boolean)

If (Simu = False) Then

Dim Measure

dimension1.Value = Temperature

simuInverse1.Update

Simu = True

OPTISViewer.OpenFile strFileOpen

Measure = OPTISViewer.GetColor(0#, 0#, 1)

DeltaE = Sqr((Measure(1) - XTarget) * (Measure(1) - XTarget) + (Measure(2) - YTarget) *

(Measure(2) - YTarget))

End If

End Sub

Sub Minimize(XInf As Double, YInf As Double, UpToDateInf As Boolean, _

XMid As Double, YMid As Double, UpToDateMid As Boolean, _

XSup As Double, YSup As Double, UpToDateSup As Boolean)

If (YMid < YInf) Then ' case \

If (YMid < YSup) Then ' case \/

If (YInf < YSup) Then

XSup = XMid: YSup = YMid

XMid = (XInf + XSup) / 2: UpToDateMid = False

Else

XInf = XMid: YInf = YMid

XMid = (XInf + XSup) / 2: UpToDateMid = False

End If

Else ' case \\

XInf = XMid: YInf = YMid

XMid = XSup: YMid = YSup

XSup = XMid + (XMid - XInf): UpToDateSup = False

End If

Else ' case /

If (YMid < YSup) Then ' case //

XSup = XMid: YSup = YMid

XMid = XInf: YMid = YInf

XInf = XMid - (XSup - XMid): UpToDateInf = False

Else ' case /\

If (YInf < YSup) Then

XSup = XMid: YSup = YMid

XMid = XInf: YMid = YInf

XInf = XMid - (XSup - XMid): UpToDateInf = False

Else

XInf = XMid: YInf = YMid

XMid = XSup: YMid = YSup

XSup = XMid + (XMid - XInf): UpToDateSup = False

End If

End If

End If

End Sub

Sub CATMain()

Dim productDocument1 As ProductDocument

Page 42 of 43 SPEOS CAA V5 Based Automation User Guide

Set productDocument1 = CATIA.ActiveDocument

Dim product1 As Product

Set product1 = productDocument1.Product

Dim parameters1 As Parameters

Set parameters1 = product1.Parameters

Set dimension1 = parameters1.Item("Temperature")

'---- Begin resolution script for object: Simu

Dim speosNodeRoot1 As OPTSpeosNodeRoot

Set speosNodeRoot1 = product1.GetItem("OPTVBExtension").SpeosCAA()

Dim speosNodeSimulation1 As OPTSpeosNodeSimulation

Set speosNodeSimulation1 = speosNodeRoot1.Item("Simulations")

Set simuInverse1 = speosNodeSimulation1.Item("Simu")

'---- End resolution script

Dim fs, f

Set fs = CreateObject("Scripting.FileSystemObject")

Set f = fs.CreateTextFile(productDocument1.Path + "\Export.txt", True)

Set OPTISViewer = CreateObject("XMPViewer.Application")

strFileOpen = productDocument1.Path + "\SPEOS output files\Automation.Simu.Sensor.xmp"

XTarget = 0.331185

YTarget = 0.340409

TemperatureInf = 500

TemperatureSup = 12500

TemperatureMid = (TemperatureInf + TemperatureSup) / 2

SimuInf = False

SimuMid = False

SimuSup = False

Do

Call CalcDeltaE(TemperatureInf, DeltaEInf, SimuInf)

Call CalcDeltaE(TemperatureMid, DeltaEMid, SimuMid)

Call CalcDeltaE(TemperatureSup, DeltaESup, SimuSup)

f.WriteLine TemperatureInf & " " & TemperatureSup & " " & TemperatureMid & " " & DeltaEMid

Call Minimize(TemperatureInf, DeltaEInf, SimuInf, _

TemperatureMid, DeltaEMid, SimuMid, _

TemperatureSup, DeltaESup, SimuSup)

Loop Until (Abs(TemperatureSup - TemperatureInf) < 1)

Call CalcDeltaE(TemperatureMid, DeltaEMid, SimuMid)

f.WriteLine TemperatureInf & " " & TemperatureSup & " " & TemperatureMid & " " & DeltaEMid

f.Close

End Sub

Tutorial Page 43 of 43