external database reference - cad.deww3.cad.de/foren/ubb/uploads/marvin41/exter database reference...

Download External Database Reference - CAD.deww3.cad.de/foren/ubb/uploads/Marvin41/Exter Database Reference Model ... only available in AutoCAD Plant 3D 2010, and ... AppData\Roaming\Autodesk\AutoCAD

If you can't read please download the document

Post on 06-Feb-2018

237 views

Category:

Documents

5 download

Embed Size (px)

TRANSCRIPT

  • AUTODESK AEC PLANT SOLUTIONS AUTOCAD P&ID AUTOCAD PLANT 3D

    External Database Reference SampleApplication

    Revision1.0

  • ContentsExternalDatabaseReferenceModelSample...............................................................................................1

    Overview...................................................................................................................................................1

    Illustration.................................................................................................................................................2

    UsingtheExternalReferenceManager(XDbReferenceManagerArx.dll).................................................3

    CreatingaDataSource..........................................................................................................................3

    Step1InvokeExternalReferenceManager.......................................................................................3

    Step2CreateanExternalDataSource..............................................................................................3

    Step3DefinetheDataSource...........................................................................................................4

    Step4CreatePropertyMappings......................................................................................................5

    Step5TurnonandApply...................................................................................................................6

    Done!.....................................................................................................................................................7

    AdditionalNotes.......................................................................................................................................8

    ConfigurationFiles................................................................................................................................8

    ModuleList...........................................................................................................................................8

    BuildingtheSampleApplication...........................................................................................................8

    KnownIssues.............................................................................................................................................9

  • 1

    ExternalDatabaseReferenceModelSample

    OverviewTheAutoCADP&IDprojectdatabasemodelisanextensiblemodelwhichcanbeconfiguredtoreferencedatatablesofanexternaldatabaseusingeitheraVirtualMapping,oranExistingMapping:

    VirtualMapping:thecolumnintheexternaldatabasetabledoesnotbecomeapropertyintheprojecthierarchy; itwillappearasanewproperty,andcanhaveanamethat'sdifferent fromtheexternaldatabasecolumnname.

    ExistingMapping:thecolumnintheexternaldatabaseismappedtoanexistingpropertyintheprojecttable.

    The project database interactswith external databases through theOLEDB .NET provider, and canconnect tomostdatabasesystemswithan installationof thecorrespondingOLEDBproviderson theclientsystem.

    Additionalexternaltablecolumnscanbereferencedfromtheprojecttablebyjoiningtheprojecttablewith anexternaldatabase table; rows in theproject and externaldatabase tables areboundby thespecificationofaforeignkey(column)fortheprojecttable,andaprimarykey(column)fortheexternaldatabasetable.

    This document describes a sample database extension where columns from an external database(autodesk.accdb)areaddedtotheprojectdatabase.

  • 2

    IllustrationExternaldatabase :autodesk.accdbExternaltable :Table1

    Keycolumn :Field1Extensioncolumns :Field2, Field3, Field4

    Figure1DataManager

    Figure2ExternalDataSourceinAccess2007

  • 3

    UsingtheExternalReferenceManager(XDbReferenceManagerArx.dll)Touse the tool, startAutoCADP&ID2010, and 'NETLOAD' theXDbReferenceManagerArx.dll.NETObjectARXapplication.IntheProjectManager,opentheprojectthatyouwanttomanageexternalreferencesfor.

    CreatingaDataSource

    Step1InvokeExternalReferenceManagerInvoketheExternalReferenceManagerdialogwiththe'PLANTXDBMANAGER'command.

    Step2CreateanExternalDataSourceCreateadatasourcenamed"autodesk_datasource"byclickingthe"Add"buttoninthe"DataSources"tab;multipledatasourcescanbedefined.

    Figure3DefiningaDataSource

  • 4

    Step3DefinetheDataSourceClickthe"Define..."buttontospecifytheconnectionpropertiesinthe"DataLinkProperties"dialog.Inthis example, we're using the "Microsoft Office 12.0 Access Database Engine" to connect to anMicrosoftAccessdatabaseatI:\catalogs\autodesk.accdb.

    Figure4DefiningaDatabaseConnection

  • 5

    Step4CreatePropertyMappingsOncethedatasource iscreated,switchtothe"PropertyMapping"tabtodefineapropertymapping.Toggle the "Hide Unused" button to show all available classes in the project hierarchy. Select the"EngineeringItems"table(i.e.thetablethatyouwanttoextend),andclickthe"MapVirtualProperty"button to create a new property mapping set; multiple property mapping sets can be defined.Alternatively, you can also click the "Map Existing Property" button to createmappings to existingcolumnsintheprojecttable.

    Select"autodesk_datasource"astheReferenceddatasource,and"Table1"astheReferencedtable[seeBLUEboxinFigure5below].

    Oncethereferencedtableisselected,mapthe"ModelNumber"columnintheprojectdatabasetotheField1columnintheexternaldatabaseasshown[seeREDboxinFigure5].

    Thelastthingtodointhisstep,istospecifythecolumnsfromtheexternaldatabasetableandhowtheywilldisplaywhenextendingtheEngineeringItemstable[seeORANGEboxinFigure5].

    Figure5DefiningaVirtualPropertyMapping

  • 6

    If you're creatingmappings toexistingproject table columns, specify the columns from theexternaldatabasetableandthecolumnsintheprojecttablethattheyshouldmapto[seeORANGEboxinFigure6below].

    Figure6DefininganExistingPropertyMapping

    Step5TurnonandApplyChecktheUsecheckboxintheGeneralgroupbox[seeREDovalinFigure5above],thisturnsonthereferencesothat it isused.Tofinishandexitthedialogbox,clicktheApplybuttonfollowedbytheClosebutton.

  • 7

    Done!Invoke theDataManager, and scroll to the right.Notice that three new columns now exist for theEngineeringItems table. If you type in Info1 for the ModelNumber column of a record,FieldName2throughFieldName4areautomaticallyupdated.

    If you've created mappings to existing project columns, after you've typed in "Info1" for the"ModelNumber"columnofarecord,selectandrightclickthe"EngineeringItems"nodeintheclasstreeandselectthe"ReloadMappedProperties..."menu item1 topopulate themappedpropertyvalues intheselectedtable.

    Figure7ReloadingExistingPropertyMappings

    1The"ReloadMappedProperties..."contextmenuitemisonlyavailableinAutoCADPlant3D2010,andwillnotbeshowninAutoCADP&ID2010.

  • 8

    AdditionalNotes

    ConfigurationFilesThe data source connection parameters and property mapping definitions are stored in ".edf"configurationfilesintheprojectfolder;aconfigurationfileiscreatedforandnamedaftereachprojectpart(i.e.PnId.edf,Piping.edf,Iso.edf,etc.).

    Theusestatussettingsforvirtualpropertymappingsareuserandprojectspecific,andaresavedasXMLconfiguration files in the user profile application data folder for each project (e.g.C:\Users\\AppData\Roaming\Autodesk\AutoCAD Plant 3D 2010\R18.0\enu\Support\PnPProjects\).

    ModuleList XDbReferenceUI.dll

    o CommonUserInterface(UI)controlsassembly. XDbReferenceManagerArx.dll

    o Contains the AutoCAD ObjectARX .NET application and the 'PLANTXDBMANAGER'commandimplementation;usescontrolsfromtheXDbReferenceUIassembly.

    XDbReferenceManager.exeo StandaloneExternalDatabaseReferenceManagerapplication;usescontrols fromthe

    XDbReferenceUIassembly.

    BuildingtheSampleApplicationThis sample application is built on Visual Studio 2008 and with the PnPSDK. The PnPSDK requiresAutoCAD2010ObjectARX.YoucanfindtheAutoCAD2010ObjectARXatwww.autodesk.com/objectarx.

    MicrosoftVisual Studio requirements and setup are described inObjectARX Introductory Concepts >OverviewofObjectARX>GettingStartedfromtheObjectARXDevelopersGuide(arxdev.chm).

    PnPSDK files are installed with AutoCAD P&ID or AutoCAD Plant 3D into the \\PnPSDK folder. Youmay overlay the PnPSDK ontoObjectARX by copying thecontentsof thePnPSDK folder to theObjectARX folder,which isC:\ObjectARX 2010bydefault.TheSDKfilesshareexistingObjectARXfolders,butnofilesareoverwritten.

    Tobuildthesampleapplication,copythe XDbReferencefoldertotheObjectARXfolder,andbuildtheXDbReference.slnsolutioninVisualStudio.

  • 9

    KnownIssues The "Reload Mapped Properties..." Data Manager context menu item is not available in

    AutoCADP&ID2010,andanypreviousreleaseofAutoCADP&ID.An additional command or reactor implementation is required to trigger a refresh of themapped project column values when the foreign key value of a row is changed. A sampleimplementationcanbefoundinAppendixA.

    The XDbReferenceManager.exe standalone application has dependencies on two additionalassemblies:

    o PnPSQLiteEngine.dllo System.Data.SQLite.dll

    TheseassembliescanbeobtainedfromtheAutoCADP&IDorAutoCADPlant3Dprogramfolder,andneedtobemanuallycopiedtotheXDbReferenceManager.exeapplicationfolder,oraddedtothesystempath.

  • A1

    AppendixA EquivalentC#CodeThe code below is equivalent to the interactive steps shown in the "Using the External ReferenceManager (XDbReferenceManagerArx.dll)" section. It illustrates how a developer can use the APIs toextendtheprojectdatabasewithvirtualpropertiesatruntime.

    /* This is a sample of adding additional columns to a table that are * defined in an external database. */ [CommandMethod("xdb_sample", CommandF

Recommended

View more >