© 2012 autodesk implementing cloud-based productivity solutions with the autocad® objectarx® api...
TRANSCRIPT
© 2012 Autodesk
Implementing Cloud-Based Productivity Solutions with the AutoCAD® ObjectARX® APIRavi KrishnaswamySenior Software Architect
© 2012 Autodesk
Class Summary
Goal: show how to leverage powerful web service based platforms and applications in AutoCAD.
At the end of this class: one should have the basic tools and knowledge to implement Arx applications with the cloud platform web services, such as the Google APIs or any other cloud ‘Platforms as a Service’.
NOTE: This class includes several advanced programming topics
© 2012 Autodesk
Learning Objectives
At the end of this class, you will be able to: Implement an Arx application for Google Docs Learn about Google’s Data store – and differences from traditional data
stores Create an Arx app that uses the Google App Engine Learn about metering and costs of running a PaaS application
You will also learn about the open source libraries and tools used to implement the solutions.
© 2012 Autodesk
Demo!
ACAD.EXE GDOCS.ARX
Google APP ENGINE
Google DOCS
OAuth2RESTArx APIsSpreadsheet APIJNI, Jersey, Jetty
ScopesApplication registrationHigh Replication Data StoreGAE App deployment/frontends
© 2012 Autodesk
Libraries and Tools
© 2012 Autodesk
Java Tools and setup
Java SE http://www.oracle.com/technetwork/java/javase/downloads JSE7 or JSE6
Eclipse http://www.eclipse.org/downloads/
JNI: Java to native (add C:\Java\jre7\bin;C:\Java\jre7\bin\server) to path
© 2012 Autodesk
Google SDKs
Google Client APIs http://
code.google.com/p/google-api-java-client/wiki/APIs#Google_OAuth2_API http://code.google.com/p/gdata-java-client/downloads/list
Google App Engine SDK and Eclipse plugin https://developers.google.com/appengine/downloads https://developers.google.com/eclipse/docs/download
© 2012 Autodesk
Java Libraries
Jetty. Lightweight web server for OAuth2 authentication http://www.eclipse.org/jetty/downloads.php
Jersey. Library to make REST implementation very easy. http://jersey.java.net http://jersey.java.net/nonav/documentation/latest/chapter_deps.html
© 2012 Autodesk
AutoCAD apis
AcDbTable Entity setValue(), value(), setSize()
AcDbXrefGraph AcDbXrefGraphNode, rootNode(), numOut(), out()
© 2012 Autodesk
The Docs API
© 2012 Autodesk
Create account, register id
http://accounts.google.com https://code.google.com/apis/console
Register for services Create credentials and client secret
© 2012 Autodesk
Scopes
https://developers.google.com/academy/apis/drive/drive-apps/auth/scopes
https://developers.google.com/google-apps/spreadsheets/
private static final String[] scopes =
{
"https://www.googleapis.com/auth/userinfo.profile",
"https://www.googleapis.com/auth/userinfo.email",
"https://docs.google.com/feeds",
"https://spreadsheets.google.com/feeds"
};
© 2012 Autodesk
Authentication and Authorization
OAuth2 https://developers.google.com/accounts/docs/OAuth2 Credentials, and Credentials Storage
public static int createOAuth2Authorizer()
public static int setJsonCredentials(int authIndex, String jsonCredentials)
public static int setScopes(int authIndex, String[] scopes)
public static int authorize(int authIndex)
public static String getAccessToken(int authIndex)
Setting access tokenString accessToken = Authorizer.getAccessToken(mAuthorizer);
mSpreadsheetService.setHeader("Authorization", "Bearer " + accessToken);
© 2012 Autodesk
Connecting it together
© 2012 Autodesk
Step by Step
1. We downloaded the JDK, downloaded and installed the libraries and SDKs, installed Eclipse and the App Engine plugin for eclipse.
2. We registered our app id in our google account, generating the client secret json.3. We imported or created two eclipse Java projects:
a) The OAuth2 projectb) The google docs project
4. And exported two runnable jars, selecting the option to copy referenced libraries to a subdirectory.
5. We created a VS2010 JNI project – with the C++ access to the java APIs, making sure the .jars created in step 3 are loaded.
6. We created an ARX app, incorporating the JNI apis, and commands to get/set the spreadsheet data to the AcDbTable entity.
7. We set NEXTFIBERWORLD to 0 in AutoCAD, quit, and noted in the next session, FIBERWORLD was 0. We then ran the app.
© 2012 Autodesk
The Google App Engine
© 2012 Autodesk
The App Engine and Data Store
The App Engine is the server part of our application on the Google platform.
The following link gives a step by step procedure of creating an account https://developers.google.com/web-toolkit/doc/latest/tutorial/appengine
This is integrated in Eclipse File New Project – ‘Google’
© 2012 Autodesk
High Replication Data Store
For details and an overview. https://developers.google.com/appengine/docs/java/datastore/
Key concepts for the store are the notion of Entities – these are the referenceable objects that hold properties Properties – these are named properties and entity has Kind – this qualifies the type of entity being created Key - this is an object that lets you reference an entity.
© 2012 Autodesk
The References problem
Item has ContentId and LocalPath Item has a list of references Determine: Given a content Id
What are nodes with different local paths with the same content What are the references What are the referencers
© 2012 Autodesk
Implementation of references
Xref graph api: host dwg is root, xrefs are child nodes Use timestamps and special request header information for region, city
Qualify content and references query by Date/Time. I.e. between specific dates.
Qualify content and references query by region. I.e. city/state/country.
© 2012 Autodesk
Step by Step
1. Create and setup an Eclipse project for GAE, including installing the GAE sdk and the GAE plugin.
2. Implement, using Jersey, REST apis that log a FileItem and its references in the High Replication Data Store.
3. Deploy that app to GAE from within eclipse.4. Implement a Java client app using Jersey to invoke the REST apis
to put a FileItem, and get references and references to a file item.5. Implement a JNI layer to invoke the Java client apis6. Integrate the JNI calls into the ARX app that implements the
GAELOGREFS, GAEGETREFS and GAEGETREFSTO commands. 7. Run the arx app, making sure FIBERWORLD is 0.
© 2012 Autodesk
Metrics and Billing
© 2012 Autodesk
Google Client API
• Free quota• Wide range of services• Some services have billing• Ability to view usage profile
© 2012 Autodesk
GAE usage and billing
Billing information at:https://developers.google.com/appengine/docs/billing
Complex Billing• Bandwidth• Instance hours (backend and frontend)• Database operations (read, write, small)• Storage
© 2012 Autodesk
Azure
Windows Azure Cloud Services: PaaS App doesn’t remember state, kept in DataStore services Also has web role and worker role instances (frontend/backend) Like GAE – create web role, create package, deploy to cloud. Integrated in Visual Studio
Azure provides IaaS. Specify VHD and VM size (like AMI in Amazon).
Billing: http://www.windowsazure.com/en-us/pricing/calculator/?scenario=full
© 2012 Autodesk
Thank You!
© 2012 Autodesk
Autodesk, AutoCAD* [*if/when mentioned in the pertinent material, followed by an alphabetical list of all other trademarks mentioned in the material] are registered trademarks or trademarks of Autodesk, Inc., and/or its subsidiaries and/or affiliates in the USA and/or other countries. All other brand names, product names, or trademarks belong to their respective holders. Autodesk reserves the right to alter product and services offerings, and specifications and pricing at any time without notice, and is not responsible for typographical or graphical errors that may appear in this document. © 2012 Autodesk, Inc. All rights reserved.