Download presentation
Presentation is loading. Please wait.
Published byHoratio Simpson Modified over 9 years ago
1
WiseImage Open Architecture Lessons “Mission Impossible”
2
Objectives Learn how to use Active Script studio Create a new command that scales your image –Measure the distance –Convert it to paper units –Get prompted for a desired distance –Scale the image
3
Preparation Open Active Script Studio Observe the tools –F–File operations –E–Edit, Search and Undo –R–Run, FormWizard and Reference Let’s start
4
Step 1:Measure Distance
5
Step 1: Discussion Root objects like Document, Command Interaction with user – messages, prompts, forms Choosers – important interactive objects
6
Step 1: Execution Save your script Create a toolbar for your brilliant commands Assign a new button to your command Run it!
7
Step 2: Paper Units Coordinate systems: WCS, UCS, units What are paper units? How to convert data to paper units and back to world units? Useful transformation object - Transformer
8
Step 2: Code changes Add transformation function function ToPaperUnits(val) { with (Document.CoordinateSystem.PaperUnit) { val = W2U.Direct(val); return D2S(val); } Command.Alert("Distance is " + org_dist); Modify your previous code by replacing with Command.Alert("Distance is " + ToPaperUnits(org_dist));
9
Step 2: Execution Change units to inches Run the command again Run your command What is the difference?
10
Step 3: Be Interactive! Script commands can be interactive How to get response from user? –Alert – a simple reply yes or no –Prompt – get some literate response –Forms – the most sophisticated and flexible way
11
Step 3: Code changes Modify your previous code by replacing var res = Command.Prompt( "You have measured the distance " + ToPaperUnits(org_dist) + "\r\nEnter the required distance", "Scale Image"); try { var new_dist = ToWorldUnits(res); if (new_dist == 0.0) Command.Quit(); Command.Alert(new_dist); } catch (e) { Command.Alert(e); } // TODO: Add ToWorldUnits() code Command.Alert("Distance is " + org_dist); with
12
Step 3: Execution Run your code
13
Final point How to process images: –Tools collection –Batch commands
14
Final point: Code changes Modify your previous code by replacing with (Tools("Resample")) { ToolParam("ResampleType") = 1; ToolParam("Scale") = 100.0 * new_dist / org_dist; ToolParam("ResampleFlag") = true; WiseRun(); Document.View.Invalidate(); } with Command.Alert("Distance is " + org_dist);
15
Final point: Fulfillment Load the sample image Run your command Enjoy Do you know any other way how to do the same?
16
Be Interactive – part 2 HTML forms Form Designer is part of Active Script Studio Form Wizard will help you to create good looking forms.
17
Form creation Create a new form Add your controls Save the form
18
FormWizard Create a new simple script function Main() { } Save it Run FormWizard Just follow instructions Run your script
19
The magic of forms Open the sample script Bonus\RasterResize.js Run it
20
Gifts Interactive Image scaling – wrap.js “Back to the Future” – text_rotate.js GIS sample
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.