46

Thinking outside the Box with ObjectDBX™ Speaker: Richard Binning Introduction Thinking About Interfaces Tools to be Used for interconnection VBA/ActiveX

Embed Size (px)

Citation preview

Page 1: Thinking outside the Box with ObjectDBX™ Speaker: Richard Binning Introduction Thinking About Interfaces Tools to be Used for interconnection VBA/ActiveX
Page 2: Thinking outside the Box with ObjectDBX™ Speaker: Richard Binning Introduction Thinking About Interfaces Tools to be Used for interconnection VBA/ActiveX

Thinking outside the Boxwith ObjectDBX™

Speaker: Richard Binning

IntroductionThinking About InterfacesTools to be Used for interconnection• VBA/ActiveX• ObjectDBX• XML

Code ExplorationsWrap-up and Questions

CP13-3

Page 3: Thinking outside the Box with ObjectDBX™ Speaker: Richard Binning Introduction Thinking About Interfaces Tools to be Used for interconnection VBA/ActiveX

I am:

The CAD Coordinator for The Haskell CompanyResponsible for:• Best Practices• Training• Customization• Integration• Implementation

Liaison to:• Senior Management• Information Systems Department• AutoCAD Users

Page 4: Thinking outside the Box with ObjectDBX™ Speaker: Richard Binning Introduction Thinking About Interfaces Tools to be Used for interconnection VBA/ActiveX

Thinking Outside the Box?

What is the Box?• A Boundary?• A Limitation?

Interface: A boundary across which two systems communicate. An interface might be a hardware connector used to link to other devices, or it might be a convention used to allow communication between two software systems. Often there is some intermediate component between the two systems which connects their interfaces together. http://www.hyperdictionary.com/dictionary/interface

Page 5: Thinking outside the Box with ObjectDBX™ Speaker: Richard Binning Introduction Thinking About Interfaces Tools to be Used for interconnection VBA/ActiveX

Who Cares about the Box?

Design ProfessionalsProject Team LeadersExtended Project Team Members•Real Estate Professionals•Fabrication Shops•Detailers•Estimators•Sub Contractors• Installers•???

Page 6: Thinking outside the Box with ObjectDBX™ Speaker: Richard Binning Introduction Thinking About Interfaces Tools to be Used for interconnection VBA/ActiveX

Why do they Care?

16% Loss in Pure Profit due to:• Incomplete Data Exchange•Delays in Data Exchange•Data Duplication Efforts

40% of Total Project Costs Attributed to:•Repair•Maintenance•Warranty Costs

Page 7: Thinking outside the Box with ObjectDBX™ Speaker: Richard Binning Introduction Thinking About Interfaces Tools to be Used for interconnection VBA/ActiveX

This leads us to the following questions:

What Benefits can we achieve through better integration? What problems and hurdles will we encounter?Why should we choose to tackle this problem now? How Can We Integrate our Project through Improved Data Sharing and Communication?

Page 8: Thinking outside the Box with ObjectDBX™ Speaker: Richard Binning Introduction Thinking About Interfaces Tools to be Used for interconnection VBA/ActiveX

Benefits to be achieved?

Retain a Greater Percent of ProfitsEliminate/Reduce Redundancy and DuplicationShorten Life Cycles

Page 9: Thinking outside the Box with ObjectDBX™ Speaker: Richard Binning Introduction Thinking About Interfaces Tools to be Used for interconnection VBA/ActiveX

Problems to be Over-Come?

Greater Number of Software ApplicationsCoordination of Symbology and AbstractionData Re-purposed to friendly format

Page 10: Thinking outside the Box with ObjectDBX™ Speaker: Richard Binning Introduction Thinking About Interfaces Tools to be Used for interconnection VBA/ActiveX

When Can we Accomplish this?

Now•Mature Software• Improved APIs•Standardized Methods•Standardized Access Environments

Page 11: Thinking outside the Box with ObjectDBX™ Speaker: Richard Binning Introduction Thinking About Interfaces Tools to be Used for interconnection VBA/ActiveX

Project Integration Tools?

Visual Basic for ApplicationsActiveX or COM ObjectDBX Type LibrariesXML

Page 12: Thinking outside the Box with ObjectDBX™ Speaker: Richard Binning Introduction Thinking About Interfaces Tools to be Used for interconnection VBA/ActiveX

Project Integration Tools-VBA

VBA has some obvious advantages:•Run time Speed •Ease of Use •Built-In to favored products•Rapid Prototyping

Page 13: Thinking outside the Box with ObjectDBX™ Speaker: Richard Binning Introduction Thinking About Interfaces Tools to be Used for interconnection VBA/ActiveX

Project Integration Tools-ActiveX/COM

The Enabling Technology:•“Object” based interface •Both a Client and Controller

Think of ActiveX as our invisible translator allowing all the other programming tools we will use to communicate with each other.

Page 14: Thinking outside the Box with ObjectDBX™ Speaker: Richard Binning Introduction Thinking About Interfaces Tools to be Used for interconnection VBA/ActiveX

Project Integration Tools-ObjectDBX

The Pipeline:•Direct Access to AutoCAD Database •Speed•Familiarity

Stay Tuned for more…

Page 15: Thinking outside the Box with ObjectDBX™ Speaker: Richard Binning Introduction Thinking About Interfaces Tools to be Used for interconnection VBA/ActiveX

Project Integration Tools-XML

The Liberator:•Text Based •Human Readable•Structured

Two Flavors of Access•DOM – Powerful•SAX – Speedy & Safe

Stay Tuned for more…

Page 16: Thinking outside the Box with ObjectDBX™ Speaker: Richard Binning Introduction Thinking About Interfaces Tools to be Used for interconnection VBA/ActiveX

ObjectDBX –What's New with 2004?

New Properties and Constants to Support:•Digital Signatures•True Colors •New Gradient Patterns •Hatch Object Types S•Shaded Plotting. •One New Viewport Scale (1-1/2" = 1'-0")

Page 17: Thinking outside the Box with ObjectDBX™ Speaker: Richard Binning Introduction Thinking About Interfaces Tools to be Used for interconnection VBA/ActiveX

ObjectDBX –What's New with 2004?

New Classes Provide Support for:•Changes to the Color System•File Dependencies and a built in Dependency Collection

•Security Parameters•Summary Info (Formerly an extended drawing Properties dictionary)

Page 18: Thinking outside the Box with ObjectDBX™ Speaker: Richard Binning Introduction Thinking About Interfaces Tools to be Used for interconnection VBA/ActiveX

ObjectDBX - 2004

Where Can I Use ObjectDBX?•Any PC that has an AutoCAD Application Installed

Must AutoCAD be Running?•Yes, but it can run in the background or invisibly

Do I have to Register it?•Not Anymore…still required for R15

How Can I Use ObjectDBX? •Remember the Rules•Use what you already know

Page 19: Thinking outside the Box with ObjectDBX™ Speaker: Richard Binning Introduction Thinking About Interfaces Tools to be Used for interconnection VBA/ActiveX

ObjectDBX 2004 – The Rules

Think Objects• Declare them explicitly• Release them when you are done with them

Use Targeted Declarations• Always declare and bind them to the AXDBLib class

• AXDBLib.(whatever you are accessing)• Good Habit for other Interfaces Too!

Forget About:• "ThisDrawing“• Selection Sets• Utility Functions• The CommandLine/SendCommand

Page 20: Thinking outside the Box with ObjectDBX™ Speaker: Richard Binning Introduction Thinking About Interfaces Tools to be Used for interconnection VBA/ActiveX

ObjectDBX 2004 – What Can be Accessed?

All Database Resident Objects contained in the Drawing File•All AutoCAD Entities – Anything derived from AcadObject

•Dictionaries•Built in Collections – Blocks and Attributes

•AEC Objects, Styles, Schedule Data, etc.•??? – Lets Find Out

Page 21: Thinking outside the Box with ObjectDBX™ Speaker: Richard Binning Introduction Thinking About Interfaces Tools to be Used for interconnection VBA/ActiveX

Working with DWG files ObjectDBX style

Launch AutoCADCommand Line Approach•“VBANEW”•“VBAIDE”

Not “Alt-F11”Menu Driven Approach•Load CAD Manager•Select Commands

Page 22: Thinking outside the Box with ObjectDBX™ Speaker: Richard Binning Introduction Thinking About Interfaces Tools to be Used for interconnection VBA/ActiveX

ObjectDBX style - cont.

Add Necessary ReferenceNew Class Module: “ObjectDBXDocument.cls”Ensure Explicit DeclarationsSelect “Class” from Objects Selector• Create Skeleton – Initialize and

Terminate• Create Binding Private Variable• Cleanup Function• A Method to pass Document Out• Various Collections

Page 23: Thinking outside the Box with ObjectDBX™ Speaker: Richard Binning Introduction Thinking About Interfaces Tools to be Used for interconnection VBA/ActiveX

ObjectDBX styleCls Code - 1.

Demos…

Page 24: Thinking outside the Box with ObjectDBX™ Speaker: Richard Binning Introduction Thinking About Interfaces Tools to be Used for interconnection VBA/ActiveX

Thinking Outside the Box with XML

What is XML?•Text Based, Human Readable, Easy to Use

Where is XML being used?•Project Related Files with ADT & ABS•LandXML with LDDT•Palettes and Catalogs•???

Page 25: Thinking outside the Box with ObjectDBX™ Speaker: Richard Binning Introduction Thinking About Interfaces Tools to be Used for interconnection VBA/ActiveX

Thinking Outside the Box with XML

XML Concepts and Rules:•Elements, Attributes

Elements Are:•Containers

• Organized by Boundaries• Must Have an Opening or Start Tag• Must Have a Closing Tag delimited by slash• There can be only ONE ROOT

Page 26: Thinking outside the Box with ObjectDBX™ Speaker: Richard Binning Introduction Thinking About Interfaces Tools to be Used for interconnection VBA/ActiveX

Thinking Outside the Box with XML

Elements Are:•Case Sensitive•Cannot contain spaces•Cannot start with the letters "xml" or "XML" or any combination of the two

•Must begin with an underbar "_" or a letter - no numbers!

•Numbers are okay in any position except the first character... Periods and hyphens are okay too!

•See Example

Page 27: Thinking outside the Box with ObjectDBX™ Speaker: Richard Binning Introduction Thinking About Interfaces Tools to be Used for interconnection VBA/ActiveX

Thinking Outside the Box with XML

Elements Example:

Page 28: Thinking outside the Box with ObjectDBX™ Speaker: Richard Binning Introduction Thinking About Interfaces Tools to be Used for interconnection VBA/ActiveX

Thinking Outside the Box with XML

Elements Relate to Each Other:•Siblings•Children•Parents

Page 29: Thinking outside the Box with ObjectDBX™ Speaker: Richard Binning Introduction Thinking About Interfaces Tools to be Used for interconnection VBA/ActiveX

Thinking Outside the Box with XML

XML Concepts and Rules:•Elements, Attributes

Attributes Are:•Name-Value Pairs contained within Element Start Tags

Page 30: Thinking outside the Box with ObjectDBX™ Speaker: Richard Binning Introduction Thinking About Interfaces Tools to be Used for interconnection VBA/ActiveX

Thinking Outside the Box with XML

Attribute Names Are:•Case Sensitive•Cannot start with the letters "xml" or "XML" or any combination of the two

•Must begin with an underbar "_" or a letter - no numbers!

•Numbers are okay in any position except the first character... Periods and hyphens are okay too!

Attribute Values Are:•Surrounded by Single or double quotes

Page 31: Thinking outside the Box with ObjectDBX™ Speaker: Richard Binning Introduction Thinking About Interfaces Tools to be Used for interconnection VBA/ActiveX

Thinking Outside the Box with XML

XML Summary:

Page 32: Thinking outside the Box with ObjectDBX™ Speaker: Richard Binning Introduction Thinking About Interfaces Tools to be Used for interconnection VBA/ActiveX

XML Access Tools

DOM – Document Object Model•Read/Write•Tree Look at XML

SAX – Simple Api for XML•Fairly Safe – Read Only•Event Driven

Page 33: Thinking outside the Box with ObjectDBX™ Speaker: Richard Binning Introduction Thinking About Interfaces Tools to be Used for interconnection VBA/ActiveX

XML Access Tools

Which one to use??? Use the SAX Parser to:•Open Very Large Documents.•Quickly Access Elements contained in your file

• If you only want to read the data.Use the DOM Parser to:•Open Normal Sized Documents.•Modify Data Contained in Your File.• If you need to create new XML files.•When you need random access to the data.

Page 34: Thinking outside the Box with ObjectDBX™ Speaker: Richard Binning Introduction Thinking About Interfaces Tools to be Used for interconnection VBA/ActiveX

Working with XML files DOM style

Install MSMXL ParserLaunch AutoCADCommand Line Approach•“VBANEW”•“VBAIDE”

Not “Alt-F11”Menu Driven Approach•Load CAD Manager•Select Commands

Page 35: Thinking outside the Box with ObjectDBX™ Speaker: Richard Binning Introduction Thinking About Interfaces Tools to be Used for interconnection VBA/ActiveX

XML files DOM style - cont.

Add Necessary ReferenceNew Class Module: “XMLDomDocument.cls”Ensure Explicit DeclarationsSelect “Class” from Objects Selector• Create Skeleton – Initialize and

Terminate• Create Binding Private Variable• Cleanup Function• A Method to pass Document Out• Various Collections

Page 36: Thinking outside the Box with ObjectDBX™ Speaker: Richard Binning Introduction Thinking About Interfaces Tools to be Used for interconnection VBA/ActiveX

DOM style –Cont.

Class Code:

Page 37: Thinking outside the Box with ObjectDBX™ Speaker: Richard Binning Introduction Thinking About Interfaces Tools to be Used for interconnection VBA/ActiveX

DOM style –Cont.

Module Code:

Page 38: Thinking outside the Box with ObjectDBX™ Speaker: Richard Binning Introduction Thinking About Interfaces Tools to be Used for interconnection VBA/ActiveX

DOM style –Cont.

Module Code:

Run Code…

Page 39: Thinking outside the Box with ObjectDBX™ Speaker: Richard Binning Introduction Thinking About Interfaces Tools to be Used for interconnection VBA/ActiveX

Working with XML files SAX style

Install MSMXL ParserLaunch Microsoft ExcelLaunch the VBA Editor Add the Reference to MSXML4.0New Class Module: “XML_SaxDocument.cls”Ensure Explicit DeclarationsAdd the code shown on the following slides to implement the interface described by SAX

Page 40: Thinking outside the Box with ObjectDBX™ Speaker: Richard Binning Introduction Thinking About Interfaces Tools to be Used for interconnection VBA/ActiveX

SAX style –Cont.

Class Code:

Page 41: Thinking outside the Box with ObjectDBX™ Speaker: Richard Binning Introduction Thinking About Interfaces Tools to be Used for interconnection VBA/ActiveX

SAX style –Cont.

Class Code:

Page 42: Thinking outside the Box with ObjectDBX™ Speaker: Richard Binning Introduction Thinking About Interfaces Tools to be Used for interconnection VBA/ActiveX

SAX style –Cont.

Class Code:

Page 43: Thinking outside the Box with ObjectDBX™ Speaker: Richard Binning Introduction Thinking About Interfaces Tools to be Used for interconnection VBA/ActiveX

SAX style –Demo.

Run Code:

Page 44: Thinking outside the Box with ObjectDBX™ Speaker: Richard Binning Introduction Thinking About Interfaces Tools to be Used for interconnection VBA/ActiveX

IN Summary

Talked about Project MembersThinking About Interfaces not BoundariesTools to be Used for interconnection• VBA/ActiveX• ObjectDBX• XML

Code Explorations• Inside and Outside AutoCAD’s Box

Page 45: Thinking outside the Box with ObjectDBX™ Speaker: Richard Binning Introduction Thinking About Interfaces Tools to be Used for interconnection VBA/ActiveX

Updates Will be Posted to AU Website

Page 46: Thinking outside the Box with ObjectDBX™ Speaker: Richard Binning Introduction Thinking About Interfaces Tools to be Used for interconnection VBA/ActiveX

MicroWeb For CP13-3

Questions???

http://www.integr-8.com/AU2003