an introduction to the scheme macro language in …...in this webinar you will: •gain an...

50
An Introduction to the Scheme Macro Language in TracePro Presented by : Lambda Research Corporation 25 Porter Rd. Littleton, MA 01460 www.lambdares.com

Upload: others

Post on 04-Apr-2020

5 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: An Introduction to the Scheme Macro Language in …...In this webinar you will: •Gain an understanding as to what the Scheme macro language is and how it can be used in TracePro

An Introduction to the Scheme Macro

Language in TracePro

Presented by :

Lambda Research Corporation

25 Porter Rd.

Littleton, MA 01460

www.lambdares.com

Page 2: An Introduction to the Scheme Macro Language in …...In this webinar you will: •Gain an understanding as to what the Scheme macro language is and how it can be used in TracePro

Moderator:

Andy Knight

Technical Sales Manager

Lambda Research Corporation

Presenter:

Dave Jacobsen

Senior Application Engineer

Lambda Research Corporation

Page 3: An Introduction to the Scheme Macro Language in …...In this webinar you will: •Gain an understanding as to what the Scheme macro language is and how it can be used in TracePro

Format

•A 25-30 minute presentation followed by a 10-

15 minute question and answer session

•Please submit your questions anytime using

Question box in the GoToWebinar control panel

Page 4: An Introduction to the Scheme Macro Language in …...In this webinar you will: •Gain an understanding as to what the Scheme macro language is and how it can be used in TracePro

An Introduction to the Scheme Macro

Language in TracePro

Presented by :

Lambda Research Corporation

25 Porter Rd.

Littleton, MA 01460

www.lambdares.com

Page 5: An Introduction to the Scheme Macro Language in …...In this webinar you will: •Gain an understanding as to what the Scheme macro language is and how it can be used in TracePro

In this webinar you will:

•Gain an understanding as to what the Scheme macro language is and how it

can be used in TracePro

•Discover how you can use the Macro Recorder in TracePro to “write” Scheme

macros without having to write anything

•Learn how to use the Scheme macro language to automate and simplify tasks in

TracePro, such as repetitive raytraces and saving data

•Watch a demonstration on how to use a Scheme macro to move the sun around

a solar concentrator in a TracePro model and automatically save the results

Page 6: An Introduction to the Scheme Macro Language in …...In this webinar you will: •Gain an understanding as to what the Scheme macro language is and how it can be used in TracePro

In this webinar you will:

•See an example on how to use the Scheme macro language in conjunction with

the Interactive Optimizer in TracePro to automate such tasks as optimizing the

position of a lighting source for uniform illumination

•Have your questions answered in the Question and Answer session

Page 7: An Introduction to the Scheme Macro Language in …...In this webinar you will: •Gain an understanding as to what the Scheme macro language is and how it can be used in TracePro

Current TracePro Release

•TracePro 7.0.6 (just released)

•Can be downloaded by anyone with a

current Maintenance and Support Agreement

•www.lambdares.com

Page 8: An Introduction to the Scheme Macro Language in …...In this webinar you will: •Gain an understanding as to what the Scheme macro language is and how it can be used in TracePro

An Introduction to the Scheme Macro

Language in TracePro

Page 9: An Introduction to the Scheme Macro Language in …...In this webinar you will: •Gain an understanding as to what the Scheme macro language is and how it can be used in TracePro

What is Scheme?

• Powerful and flexible macro capability based on the

Scheme programming language. Scheme is a dialect of the LISP language, commonly used in

artificial intelligence applications

The Scheme language is easily extensible.

• Extends the capabilities of TracePro. Lambda Research has extended Scheme with over 750

commands specific to TracePro.

• Extends the capabilities of ACIS within TracePro. Spatial Technology (authors of ACIS) and Schemers, Inc. have

extended Scheme to include nearly 1000 ACIS-specific

commands.

Page 10: An Introduction to the Scheme Macro Language in …...In this webinar you will: •Gain an understanding as to what the Scheme macro language is and how it can be used in TracePro

Working with Scheme in TracePro

• Easy implementation through TracePro user

interface.

• The Scheme Editor has context-sensitive

highlighting, parenthesis matching, online help, and a

DDE interface to TracePro.

• The Macro Recorder records Scheme commands

corresponding to keystrokes and mouse clicks and

saves them in a file.

Page 11: An Introduction to the Scheme Macro Language in …...In this webinar you will: •Gain an understanding as to what the Scheme macro language is and how it can be used in TracePro

Macro Reference Guide in TracePro

Searchable Macro Reference Guide with syntax examples.

Accessible in TracePro at Help->Macro Reference.

Page 12: An Introduction to the Scheme Macro Language in …...In this webinar you will: •Gain an understanding as to what the Scheme macro language is and how it can be used in TracePro

Macro Reference Guide in TracePro

Searchable Macro Reference Guide with syntax examples.

Accessible in TracePro at Help->Macro Reference.

Page 13: An Introduction to the Scheme Macro Language in …...In this webinar you will: •Gain an understanding as to what the Scheme macro language is and how it can be used in TracePro

Entering Scheme Commands

in the Command Line

To open Message/Macro Window - Macros->Output

Page 14: An Introduction to the Scheme Macro Language in …...In this webinar you will: •Gain an understanding as to what the Scheme macro language is and how it can be used in TracePro

An Example: Inserting a Block

•Step 1: Type command: (insert:block 10 10 10)

•Note: All commands must be enclosed in parenthesis

•Step 2: Click “Execute”

•This will insert a 10 x 10 x 10mm block at the origin

Step 1

Step 2

Page 15: An Introduction to the Scheme Macro Language in …...In this webinar you will: •Gain an understanding as to what the Scheme macro language is and how it can be used in TracePro

An Example: Inserting a Block - Result

Page 16: An Introduction to the Scheme Macro Language in …...In this webinar you will: •Gain an understanding as to what the Scheme macro language is and how it can be used in TracePro

The Scheme Editor

To open the Scheme Editor – Macros->Open Editor

Page 17: An Introduction to the Scheme Macro Language in …...In this webinar you will: •Gain an understanding as to what the Scheme macro language is and how it can be used in TracePro

The Scheme Editor – An Example

To open the Scheme Editor – Macros->Open Editor

Page 18: An Introduction to the Scheme Macro Language in …...In this webinar you will: •Gain an understanding as to what the Scheme macro language is and how it can be used in TracePro

The Scheme Editor – An Example

Simple Scheme macro to insert a 10 x 10 x 10mm block and rename it

“WebinarBlock”

(define InsertBlock

(lambda ( )

(define Block

(insert:block 10 10 10))

(property:apply-name Block "WebinarBlock")

)

)

Macro name

Page 19: An Introduction to the Scheme Macro Language in …...In this webinar you will: •Gain an understanding as to what the Scheme macro language is and how it can be used in TracePro

The Scheme Editor – An Example

Load the macro into TracePro by going to Macros->Execute and then browsing

to the location of the macro.

Page 20: An Introduction to the Scheme Macro Language in …...In this webinar you will: •Gain an understanding as to what the Scheme macro language is and how it can be used in TracePro

The Scheme Editor – An Example

To run the macro

•Type the macro name, (InsertBlock) , in the Command line. Remember, the

parenthesis must be included.

•Click Execute

Step 1Step 2

Page 21: An Introduction to the Scheme Macro Language in …...In this webinar you will: •Gain an understanding as to what the Scheme macro language is and how it can be used in TracePro

The Scheme Editor - An Example - Result

Page 22: An Introduction to the Scheme Macro Language in …...In this webinar you will: •Gain an understanding as to what the Scheme macro language is and how it can be used in TracePro

The TracePro Macro Recorder

• The Macro Recorder records Scheme commands

corresponding to keystrokes and mouse clicks and

saves them in a file.

• Allows you to write Scheme macros without having to

“write” any code.

Page 23: An Introduction to the Scheme Macro Language in …...In this webinar you will: •Gain an understanding as to what the Scheme macro language is and how it can be used in TracePro

Steps for Using the TracePro Macro Recorder

1. Start the Macro Recorder – Macros->Recorder->Start

2. Define Macro Name

3. Define Filepath and Filename for the macro

4. Perform desired actions in TracePro

5. Stop the Macro Recorder – Macros->Recorder->Stop

6. Open New Model Window

7. Load the Macro – Macros->Execute and browse the location of the macro

8. Type the name of the macro in the Command line of the Message/Macro

window, remember the parenthesis, and then click Execute

Page 24: An Introduction to the Scheme Macro Language in …...In this webinar you will: •Gain an understanding as to what the Scheme macro language is and how it can be used in TracePro

The TracePro Macro Recorder

A Live Demonstration

Page 25: An Introduction to the Scheme Macro Language in …...In this webinar you will: •Gain an understanding as to what the Scheme macro language is and how it can be used in TracePro

Solar Macro Example

Page 26: An Introduction to the Scheme Macro Language in …...In this webinar you will: •Gain an understanding as to what the Scheme macro language is and how it can be used in TracePro

Solar Macro Example

CPC reflector

Sun

Solar Cell

Path of Sun

Page 27: An Introduction to the Scheme Macro Language in …...In this webinar you will: •Gain an understanding as to what the Scheme macro language is and how it can be used in TracePro

Solar Macro Example(define rootPath "C:/TraceProProjects/CPCData/")

(define filename "")

(define angle "")

(define SUN

(lambda (dist theta phi)

(define PI 3.14159)

(define t (* PI (/ theta 180.0)))

(define p (* PI (/ phi 180.0)))

(define z (* dist (cos t)))

(define x (* dist (sin t) (cos p)))

(define y (* dist (sin t) (sin p)))

(define raxis (gvector:cross (gvector 0 0 1) (gvector x y z)))

(define trans1 (transform:rotation (position 0 0 0) raxis theta))

(define trans2 (transform:translation (gvector x y z)))

(define trans (transform:compose trans1 trans2))

(define sunplate

(insert:cylcone 1 10))

(property:apply-name sunplate "Sun")

(property:apply-name (cadr (entity:faces sunplate)) "emitter")

(property:apply-flux-surface-source (cadr (entity:faces sunplate)) 10 10000 2)

(entity:transform sunplate trans)

(raytrace:set-wavelengths 0.548 (raytrace:source-get-by-name "Sun/emitter"))

))

Note: Math functions in Scheme

are Forward Polish Notation

Eg. (+ 2 3) = 5

Page 28: An Introduction to the Scheme Macro Language in …...In this webinar you will: •Gain an understanding as to what the Scheme macro language is and how it can be used in TracePro

Solar Macro Example

(define CPC

(lambda ()

(define concentrator

(insert:3d-compound-reflector 0 0.1 15.588 0.0 4.5 3 30))

(property:apply-name concentrator "CPC")

(property:apply-name (car (entity:faces concentrator)) "Innerside")

(property:apply-surface (car (entity:faces concentrator)) (list "Perfect Mirror" "Default"))

(edit:rotate concentrator 0 0 0 0 1 0 180)

))

(define SolarCell

(lambda ()

(define die

(insert:block 5 5 0.1))

(property:apply-name die "SolarCell")

(property:apply-name (car (entity:faces die)) "detector")

(property:apply-surface (car (entity:faces die)) (list "Perfect Absorber" "Default"))

(edit:move die 0 0 -19.5)

))

Page 29: An Introduction to the Scheme Macro Language in …...In this webinar you will: •Gain an understanding as to what the Scheme macro language is and how it can be used in TracePro

Solar Macro Example

(define demo

(lambda (from to steps)

(define inc (/ (- to from) (- steps 1)))

(file:new)

(CPC)

(SolarCell)

(view:set-up (gvector 0 0 1))

(view:set-eye (position 0 100 0))

(do ((i 0 (+ i 1))) ((= i steps ))

(define theta (+ from (* i inc)))

(print (string-append "Raytracing the sun at theta = " (number->string theta) " degrees"))

(define phi (if (>= theta 0.0) 0 180))

(set! angle (* 1 theta))

(set! theta (abs theta))

(if (> i 0) (entity:delete (entity:get-by-name "Sun")))

(SUN 100 theta phi)

Page 30: An Introduction to the Scheme Macro Language in …...In this webinar you will: •Gain an understanding as to what the Scheme macro language is and how it can be used in TracePro

Solar Macro Example

(view:zoom-all)

(raytrace:source)

(analysis:ray-sorting 0 0.0 0 1 0.0 1.0)

(print (string-append "Flux on target at sun angle of " (number->string angle) " = "))

(display (raytrace:get-incident-flux (entity:get-by-name "detector")))

(newline)

(edit:select (entity:get-by-names "SolarCell" "detector"))

(analysis:refresh)

(analysis:irradiance-normal (gvector 0 0 -1))

(analysis:irradiance-up (gvector 0 1 0))

(analysis:irradiance)

(window:horizontal-tile)

(set! filename (string-append rootPath "_Irradiance at_" (number->string angle) "_degrees.txt"))

(analysis:irradiance-save filename)

(system:sleep 1000)

)

))

(display "Command: (demo fromang toang steps)")

(newline)

(display "Example: (demo -30 30 11)")

(newline)

Page 31: An Introduction to the Scheme Macro Language in …...In this webinar you will: •Gain an understanding as to what the Scheme macro language is and how it can be used in TracePro

Solar Macro Example

A Live Demonstration

Page 32: An Introduction to the Scheme Macro Language in …...In this webinar you will: •Gain an understanding as to what the Scheme macro language is and how it can be used in TracePro

Scheme Macros and the

TracePro Interactive Optimizer

Page 33: An Introduction to the Scheme Macro Language in …...In this webinar you will: •Gain an understanding as to what the Scheme macro language is and how it can be used in TracePro

Scheme Macros and the

TracePro Interactive Optimizer

The Scheme macro language can be used in conjunction with the TracePro

Interactive Optimizer Utility to extend the capabilities of the optimizer.

Examples:

•Performing Boolean operations on parts sent from the optimizer to TracePro

•Optimizing spatial and angular positions of objects using the optimization

targets defined in the Interactive Optimizer

•Applying properties to objects sent from the optimizer to TracePro

Page 34: An Introduction to the Scheme Macro Language in …...In this webinar you will: •Gain an understanding as to what the Scheme macro language is and how it can be used in TracePro

Scheme and the Interactive Optimizer - Example

LED lens optimization from June 2011 Webinar on LED Luminaire Design

Page 35: An Introduction to the Scheme Macro Language in …...In this webinar you will: •Gain an understanding as to what the Scheme macro language is and how it can be used in TracePro

Scheme and the Interactive Optimizer - Example

Goal is to optimize angular position of the lenses for best uniformity of a target

10 meters long located 8 meters from the LEDs and lenses

Page 36: An Introduction to the Scheme Macro Language in …...In this webinar you will: •Gain an understanding as to what the Scheme macro language is and how it can be used in TracePro

Scheme and the Interactive Optimizer - Example

Define variable called “angle”. Initial value is 12-degrees. This is the lower limit

for the variable. The upper limit is 12+75-degrees.

Page 37: An Introduction to the Scheme Macro Language in …...In this webinar you will: •Gain an understanding as to what the Scheme macro language is and how it can be used in TracePro

Scheme and the Interactive Optimizer - Example

Scheme code entered in the After-Scheme column for Object 4

Page 38: An Introduction to the Scheme Macro Language in …...In this webinar you will: •Gain an understanding as to what the Scheme macro language is and how it can be used in TracePro

Scheme and the Interactive Optimizer - Example

Scheme code entered in the After-Scheme column for Object 4

This command runs another

Scheme macro loaded in TracePro

“angle” variable

used to define

rotation of LEDs

and lenses

Page 39: An Introduction to the Scheme Macro Language in …...In this webinar you will: •Gain an understanding as to what the Scheme macro language is and how it can be used in TracePro

Scheme and the Interactive Optimizer - Example

This Scheme macro names one surface of each LED “Emitter” and assigns a

Surface Source Property to it.

Page 40: An Introduction to the Scheme Macro Language in …...In this webinar you will: •Gain an understanding as to what the Scheme macro language is and how it can be used in TracePro

Scheme and the Interactive Optimizer - Example

Scheme code entered in the Pre-processor column. This code will be run first.

Page 41: An Introduction to the Scheme Macro Language in …...In this webinar you will: •Gain an understanding as to what the Scheme macro language is and how it can be used in TracePro

Scheme and the Interactive Optimizer - Example

This code deletes the copies of the LEDs and Lenses that are made in TracePro

Page 42: An Introduction to the Scheme Macro Language in …...In this webinar you will: •Gain an understanding as to what the Scheme macro language is and how it can be used in TracePro

Scheme and the Interactive Optimizer - Example

Initial Irradiance Map – 12-degrees between each LED/Lens

Page 43: An Introduction to the Scheme Macro Language in …...In this webinar you will: •Gain an understanding as to what the Scheme macro language is and how it can be used in TracePro

Scheme and the Interactive Optimizer - Example

Optimization Log – 39 iterations

Best Result

Page 44: An Introduction to the Scheme Macro Language in …...In this webinar you will: •Gain an understanding as to what the Scheme macro language is and how it can be used in TracePro

Scheme and the Interactive Optimizer - Example

Final Irradiance Map – 29.4-degrees between each LED/Lens

Page 45: An Introduction to the Scheme Macro Language in …...In this webinar you will: •Gain an understanding as to what the Scheme macro language is and how it can be used in TracePro

Scheme and the Interactive Optimizer - Example

Final LED and Lens Positions, 29.4-degree separation from center

Page 46: An Introduction to the Scheme Macro Language in …...In this webinar you will: •Gain an understanding as to what the Scheme macro language is and how it can be used in TracePro

Additional Resources

•2-day Scheme programming course at Lambda Research Corp.

headquarters in Littleton, Massachusetts

Next session, August 18-19, 2011

•Schemers Inc. is a company devoted to Scheme education and publishing. (Contact information in TracePro manual.)

The SCHEME Programming Language (R. Kent Dybvig)The Schemer’s Guide (Second Edition)Getting Started With ACIS Using Schemewww.schemers.com

•Authoritative and highly technical reference on the Scheme language can be found on MIT web site.

www.swiss.ai.mit.edu/projects/scheme

Page 47: An Introduction to the Scheme Macro Language in …...In this webinar you will: •Gain an understanding as to what the Scheme macro language is and how it can be used in TracePro

Special Offers

Special Offer #1

$1000 USD off the price of the TracePro Bridge for SolidWorks

Special Offer #2

Save 50% on back maintenance and support.

Contact your local sales representative for full details.

Offers valid May 1st – July 31st, 2011

Page 48: An Introduction to the Scheme Macro Language in …...In this webinar you will: •Gain an understanding as to what the Scheme macro language is and how it can be used in TracePro

Thank You

Page 49: An Introduction to the Scheme Macro Language in …...In this webinar you will: •Gain an understanding as to what the Scheme macro language is and how it can be used in TracePro

Questions and Answers

Page 50: An Introduction to the Scheme Macro Language in …...In this webinar you will: •Gain an understanding as to what the Scheme macro language is and how it can be used in TracePro

For Additional Information

Please Contact:

Lambda Research Corporation

Littleton, MA

978-486-0766

www.lambdares.com