AutoCAD for Mac

Report
®
ObjectARX
Porting
Applications and User
®
®
Interfaces to AutoCAD for Mac
Asheem Mamoowala
Software Engineer, Autodesk
© 2011 Autodesk
Agenda

Introduction
 Brief History of AutoCAD for Mac
 Compare Windows and Mac APIs
 Cross Platform Development Basics
 Mac User Interface Overview
 CUI
 Auto Loader
© 2011 Autodesk
Introduction
© 2011 Autodesk
Class Summary
This class shows how to completely port your existing Windows®-based ObjectARX
applications to AutoCAD for Mac. Watch live coding demonstrations that will show
you how to quickly compile your existing ObjectARX code for commands and
custom entities on the Apple® Mac with XCode® developer software. Learn to recreate your dialogs and palettes using the Cocoa® framework and how to autoload
your applications and CUI files into AutoCAD for Mac.
© 2011 Autodesk
Learning Objectives
At the end of this class, you will be able to:
 Describe cross-platform coding techniques
 Port your code to Apple Mac
 Integrate your commands with AutoCAD for Mac menus and toolbars
 Develop native Apple user interfaces for AutoCAD for Mac
© 2011 Autodesk
AutoCAD for Mac
© 2011 Autodesk
AutoCAD for Mac History

AutoCAD supported 10+ platforms up to the early 90s


AutoCAD for Mac dropped after 2 releases (R12 and R13)


This supported was dropped due to limited users
Used cross-platform UI components including DCL
Mac support brought back with AutoCAD for Mac released in October 2010, and
September 2011

Mac product line includes AutoCAD, AutoCAD LT, and AutoCAD WS
© 2011 Autodesk
AutoCAD for Mac

AutoCAD for Mac is 64-bit only

Supports OSX 10.6+ and Intel-based Macs

Uses Cocoa framework for UI

Not cross-platform
© 2011 Autodesk
API Comparison
API
Windows
Mac
C++ (ObjectARX)
YES
YES
Win32
YES
PARTIAL
MFC/ActiveX/COM
YES
NO
.NET
YES
NO
LISP
YES
YES
DCL
YES
NO
Qt
YES
YES
Objective-C/Cocoa
NO
YES
(C#/XAML/WinForms/WPF)
© 2011 Autodesk
API Comparison

On Windows, AutoCAD uses Fibers as an alternative to Threading.

Fibers are not available on the Mac

CP322-1 Migrating AutoCAD Apps to the Fiberless Environment (AU 2010)
© 2011 Autodesk
Porting and Development
© 2011 Autodesk
Cross Platform Development Basics

64-bit Migration required


ObjectARX provides polymorphic data types
String Handling

OSX uses Unicode UTF16 whereas Windows uses UTF8
 Conversion required between wchar_t or CString and NSString
 Careful about Unicode format differences

File paths

Forward slash supported on all platforms
 Back slash only on Windows
© 2011 Autodesk
Porting ObjectARX Code

Separate the commands and core logic from Windows-code


Share static libs or source files between Windows/MFC DLL and Mac Bundle
Use Compiler to address warnings and errors

Conflicting types
 Windows dependencies
 Compiler differences



Templates
Unavailable APIs
Use polymorphic type

Adesk::Int64 and Adesk::Boolean
© 2011 Autodesk
DEMO
© 2011 Autodesk
Linking modules for Runtime

OSX has a couple different strategies for dynamically linking modules

Dependent libraries


Runtime-loaded libraries


Loaded together
Dynamically loaded
Requires setting up the Xcode confiugration files correctly

Install Name and path
 Run-path
 Library search paths correctly

Otool –L <modulename>

Tool for inspecting file references inside a compiled module
© 2011 Autodesk
Linking modules for Runtime
© 2011 Autodesk
16
User Interface
© 2011 Autodesk
User Interface Overview

Uses Cocoa framework

Follows Apple OSX User Interface
guidelines

Cocoa has equivalent controls for most
MFC/Windows controls

Ribbon is replaced by ToolSets


Customizable through CUI
Contextual Ribbon is replaced by Visor
© 2011 Autodesk
Objective-C++
 Allows mixing C++ and Objective-C in a single source file
 Use ObjectARX APIs and C++ in the same module
 Some ObjectARX types conflict with Apple’s Carbon/Cocoa APIs
 Be careful with .h includes
 Objective-C++ only works if the .mm file type is used
© 2011 Autodesk
Cocoa
 Similar architecture to WPF
 Uses the Model-View-Controller pattern
 Stricter than MFC
 Stray too much and bugs will be harder to fix
 UI Controls expose delegates as an alternative to sub classing
 Objects are reference counted and need to be managed correctly
© 2011 Autodesk
Modal Dialog

Use Interface Builder to

Layout controls
 Associate with Action methods in Code
 Data binding

Show a dialog using
[NSApp runModalForWindow:]

NSWindowController

In .mm files you can mix Objective-C
with ObjectARX’s C++ APIs
© 2011 Autodesk
DEMO
© 2011 Autodesk
Modeless Windows

Use NSPanel subclass of NSWIndow

AutoCAD Palettes do not use the Cocoa HUDStyle
 Show a palette using
[NSWindowController showWindow:]

Use reactor notifications same as you
would in MFC

Must un-bind elements when closing or
unloading the window
© 2011 Autodesk
CUI and AutoLoader
© 2011 Autodesk
CUI
 Supports a subset of the CUI extensibility that Windows does
 Add Command Macros
 Includes Icons and Tooltips
 Add entire ToolSets, or panels to existing ToolSets
 Add Menus
 The format of the .CUIx file is shared
 CUI Command and dialog have been ported partially and can be used to
create and edit CUI files
© 2011 Autodesk
Partial CUI

ObjectARX applications can provide a partial CUI for their own Commands

Must be installed inside your ARX bundle in
MyArx.bundle/Contents/Resources

Place reference images in the same folder

No Debug tools available for errors when loading Partial CUIs

Create entries in the AutoCAD for Mac CUI dialog
 Extract from the CUI file
 /Users/<username>/Library/Application Support/Autodesk/roaming/AutoCAD
2012/R18.2/enu/Support/
© 2011 Autodesk
Partial CUI Sample
© 2011 Autodesk
AutoLoader

New system for automatically loading
AutoCAD

Requires
rd
3
party ARX applications into

Installation of ARX bundles to /Application/Autodesk/ApplicationPlugins/
 Inclusion of a PackageContents.xml definition file

AutoCAD will auto-load your components

ARX applications
 Partial CUI files
 LISP files
© 2011 Autodesk
AutoLoader PackageContents
© 2011 Autodesk
DEMO
© 2011 Autodesk
Summary

Port Windows ARX application by separating core logic from Windows-specific
code

Implement Mac UI in Cocoa

Use Partial CUI to integrate your application into AutoCAD for Mac

Leverage the autoloader feature to deploy and load your ARX application
© 2011 Autodesk
Links

Fiberless Porting : http://au.autodesk.com/?nd=class&session_id=7128

Apple Human Interface Guidelines :
http://developer.apple.com/library/mac/documentation/UserExperience/Concept
ual/AppleHIGuidelines/OSXHIGuidelines.pdf

Autodesk WikiHelp:
http://wikihelp.autodesk.com/AutoCAD_for_Mac/enu/2011/Help/Developer_Doc
umentation/Migrating_Windows_Applications

ObjectARX for Mac Download:
http://usa.autodesk.com/adsk/servlet/item?siteID=123112&id=785550
© 2011 Autodesk
Thank you!
© 2011 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. © 2011 Autodesk, Inc. All rights reserved.
© 2011 Autodesk

similar documents