(ATS3-DEV01) Introduction to Scripting in Symyx Notebook
-
Upload
accelrys -
Category
Technology
-
view
476 -
download
12
description
Transcript of (ATS3-DEV01) Introduction to Scripting in Symyx Notebook
(ATS3-DEV01) Introduction to Scripting in Symyx Notebook
Mark BenzelPrincipal Software Engineer, R&D
The information on the roadmap and future software development efforts are intended to outline general product direction and should not be relied on in making a purchasing decision.
Scripting in Notebook
In-place Python editors are available in several places• Experiment Editor toolbars• Experiment Editor events• Form events and buttons• Table section events• Property events
Dynamic Toolbars
• Toolbar buttons backed by Python script can be added to the Experiment Editor
• Attached to Document Templates– Every experiment created from that template has the buttons
Demo• Dynamic toolbars
Dynamic Toolbars
• Can be attached at the document level or section level
• Script environment is populated with useful variables from Notebook– Key variables: editor, active_workspace
• Static Notebook classes are available to the script environment, and objects from the Notebook API may be instantiated
Experiment Editor Events
• Experiment Editor Events
– Scripts can be executed when a number of events in the Experiment Editor happen
– As with dynamic toolbars, they are associated with document templates, and can be attached at the document level or the document section level
– Some events can be canceled via script
Demo• Experiment Editor events
Experiment Editor Events• List of Experiment Editor Events:
OnApplicationClosingOnApplicationLoadedOnSavingOnSavedOnInsertingSectionOnLockingSectionOnRemovingSectionOnSectionInsertedOnSectionLockedOnSectionRemovedOnSectionUnlockedOnUnlockingSectionOnMenuItemEnabledStatesUpdatedOnToolBarButtonEnabledStatesUpdatedOnSectionActivatedOnSectionDeactivated
• Key variables: – e
• e.Section (for section-specific events)• e.Cancel, e.CancelReason (for cancelable events)
– editor• Represents the Experiment Editor• Properties and methods are defined in IDocumentEditor
– active_workspace• Provides services for contacting Vault
Forms Events
• Scripts can be attached to form and widget events– Form events:
• OnEdit• OnValueChanged
– Widget events:• OnReview• OnValidate• OnClick (buttons only)
Demo• Forms events
Forms Events
• OnEdit doesn’t fire when the form is in read-only mode– If OnApplicationLoaded is needed, you can put a form in a section template and have
users insert the template instead of the form
• Review Results can’t prevent a document from getting checked in– However the workflow Review activity can prevent a document from transitioning to
the next stage based on review results
Table Section Scripting• Can write scripts for the following events:
– After Cell Value Changed– After Import Row– After Record Weights– Before Import Row– Before Record Weights– Removing Row– Request Column Dictionary– Row Added– Row Changed– Row Removed– Signing Options
• Additional events for Materials sections– After Import Materials– Before Import Materials
• Additional hierarchical table events (Preparations, Formulations)
– Audit script– Component Added– Component Removed– Component Request Column Dictionary– Component Row Changed– Removing Component– Replicate Created
Demo• Table section scripting
Table Section Scripting
• Key script variables
– sender : the TableSection
– e• FieldName• OldValue• TheDataRow• Value
• Cancel, CancelMessage (if cancelable)
– row (for row-based events)
Property Events
• Property Set Definitions are reusable field definitions used by table and form sections.
• Can attach scripts to events at the property level:– Set Initial Value– Calculated Value– Property Changed– Validations
Demo• Property events scripting
Property Events
• Key variables– host_object
• property set host• E.g. Material
– properties– property– value: output parameter for Initial Value and Calculated Value scripts
– e• ValueChangedEventArgs• e.OldValueIsNull• e.NewValueIsNull• e.NewValue• e.OldValue• e.Key: QualifiedPropertyKey• ValidationResult[] ValidationResults
Tips and tricks
• Scripting Performance
– Beware of events that happen when the Experiment Editor loads, or when changing section.• OnApplicationLoaded• OnSectionActivated• OnSectionDeactivated• FormEdit
– Avoid the wire
– Use “Minimal Get’s” whenever possible
– Employ short-circuit coding
• Use the new script performance logging feature provided in Symyx Notebook 6.6 SP1
• Covered the various places scripting can be used in Symyx Notebook– Experiment Editor toolbars– Experiment Editor events– Form events and buttons– Table section events– Property events
• Resources– Symyx Notebook Developer’s Guide
• Section entitled “Scripting in Symyx Notebook”
– IronPython in Action
Summary
The information on the roadmap and future software development efforts are intended to outline general product direction and should not be relied on in making a purchasing decision.
For more information on the Accelrys Tech Summits and other IT & Developer information, please visit:https://community.accelrys.com/groups/it-dev