//
//  (C) Copyright 1994-2008 by Autodesk, Inc.  All rights reserved.
//
// Permission to use, copy, modify, and distribute this software in
// object code form for any purpose and without fee is hereby granted, 
// provided that the above copyright notice appears in all copies and 
// that both that copyright notice and the limited warranty and
// restricted rights notice below appear in all supporting 
// documentation.
//
// AUTODESK PROVIDES THIS PROGRAM "AS IS" AND WITH ALL FAULTS. 
// AUTODESK SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTY OF
// MERCHANTABILITY OR FITNESS FOR A PARTICULAR USE.  AUTODESK, INC. 
// DOES NOT WARRANT THAT THE OPERATION OF THE PROGRAM WILL BE
// UNINTERRUPTED OR ERROR FREE.
//
// Use, duplication, or disclosure by the U.S. Government is subject to 
// restrictions set forth in FAR 52.227-19 (Commercial Computer
// Software - Restricted Rights) and DFAR 252.227-7013(c)(1)(ii)
// (Rights in Technical Data and Computer Software), as applicable.
//

// DESCRIPTION: This file contains class and functions definitions for
//              MCADAPI component and component definition keys.
//
#ifndef AMICOMP_H
#define AMICOMP_H

// Includes
//
#include "gemat3d.h"
#include "mibase.h"
#include "migeom.h"
#include "miStatus.h"
#include "mi2dSHide.h"
#include "AdAChar.h"

// Forward class declarations.
//
class AmiBodyKey;
class AmiSolidKey;
class AmiCompConstrKey;
class AmiHideSituationKey;
class AmiComplexHideSituationKey;

// Open Ami namespace to include feature API enumerations.
//
namespace Ami
{
    // View type enumeration.

    enum View2DType
    {
      k2DSUndefinedView = 0,  // default, used for views created by user
      k2DSFrontView,
      k2DSTopView,
      k2DSBackView,
      k2DSSideView,
      k2DSSideLeftView,
      k2DSSideRightView,
      k2DSBottomView,
      k2DSPartialView,
      k2DSSectionView,
      k2DSDetailView,
      k2DSHalfSectionView,
      k2DSHalfSectionVisibleView,
      k2DSAuxiliaryView,
    };

    // View Definition lock type enumeration.
    enum ViewDefLockType
    {
      kNoLock       = 0x0000,
      kXrefLock     = 0x0001,
      kStdPartLock  = 0x0002,
      kUserLock     = 0x0004,
    };

    // Selection order option enumeration.
    enum SelectionOrderOption
    {
      kTopDown = 0,
      kBottomUp = 1
    };
};

// Component key class.
//
class AMIAPI AmiCompKey : public AmiObjectKey
{
  public:

    MCADAPI_DECLARE_MEMBERS(AmiCompKey);
};

// Component definition key class.
//
class AMIAPI AmiCompDefKey : public AmiObjectKey
{
  public:

    MCADAPI_DECLARE_MEMBERS(AmiCompDefKey);
};

// 2D structure classes.
//

// Folder key class.
class AMIAPI AmiFolderKey : public AmiObjectKey
{
public:

  MCADAPI_DECLARE_MEMBERS(AmiFolderKey);
};

// Folder definition key class.
class AMIAPI AmiFolderDefKey : public AmiObjectKey
{
public:

  MCADAPI_DECLARE_MEMBERS(AmiFolderDefKey);
};

// Component view key class.
class AMIAPI AmiCompViewKey : public AmiFolderKey
{
  public:

    MCADAPI_DECLARE_MEMBERS(AmiCompViewKey);
};

// Component view definition key class.
class AMIAPI AmiCompViewDefKey : public AmiFolderDefKey
{
  public:

    MCADAPI_DECLARE_MEMBERS(AmiCompViewDefKey);
};

// Annotation view definition key class.
class AMIAPI AmiAnnotationViewDefKey : public AmiFolderDefKey
{
public:

  MCADAPI_DECLARE_MEMBERS(AmiAnnotationViewDefKey);
};

class AMIAPI AmiFormulaEvaluator : public AmiObjectBase
{
public:
  MCADAPI_DECLARE_MEMBERS(AmiFormulaEvaluator);
};


// Description: Removes entities from 2d structure view (folder or component view).
// Input      : entitiesToRemove - entities to remove.
AMIAPI AmiStatus amiRemoveViewEntities(AcDbObjectIdArray& entitiesToRemove);

AMIAPI AmiStatus amiAddEntitiesToFolder(AcDbObjectIdArray& entitiesToAdd, AmiFolderKey *& pFolderKey);

// Description: Adds a 2d component to a component definition by providing
//              the definition for the component to be added. The component key
//              for the newly created component is created and returned.
//              The caller is responsible for releasing the component key.
// Input      : pDefKey	   - Pointer to the component definition key for
//                           the component being inserted.
//              pTargetKey - Pointer to the component definition key
//                           which will consume the new component.
// Output     : pCompKey   - The pointer to the new component key.
AMIAPI AmiStatus amiInstance2dComp( AmiCompKey*& pCompKey, AmiCompDefKey* pDefKey, AmiCompDefKey* pTargetKey );

// Description: Erases component view specified by key.
// Input      : pCompViewKey - The pointer to the component view key to be
//                             erased.
AMIAPI AmiStatus amiRemoveView( AmiCompViewKey *& pCompViewKey );

// Description: Adds entities to component view.
// Input      : entitiesToAdd - entities to add.
//              pCompViewKey - component view key
AMIAPI AmiStatus amiAddEntitiesToView( AcDbObjectIdArray& entitiesToAdd, AmiCompViewKey *& pCompViewKey );

// Description: Erases folder specified by key.
// Input      : pFolderKey - The pointer to the folder key to be erased.
AMIAPI AmiStatus amiRemoveFolder(AmiFolderKey *& pFolderKey);

AMIAPI AmiStatus amiGetMasterViewDef( AmiFolderDefKey*& pMVD, AcDbDatabase* pDb = NULL, const ACHAR* appName = Designer_Assemblies );

// Description: Returns an array of entities that represent geometry of
//              migrating component view. Allowed are only free model space
//              entities, excluding entities passed in excludeEnts array
// Input      : pPrompt - command prompt which will be displayed during selection
//              of drawing entities
//            : excludeEnts - an array of object ids of entities that have been
//              already selected as view geometry and cannot be selected again
//              for another view
// Output     : selectedEnts - an array of object ids of selected entities
AMIAPI AmiStatus amiSelectViewGeometry( const ACHAR* pPrompt,
									    const AcDbObjectIdArray& excludeEnts,
										AcDbObjectIdArray& selectedEnts );

/* --------- The following 2d structure functions are OBSOLETE --------- */
AMIAPI AmiStatus amiCreateCompViewDef( AmiCompViewDefKey*& pNewViewDefKey, const ACHAR* viewDefName,
									   AmiCompViewKey*& pViewInstKey,
									   AmiCompViewKey*& pTargetViewKey,
									   AmiCompKey*& pCompInstKey,
									   AcDbObjectIdArray& entitiesToAdd,
									   AmiArray<AmiCompViewKey> aCompViewKeys,
									   AcGeMatrix3d& position );

AMIAPI AmiStatus amiInstanceView( AmiCompViewDefKey * pDefToInstance, AmiCompViewDefKey*& pTargetViewDefKey,
								  AmiCompKey * pOwningCompInst, AcGeMatrix3d& position,
								  AmiCompViewKey *& pViewInstKey );

AMIAPI AmiStatus amiCreateFolderDef( AmiFolderDefKey*& pNewFolderDefKey, const ACHAR* folderDefName,
									 AmiFolderKey*& pFolderInstKey, AmiObjectKey*& pTargetKey,
									 AcDbObjectIdArray& entitiesToAdd, AcGeMatrix3d& position );

AMIAPI AmiStatus amiInstanceFolder( AmiFolderDefKey * pDefToInstance, AmiObjectKey*& pTargetDefKey,
								    AcGeMatrix3d& position, AmiFolderKey *& pFolderInstKey );

AMIAPI AmiStatus amiRemoveFolderEntities( AcDbObjectIdArray& entitiesToRemove );

/* --------- The preceding 2d structure functions are OBSOLETE --------- */

// Description: Creates an empty 2d component definition. The caller is
//              responsible for releasing the key.
// Input      : compDefName - Name of the new component definition.
//              appName	    - Name of application to perform the function.
// Output     : pCompDefKey - The pointer to the new component
//              definition key.
AMIAPI AmiStatus amiCreate2dCompDef(AmiCompDefKey*& pCompDefKey, const ACHAR* compDefName,
                             const ACHAR* appName = Designer_Assemblies );

AMIAPI AmiStatus ami2DSGetEditTarget( AmiObjectKey*& pKey, AcDbDatabase* pDb = NULL);

AMIAPI AmiStatus ami2DSSetEditTarget( AmiObjectKey* pKey, AcDbDatabase* pDb = NULL);

AMIAPI AmiStatus ami2DSGetFolderDefs( long& count,
                                        AmiFolderDefKey**& pFolderDefs,
                                        bool bIncludeExernals = false,
                                        AcDbDatabase* pDb = NULL);

AMIAPI AmiStatus ami2DSGetComponentDefs( long& count,
                                         AmiCompDefKey**& pCompDefs,
                                         bool bIncludeExernals = false,
                                         AcDbDatabase* pDb = NULL);

AMIAPI AmiStatus ami2DSGetStructureFromEntity( const AcDbObjectId&,
												AmiObjectKey*& pKey);

AMIAPI AmiStatus ami2DSCopyFolderFromDatabase( const AmiFolderDefKey* pSourceKey,
												AcDbDatabase* pDb,
												AmiFolderDefKey*& pNewDefKey);

AMIAPI AmiStatus ami2DSCopyComponentFromDatabase( const AmiCompDefKey* pSourceKey,
													AcDbDatabase* pDb,
													AmiCompDefKey*& pNewDefKey);

AMIAPI AmiStatus ami2DSExternalStructureDatabases( AcArray<AcDbDatabase*>& xrefDbs, AcDbDatabase* pDb = NULL);

AMIAPI AmiStatus ami2DSGetSelection( AcArray<AmiFolderKey*>& keys,
                    AcDbObjectIdArray& entities);

AMIAPI AmiStatus ami2DSHighlight( const AcArray<AmiFolderKey*>& arKeys,
                    bool bHighlight);

AMIAPI AmiStatus ami2DSUpdate( bool bForceAll );

AMIAPI AmiStatus ami2DSRestructure( const AcArray<AmiFolderKey*>& arKeys,
                    const AmiFolderKey* pKey);

AMIAPI AmiStatus ami2DSIsStructureBlock( const AcDbObjectId& blkId, bool& bIsStructureBlock );

AMIAPI AmiStatus ami2DSCreateCompViewDef( AmiCompViewDefKey*& pNewViewDefKey,
											AmiCompViewKey*& pViewInstKey,
											AmiCompKey* pCompInstKey,
											const AcDbObjectIdArray& entitiesToAdd,
											const AmiArray<AmiFolderKey>& aViewKeys,
											const AcGeMatrix3d& position,
											AmiFolderKey* pTargetViewKey = NULL,
											const ACHAR* viewDefName = NULL);

AMIAPI AmiStatus ami2DSCreateFolderDef(AmiFolderDefKey*& pNewFolderDefKey,
                                        AmiFolderKey*& pFolderInstKey,
                                        const AcDbObjectIdArray& entitiesToAdd,
                                        const AmiArray<AmiFolderKey>& aViewKeys,
                                        const AcGeMatrix3d& position,
                                        AmiFolderKey* pTargetKey = NULL,
                                        const ACHAR* folderDefName = NULL);

AMIAPI AmiStatus ami2DSInstanceCompView(AmiCompViewDefKey * pDefToInstance,
										AmiFolderKey* pTargetViewKey,
										AmiCompKey*   pOwningCompInst,
										const AcGeMatrix3d& position,
										AmiCompViewKey *& pViewInstKey);

AMIAPI AmiStatus ami2DSInstanceCompView2(AmiCompViewDefKey * pDefToInstance,
                   AmiFolderDefKey* pTargetViewDefKey,
                   AmiCompKey*   pOwningCompInst,
                   const AcGeMatrix3d& position,
                   AmiCompViewKey *& pViewInstKey);

AMIAPI AmiStatus ami2DSInstanceFolder(AmiFolderDefKey * pDefToInstance, AmiFolderKey* pTargetViewKey,
                    const AcGeMatrix3d& position, AmiFolderKey *& pFolderInstKey);

AMIAPI AmiStatus ami2DSInstanceFolder2(AmiFolderDefKey * pDefToInstance, AmiFolderDefKey* pTargetDefKey,
                    const AcGeMatrix3d& position, AmiFolderKey *& pFolderInstKey);

AMIAPI AmiStatus ami2DSIsStructureEnabled( bool& bIsStructureEnabled );

AMIAPI AmiStatus ami2DSIsEntityAllowed( const AcDbObjectId& oEntId, bool& bIsAllowed  );

AMIAPI AmiStatus ami2DSIsFreeEntity( const AcDbObjectId& oEntId, bool& bIsFree  );

AMIAPI AmiStatus ami2DSIsInActiveTarget( const AcDbObjectId& oEntId, bool& bIsInActiveTarget  );

AMIAPI AmiStatus ami2DSHasFolderDefinition( const ACHAR* pName, AmiFolderDefKey*& pFolderDefKey, bool& bHasFolderDef  );

AMIAPI AmiStatus ami2DSHasComponentDefinition( const ACHAR* pName, AmiCompDefKey*& pComDefKey, bool& bHasCompDef  );

AMIAPI AmiStatus ami2DSGetNextComponentDefinitionName( const ACHAR* pBaseName, ACHAR*& pNextName, AcDbDatabase* pDatabase = NULL );

AMIAPI AmiStatus ami2DSGetNextFolderDefinitionName( const ACHAR* pBaseName, ACHAR*& pNextName, AcDbDatabase* pDatabase = NULL );

AMIAPI AmiStatus ami2DSGetNextAnnotationViewDefinitionName( AmiCompDefKey *pCompDefKey, ACHAR*& pNextName, AcDbDatabase* pDatabase = NULL );

AMIAPI AmiStatus ami2DSUpdateEntities(AcDbDatabase *pDb = NULL);

AMIAPI AmiStatus ami2DSIsStructureMode( bool& bMode, AcDbDatabase* pDatabase = NULL );

AMIAPI AmiStatus ami2DSSetStructureMode( bool bMode, AcDbDatabase* pDatabase = NULL );

AMIAPI AmiStatus ami2DSIsReferenceLockMode( bool& bMode, AcDbDatabase* pDatabase = NULL );

AMIAPI AmiStatus ami2DSSetReferenceLockMode( bool bMode, AcDbDatabase* pDatabase = NULL );

AMIAPI AmiStatus ami2DSIsSelectionLockMode( bool& bMode );

AMIAPI AmiStatus ami2DSSetSelectionLockMode( bool bMode );

AMIAPI AmiStatus ami2DSGetSelectionOrderMode( Ami::SelectionOrderOption& enMode );

AMIAPI AmiStatus ami2DSSetSelectionOrderMode( Ami::SelectionOrderOption enMode );


////////////////////////////////////////////////
// MCADAPI component and component definition functions
//
//-----------------------------------------------------------------------------
// Description: Returns a pointer to a component definition key that
//              represents the database's master component definition.
//              This function can be used to obtain the master compdef
//              of any loaded databases for the current document (i.e.
//              the host database and any loaded XRef'd databases).
//              It is the caller's responsibility to release the key.
// Input      : pDb - If non-NULL then the output key will be a key for
//              the master compdef of this database (provided it is loaded
//              and is in the current document).  If NULL, then the host
//              database of the current document is assumed.
//              appName	- Name of the application to perform the
//              function (optional).
// Output     : pCompDefKey - A pointer to a key for the requested master
//              component definition.
AMIAPI AmiStatus amiGetMasterCompDef ( AmiCompDefKey*& pCompDefKey,
                                AcDbDatabase* pDb = NULL,
                                const ACHAR* appName = Designer_Assemblies );

//-----------------------------------------------------------------------------
// Description: Copys the comp def to a new one with the given name
//              returns eInvalidName if the name is not syntactically ok
//              and eNameAlreadyExists if there already exists a comp def
//              with that name
// Input      : pCompDefKey - Pointer to component def key.
//            : compDefName - Name of component of the given key.
// Output     : pNewCompDefKey - key to the newly created compdef
AMIAPI AmiStatus amiCopyCompDef(AmiCompDefKey* pCompDef, AmiCompDefKey*& pNewCompDef, const ACHAR* newCopyname = NULL);

//-----------------------------------------------------------------------------
// Description: Returns keys to all components used by a component
//              definition. It is the caller’s responsibility to release
//              all the keys in the array and delete the array.
// Input      : pCompDefKey - Pointer to component defintion key.
// Output     : size - Number of keys returned.
//              pKeys - Array of pointers to component keys used by
//                          component definition.
AMIAPI AmiStatus amiGetCompDefChildren(AmiCompDefKey* pCompDefKey,
                   long& size, AmiCompKey**& pKeys);

//-----------------------------------------------------------------------------
// Description: Sets the name of the component definition. An error
//              status is returned if the name is invalid.
// Input      : pCompDefKey - The pointer to the component definition
//                            key.
// Output     : name - Name to be given to component definition.
AMIAPI AmiStatus amiSetCompDefName(AmiCompDefKey* pCompDefKey,
                   const ACHAR* name);

//-----------------------------------------------------------------------------
// Description: Adds a component to a component definition by providing
//              the definition for the component to be added. The owner
//              component definition must not be a leaf node nor may it
//              be external. A matrix is to be supplied to position the
//              component in WCS. The component key for the newly
//              created component is created and returned. The caller is
//              responsible for releasing the component key.
// Input      : def	  - Pointer to the component definition key for
//                          the component being inserted.
//              target - Pointer to the component definition key
//                          which will consume the new component.
//              matrix    - WCS position for the component.
// Output     : pCompKey - The pointer to the new component key.
AMIAPI AmiStatus amiAddCompToCompDef(AmiCompKey*& pCompKey,
                   AmiCompDefKey* def, AmiCompDefKey* target,
                   const AcGeMatrix3d& matrix);

//-----------------------------------------------------------------------------
// Description: Removes a component from a component definition. An
//              error is returned if the component does not   exist
//              within the component definition.
// Input      : pCompKey - The pointer to the component key to be
//                         removed.
//              pOwner - The pointer to the component definition key
//                          from which the component will be removed.
AMIAPI AmiStatus amiRemoveCompFromCompDef(AmiCompKey* pCompKey,
                   AmiCompDefKey* pOwner);

//-----------------------------------------------------------------------------
// Description: Checks if the component definition is an external
//              component definition.
// Input      : pCompDefKey - The pointer to the component definition
//                            key.
// Output     : external - True if external; false if local.
AMIAPI AmiStatus amiIsCompDefExternal(AmiCompDefKey* pCompDefKey,
									  Adesk::Boolean& external);

//-----------------------------------------------------------------------------
// Description: Checks if the given component definition is the master
//              definition.
// Input      : pCompDefKey - The pointer to the component definition
//                            key.
// Output     : master - Returns true if the component definition is the
//              master.
AMIAPI AmiStatus amiIsCompDefMaster(AmiCompDefKey* pCompDefKey,
									Adesk::Boolean& master);

//-----------------------------------------------------------------------------
// Description: Checks if the component definition is that of a leaf node.
// Input      : pCompDefKey - The pointer to the component definition
//                            key.
// Output     : leaf - True, if the component is a leaf node; false, if
//                     the component definition is not a leaf node.
AMIAPI AmiStatus amiIsCompDefLeafNode(AmiCompDefKey* pCompDefKey,
                   Adesk::Boolean& leaf);

//-----------------------------------------------------------------------------
// Description: Retrieves the name for the component specified by the
//              component key.  The user is responsible for releasing
//              the memory used by compName.
// Input      : pCompKey - The pointer to the component key.
// Output     : compName - Name of component of the given key.
AMIAPI AmiStatus amiGetCompName(AmiCompKey* pCompKey,
                   ACHAR*& compName);

//-----------------------------------------------------------------------------
// Description: Sets the name for the component specified by the
//              component key. An error status is returned if an invalid
//              name is passed-in.
//              NOTE: The name of a component that stems from an
//                    external file can be changed during the drawing
//                    session. However, the same change is not
//                    persistent and will revert during the next file
//                    loading.
// Input      : pCompKey - The pointer to the component key.
// Output     : compName - New name for the component.
AMIAPI AmiStatus amiSetCompName(AmiCompKey* pCompKey,
                   const ACHAR* compName);

//-----------------------------------------------------------------------------
// Description: Gets the component's definition. It is the caller’s
//              responsibility to release the key.
// Input      : pCompKey - Pointer to the component key.
// Output     : pCompDefKey - Pointer to key to the component's
//                            definition.
AMIAPI AmiStatus amiGetCompDef(AmiCompKey* pCompKey,
                   AmiCompDefKey*& pCompDefKey);

//-----------------------------------------------------------------------------
// Description: Gets the definition to the component owning the
//              component passed-in. The user is responsible for releasing
//              the component definition key.
// Input      : pCompKey - The pointer to the component key.
// Output     : pCompDefKey - The pointer to the component definition
//              key.
AMIAPI AmiStatus amiGetCompOwner(AmiCompKey* pCompKey,
                   AmiCompDefKey*& pCompDefKey);

//-----------------------------------------------------------------------------
// Description: Returnsthe current WCS position of the component. .
// Input      : pCompKey - The pointer to the component key.
// Output     : matrix - Actual position of component in current WCS
//              space.
AMIAPI AmiStatus amiGetCompPosition(AmiCompKey* pCompKey,
                   AcGeMatrix3d& matrix);

//-----------------------------------------------------------------------------
// Description: Sets the component to the new WCS position. All
//              instances of the component will also update accordingly.
// Input      : pCompKey - The pointer to the component key.
//              matrix - New WCS position for the component.
AMIAPI AmiStatus amiSetCompPosition(AmiCompKey* pCompKey,
                   const AcGeMatrix3d& matrix);

//-----------------------------------------------------------------------------
// Description: Returns a pointer to an array of component key pointers
// to the immediate (first level) subcomponents of the given component.
// It is the caller’s responsibility to release the keys.
// Input      : pCompKey - The pointer to the component key.
// Output     : size - Number of component key pointers being returned.
//              pCompKeys - A pointer to an array of component key
//                          pointers.
AMIAPI AmiStatus amiGetCompChildren(AmiCompKey* pCompKey,
                   long& size, AmiCompKey**& pKeys);

//-----------------------------------------------------------------------------
// Description: Given a key to a component returns the key to the component
//              which is its corresponding component in its space of definition.
// Input      : pCompKey1 - The pointer to the first component key.
// Output     : pCompKey2 - Pointer to corresponding component key.
AMIAPI AmiStatus amiGetCompInDef(AmiCompKey* pCompKey1,
                   AmiCompKey*& pCompKey2);

//-----------------------------------------------------------------------------
// Description: Returns a key to the component which "contains" the object referred to
//              by the key passed in (if the object is not "owned" by any component,
//              pcompKey is set to NULL).
// Input      : pObjKey  - Pointer to object key.
// Output     : pCompKey - Pointer to component key referencing the component that
//                         "contains" the object specified,
AMIAPI AmiStatus amiGetContainingComp ( AmiObjectKey* pObjKey, AmiCompKey*& pCompKey );

//-----------------------------------------------------------------------------
// Description: Externalize the given component definition.
// Input      : pCompDefKey - Pointer to comp def key who's component
//                            definitions is to be externalized.
//              pFileName   - Name of new file where component definition
//                            is to be stored.
//              pTemplateFileName
//                          - Name of template file used when creating new file
AMIAPI AmiStatus amiExternalize(AmiCompDefKey* pCompDef, const ACHAR* pFileName, const ACHAR* pTemplateFileName);

AMIAPI AmiStatus ami2DSLocalize(AmiCompDefKey* pCompDef, bool bLocalizeAll);

//-----------------------------------------------------------------------------
// Description: A convenience function to get all instances (components)
//              of a given component definition.  Only those instances
//              (components) within the given subassembly (scope) are
//              are returned.  All of the components returned will be
//              "focused" to the given scope (i.e. they will be components
//              in the assembly defined by the component definition
//              referenced by pScopeKey.
//              If pScopeKey is NULL, then the master assembly is used.
//
// Input      : pDefKey - Component definition for which instances are
//                  returned.
//            : pScopeKey - Context/scope for the search for instances.
//                  Only instances within this subassembly will be
//                  returned.  If NULL, then the master assembly is used.
// Output     : numInstances - number of instances returned.
//            : pInstances - array of pointers to keys for the instances.
//                  It is the caller's responsibility to release() the
//                  keys in the array and delete the array.
AMIAPI AmiStatus amiGetAllInstances(AmiCompDefKey* pDefKey, AmiCompDefKey* pScopeKey,
                    int& numInstances, AmiCompKey**& pInstances);

AMIAPI AmiStatus ami2DSCompHasGhostViews( AmiCompKey* pCompKey, bool& bHasGhostViews );

AMIAPI AmiStatus ami2DSCompGetReference( AmiCompKey* pCompKey, bool& bReference );

AMIAPI AmiStatus ami2DSCompSetReference( AmiCompKey* pCompKey, bool bReference );

AMIAPI AmiStatus ami2DSCompDefHasComponentViewDefinition( AmiCompDefKey* pCompDefKey, const ACHAR* pName, AmiCompViewDefKey*& pCompViewDefKey, bool& bHasViewDef );

AMIAPI AmiStatus ami2DSCompDefGetNextComponentViewDefinitionName( AmiCompDefKey* pCompDefKey, const ACHAR* pBaseName, ACHAR*& pNextName );

//-----------------------------------------------------------------------------
// Description: Replace the component with a new definition
// Input      : pCompKey - Component to be replaced.
// Input      : pNewDefKey - New definition to replace with.
AMIAPI AmiStatus ami2DSReplaceCompDef( AmiCompKey* pCompKey, AmiCompDefKey* pNewDefKey);

//-----------------------------------------------------------------------------
// Description: Create a copy of the definition for the specified component
// Input      : pCompKey - the component to be assigned the new definiton
// Input      : newDefName - the new name of the definition, must be unique.
AMIAPI AmiStatus ami2DSCopyCompDefinition(AmiCompKey* pCompKey, const ACHAR* newDefName);

//-----------------------------------------------------------------------------
// Description:	Returns the components definition name. It will return the 
//              full path name if fullPath is true and the components def is
//              external. The user is responsible for freeing the memory.
// Input      : pCompKey - component key
//              fullPath - true: give full path name (XREF name)
//                         false: give stripped name
// Output     : name - name of component definition
AMIAPI AmiStatus ami2DSGetCompDefName(AmiCompDefKey* pCompDefKey,
										ACHAR*& name, const Adesk::Boolean& fullPath = Adesk::kFalse );


////////////////////////////////////////////////
// MCADAPI component view and folder functions
//

AMIAPI AmiStatus ami2DSAddEntitiesToView(AcDbObjectIdArray& entitiesToAdd, AmiObjectKey* pViewKey);

//-----------------------------------------------------------------------------
// Description: Remove entities from the parent view.
// Input      : entitiesToRemove - entities to remove.
//              pViewKey - the parent folder/component view key
AMIAPI AmiStatus ami2DSRemoveViewEntities(AcDbObjectIdArray& entitiesToRemove, AmiObjectKey* pViewKey);

AMIAPI AmiStatus ami2DSGetViewName(AmiFolderKey* pViewKey, ACHAR*& name );

AMIAPI AmiStatus ami2DSGetViewGeomPathName(AmiFolderKey* pViewKey, ACHAR*& pathName );

AMIAPI AmiStatus ami2DSGetViewEntities(AmiFolderKey* pViewKey, AcDbObjectIdArray& viewEntities );

AMIAPI AmiStatus ami2DSGetViewPosition(AmiFolderKey* pViewKey, AcGeMatrix3d& position );

AMIAPI AmiStatus ami2DSSetViewPosition(AmiFolderKey* pViewKey, const AcGeMatrix3d& position );

AMIAPI AmiStatus ami2DSGetCompInView(AmiCompViewKey* pCompViewKey, AmiCompKey*& pNewCompKey );

AMIAPI AmiStatus ami2DSGetViewDefinition(AmiFolderKey* pFolderKey, AmiFolderDefKey*& pFolderDefKey );

AMIAPI AmiStatus ami2DSGetViewOwnerDef(AmiFolderKey* pFolderKey, AmiFolderDefKey*& pOwnerFolderDefKey );

AMIAPI AmiStatus ami2DSGetViewChildren(AmiFolderKey* pViewKey, long& size, AmiFolderKey**& pViews );

AMIAPI AmiStatus ami2DSIsCompViewFeature(AmiCompViewKey* pCompViewKey, Adesk::Boolean& isFeature );

AMIAPI AmiStatus ami2DSGetViewGeomExtents(AmiFolderKey* pViewKey, AcDbExtents& extents );

AMIAPI AmiStatus ami2DSHasViewExternalDef(AmiFolderKey* pViewKey, Adesk::Boolean& hasExternalDef );

AMIAPI AmiStatus ami2DSIsViewLocked(AmiFolderKey* pViewKey, Adesk::Boolean& isLocked );

AMIAPI AmiStatus ami2DSIsLeafOccurrence(AmiFolderKey* pViewKey, Adesk::Boolean& isLeaf );

AMIAPI AmiStatus ami2DSIsInstanceOccurrence(AmiFolderKey* pViewKey, Adesk::Boolean& isInstance );

AMIAPI AmiStatus ami2DSIsSubentityOf(AmiFolderKey* pViewKey1, AmiFolderKey* pViewKey2,
									 Adesk::Boolean& isSubEntity,
									 Adesk::Boolean isEqual = Adesk::kFalse );

AMIAPI AmiStatus ami2DSGetViewContextDef(AmiFolderKey* pFolderKey, AmiFolderDefKey*& pContextFolderDefKey );

AMIAPI AmiStatus ami2DSClearLeaf(AmiFolderKey* pViewKey );

AMIAPI AmiStatus amiIsCompDef2D(AmiCompDefKey* pCompDefKey, Adesk::Boolean& is2D);

AMIAPI AmiStatus amiIsCompDef2DAssembly(AmiCompDefKey* pCompDefKey, Adesk::Boolean& is2DAssembly);

AMIAPI AmiStatus amiIsCompDefFeature(AmiCompDefKey* pCompDefKey, Adesk::Boolean& isFeature);

AMIAPI AmiStatus amiCompDefSortChildren(AmiCompDefKey* pCompDef);

AMIAPI AmiStatus amiGetPhantomState(AmiCompDefKey* pCompDefKey, Ami::PhantomState& phantomState);

AMIAPI AmiStatus amiSetPhantomState(AmiCompDefKey* pCompDefKey, Ami::PhantomState phantomState);

AMIAPI AmiStatus amiGetViewDefsInCompDef(AmiCompDefKey* pCompDefKey, long& size, AmiCompViewDefKey**& pViewDefKeys);

AMIAPI AmiStatus amiIsCompDefStdPart(AmiCompDefKey* pCompDefKey, Adesk::Boolean& isStdPart);

AMIAPI AmiStatus amiIsCompDefShaft(AmiCompDefKey* pCompDefKey, Adesk::Boolean& isShaft);

AMIAPI AmiStatus amiIsComp2D(AmiCompKey* pCompKey, Adesk::Boolean& is2D);

AMIAPI AmiStatus amiIsCompHasExternalDef(AmiCompKey* pCompKey, Adesk::Boolean& HasExternalDef);

AMIAPI AmiStatus amiCompSortChildren(AmiCompKey* pCompKey);

AMIAPI AmiStatus amiGetViewsInComp(AmiCompKey* pCompKey, long& size, AmiCompViewKey**& pViewKeys);

AMIAPI AmiStatus ami2DSViewIsGhost( AmiCompViewKey* pCompViewKey, bool& bIsGhost, bool bTreatFeatAsNonGhost = true );

//-----------------------------------------------------------------------------
// Description: Explode the specified folder or component view
// Input      : pFolderKey - the view / folder to be exploded.
AMIAPI AmiStatus ami2DSExplodeView(AmiFolderKey * pFolderKey);

//-----------------------------------------------------------------------------
// Description: Replace the folder with a new definition
// Input      : pFolderKey - Folder to be replaced.
// Input      : pNewDefKey - New definition to replace with.
AMIAPI AmiStatus ami2DSReplaceViewDef( AmiFolderKey* pFolderKey, AmiFolderDefKey* pNewDefKey);

//-----------------------------------------------------------------------------
// Description: Create a copy of the definition for the specified folder or component view
// Input      : pFolderKey - the view / folder to be assigned the new definition
// Input      : newDefName - the new name of the definition, must be unique.
AMIAPI AmiStatus ami2DSCopyViewDefinition(AmiFolderKey * pFolderKey, const ACHAR* newDefName);

//-----------------------------------------------------------------------------
// Description: Copy the entities to the folder / component view.
// Input      : entitiesToCopy - entities to copy.
//              pViewKey - destination folder / component view key
AMIAPI AmiStatus ami2DSCopyEntitiesToView(AcDbObjectIdArray& entitiesToCopy, AmiObjectKey* pViewKey);

//-----------------------------------------------------------------------------
// Description: Copy the specified view to the destination view
// Input      : pFolderToCopyKey - the view/folder to be copied.
//              pTargetKey - the target view/folder to copy to.
AMIAPI AmiStatus ami2DSCopyViewToView(AmiFolderKey * pFolderToCopyKey, AmiFolderKey* pTargetKey);

//-----------------------------------------------------------------------------
// Description: Retrieve the view scale
// Input      : pFolderKey - the view/folder to whose view scale is to be obtained.
// Output     : curScale - the current view scale.
AMIAPI AmiStatus ami2DSGetViewScale(AmiFolderKey * pFolderKey, double &curScale);

//-----------------------------------------------------------------------------
// Description: Set the view scale
// Input      : pFolderKey - the view/folder to be scaled.
//              newScale - the scale to set to.
AMIAPI AmiStatus ami2DSSetViewScale(AmiFolderKey * pFolderKey, double newScale);

//-----------------------------------------------------------------------------
// Description: Set the view base point
// Input      : pFolderKey - the key of the folder or component view, whose base point is to be set.
// Input     : basePt - the base point to set to.
AMIAPI AmiStatus ami2DSSetViewBasePoint(AmiFolderKey* pFolderKey, const AcGePoint3d& basePt);

//-----------------------------------------------------------------------------
// Description: Retrieve the view base point
// Input      : pFolderKey - the key of the folder or component view, whose base point is to be obtained.
// Output     : basePt - the current base point.
AMIAPI AmiStatus ami2DSGetViewBasePoint(AmiFolderKey* pFolderKey, AcGePoint3d& basePt);

//-----------------------------------------------------------------------------
// Description: Checks whether the folder or component view has property override.
// Input      : pFolderKey - key of the view /folder to be checked.
// Output     : bHasOverride - returns whether property overrides exist.
AMIAPI AmiStatus ami2DSHasViewOverrideProperties(AmiFolderKey * pFolderKey, bool &bHasOverride);

//-----------------------------------------------------------------------------
// Description: Set color overides for the folder or component view. Since
//              color overrides applies only when predefined reference is
//              false, this function will return Ami::eBad if predefined
//              reference has already been set.
// Input      : pFolderKey - the view to whose override is to be set.
//              bColor     - true to set color and false to unset.
//              bContoursColorOnly - whether to set only only for contours.
//              trueColour - points to the color to set to. Can be null which will
//                           result in the colour value to be unchanged.
AMIAPI AmiStatus ami2DSSetViewColorOverride(AmiFolderKey * pFolderKey,
                  bool bColor,
                  bool bContoursColorOnly,
                  const AcCmColor *trueColor = NULL);

//-----------------------------------------------------------------------------
// Description: Set visibility overrides for the folder or component view.
// Input      : pFolderKey - the view to whose override is to be set.
//              bContoursOnly - whether to isolates the contour (continuous)
//                              lines in a folder or view. It can be used
//                              in conjunction with Centerline visibility and
//                              Color, but is not available in conjunction
//                              with Hidden Line visibility.
//                              If predefined override is set, then bContoursOnly
//                              and bHiddenLines will be ignored.
//              bHiddenLines - whether to turns off visibility of hidden
//                             lines in a folder or view. This option is
//                             not applicable when the Contours Only
//                             visibility is set.
//              bCenterLines - control centerline visibility.
AMIAPI AmiStatus ami2DSSetViewVisibilityOverride(AmiFolderKey * pFolderKey,
                                           bool bContoursOnly,
                                           bool bHiddenLines,
                                           bool bCenterLines);

//-----------------------------------------------------------------------------
// Description: Set predefined reference overrides for the folder or component view.
// Input      : pFolderKey - the view to whose override is to be set.
//              bPredefinedRef - whether to set reference override.
//                               Visibility of everything except contours
//                               is turned off. Contour lines are changed to
//                               the configured linetype of the phantom line
//                               layer (AM_11 by default) and the color of
//                               contour lines is changed to the configured
//                               color of the phantom line layer (AM_11 by default).
AMIAPI AmiStatus ami2DSSetViewPredefinedRefOverride(AmiFolderKey * pFolderKey,
                                             bool bPredefinedRef);

//-----------------------------------------------------------------------------
// Description: Clear the override properties for the folder or component view.
// Input      : pFolderKey - the view whose override, if any, is to be clear.
AMIAPI AmiStatus ami2DSClearViewOverrideProperties(AmiFolderKey * pFolderKey);

//-----------------------------------------------------------------------------
// Description: Checks whether any of the component's view(/s) has property override.
// Input      : pCompKey - the component whose override is to be checked.
// Output     : bHasOverride - returns whether property overrides exist.
AMIAPI AmiStatus ami2DSHasCompOverrideProperties(AmiCompKey * pCompKey, bool &bHasOverride);

//-----------------------------------------------------------------------------
// Description: Set color overides for the component view. All the views of the
//              component will be affected. Since color overrides applies only
//              when predefined reference is false, this function will force 
//              redefined reference to be false.
// Input      : pCompKey - the component to whose override is to be set.
//              bColor     - true to set color and false to unset.
//              bContoursColorOnly - whether to set only only for contours.
//              trueColour - points to the color to set to. Can be null which will
//                           result in the colour value to be unchanged.
AMIAPI AmiStatus ami2DSSetCompColorOverride(AmiCompKey * pCompKey,
                  bool bColor,
                  bool bContoursColorOnly,
                  const AcCmColor *trueColor = NULL);

//-----------------------------------------------------------------------------
// Description: Set visibility overrides for the component. All the views of the
//              component will be affected.
// Input      : pCompKey - the component whose override is to be set.
//              bContoursOnly - whether to isolates the contour (continuous)
//                              lines in a folder or view. It can be used
//                              in conjunction with Centerline visibility and
//                              Color, but is not available in conjunction
//                              with Hidden Line visibility.
//                              If predefined override is set, then bContoursOnly
//                              and bHiddenLines will be ignored.
//              bHiddenLines - whether to turns off visibility of hidden
//                             lines in a folder or view. This option is
//                             not applicable when the Contours Only
//                             visibility is set.
//              bCenterLines - control centerline visibility.
AMIAPI AmiStatus ami2DSSetCompVisibilityOverride(AmiCompKey * pCompKey,
                  bool bContoursOnly,
                  bool bHiddenLines,
                  bool bCenterLines);

//-----------------------------------------------------------------------------
// Description: Set predefined reference overrides for the component.
// Input      : pCompKey - the component whose override is to be set.
//              bPredefinedRef - whether to set reference override.
//                               Visibility of everything except contours
//                               is turned off. Contour lines are changed to
//                               the configured linetype of the phantom line
//                               layer (AM_11 by default) and the color of
//                               contour lines is changed to the configured
//                               color of the phantom line layer (AM_11 by default).
AMIAPI AmiStatus ami2DSSetCompPredefinedRefOverride(AmiCompKey * pCompKey,
                  bool bPredefinedRef);

//-----------------------------------------------------------------------------
// Description: Clear the override properties for the component.
//              All the component views associated with the component will have
//              their override properties, if any, clear.
// Input      : pCompKey - the component whose override is to be clear.
AMIAPI AmiStatus ami2DSClearCompOverrideProperties(AmiCompKey * pCompKey);



//////
// MCADAPI component view definition and folder definition functions
//
AMIAPI AmiStatus ami2DSGetViewDefName(AmiFolderDefKey* pViewDefKey, ACHAR*& name);

AMIAPI AmiStatus ami2DSGetViewDefFullName(AmiFolderDefKey* pViewDefKey, ACHAR*& name);

AMIAPI AmiStatus ami2DSSetViewDefName(AmiFolderDefKey* pViewDefKey, const ACHAR* name);

AMIAPI AmiStatus ami2DSGetNextViewName(AmiFolderDefKey* pViewDefKey, ACHAR*& name, AcDbDatabase *pDb = NULL /*= workingDb*/);

AMIAPI AmiStatus ami2DSLookupViewName(AmiFolderDefKey* pViewDefKey, const ACHAR* viewName,
                                                               Adesk::Boolean& found, AcDbDatabase *pDb = NULL/*= workingDb*/);

AMIAPI AmiStatus ami2DSGetViewDefGeomExtents(AmiFolderDefKey* pViewDefKey, AcDbExtents& extents);

AMIAPI AmiStatus ami2DSSortViewDefChildren(AmiFolderDefKey* pViewDefKey);

AMIAPI AmiStatus ami2DSGetCompViewDefOwner(AmiCompViewDefKey* pViewDefKey, AmiCompDefKey*& pCompDefKey);

AMIAPI AmiStatus ami2DSIsViewDefExternal(AmiFolderDefKey* pViewDefKey, Adesk::Boolean& isExternal,
                                                                   AcDbDatabase* pRelativeDb = NULL);

AMIAPI AmiStatus ami2DSIsCompViewDefFeature(AmiCompViewDefKey* pViewDefKey, Adesk::Boolean& isFeature);

AMIAPI AmiStatus ami2DSIsViewDefAnnotation(AmiFolderDefKey* pViewDefKey, Adesk::Boolean& isAnnot);

AMIAPI AmiStatus ami2DSIsViewDefDetail(AmiFolderDefKey* pViewDefKey, Adesk::Boolean& isDetail);

AMIAPI AmiStatus ami2DSIsMasterViewDef(AmiFolderDefKey* pViewDefKey, Adesk::Boolean& isMaster);

AMIAPI AmiStatus ami2DSViewDefInstancesViewDef(AmiFolderDefKey* pViewDefKey1, AmiFolderDefKey* pViewDefKey2,
                   Adesk::Boolean& instances);

AMIAPI AmiStatus ami2DSGetViewDefChildren(AmiFolderDefKey* pViewDefKey,
										  long& size, AmiFolderKey**& pViews,
										  AmiFolderKey *pParentView = NULL);

AMIAPI AmiStatus ami2DSGetCompViewDefInstances(AmiCompViewDefKey* pViewDefKey, long& size, AmiCompViewKey**& pViews,
                                                                         AcDbDatabase *pDb = NULL);

AMIAPI AmiStatus ami2DSGetViewDefInstances(AmiFolderDefKey* pViewDefKey, long& size, AmiFolderKey**& pViews,
										   AcDbDatabase *pDb = NULL);

AMIAPI AmiStatus ami2DSGetCompViewDefOccurrences(AmiCompViewDefKey* pViewDefKey, long& size, AmiCompViewKey**& pViews,
                                                                          AcDbDatabase *pDb = NULL);

AMIAPI AmiStatus ami2DSGetViewDefOccurrences(AmiFolderDefKey* pViewDefKey, long& size, AmiFolderKey**& pViews,
                                                                       AcDbDatabase *pDb = NULL);

AMIAPI AmiStatus ami2DSGetViewDefInstanceCount(AmiFolderDefKey* pViewDefKey, int& numInstances);

AMIAPI AmiStatus ami2DSGetViewDefChildrenCount(AmiFolderDefKey* pViewDefKey, int& numChildren);

AMIAPI AmiStatus ami2DSGetViewDefType(AmiFolderDefKey* pViewDefKey, Ami::View2DType& viewType);

AMIAPI AmiStatus ami2DSSetViewDefType(AmiFolderDefKey* pViewDefKey, Ami::View2DType viewType);

AMIAPI AmiStatus ami2DSAddTransientEntsToViewDef(AmiFolderDefKey* pViewDefKey,
                   AcDbVoidPtrArray & newEntities,
                   const AcGeMatrix3d & trans);

AMIAPI AmiStatus ami2DSAddFromExistingEntsToViewDef(AmiFolderDefKey* pViewDefKey, const AcDbObjectIdArray& entityIds);

AMIAPI AmiStatus ami2DSIsViewDefLocked(AmiFolderDefKey* pViewDefKey, Adesk::Boolean& isLocked);

AMIAPI AmiStatus ami2DSSetViewDefLocked(AmiFolderDefKey* pViewDefKey, Adesk::Boolean isLocked);

AMIAPI AmiStatus ami2DSGetViewDefLockType(AmiFolderDefKey* pViewDefKey, Adesk::UInt32& lockType);

AMIAPI AmiStatus ami2DSExternalizeFolderDef(AmiFolderDefKey* pViewDefKey, const ACHAR *pFileName,
                   const ACHAR* pTemplateFileName);

AMIAPI AmiStatus ami2DSLocalizeFolderDef(AmiFolderDefKey* pViewDefKey, bool bLocalizeAll);

//-----------------------------------------------------------------------------
// Description: Create an annotation view and definition based on the specified component definition and component view definitions.
// output     : pNewAnnotationViewDefKey - new annotation view definition that will be created.
// output     : pFolderInstKey - folder of the newly created annotation view.
// input      : position - Matrix to be used to position the new definition in WCS.
// input      : arMatrices - array of matrices for the new position of each of the new views.

// input      : pCompDefKey - component definition to base annotation on.
// Input      : arCompViewDefKeys - array of component view definitions of pCompDefKey whose corresponding annotation view position are specified in arMatrices.
// Input      : annotationViewName - name of annotation view e.g. COMP1(AV). Optional. If not
//                                   supplied, the system will fill in the appropriate name.
// Input      : bCreateLabels - specifies whether to create labels for annotation view sub views, default is false
// Input      : labelPattern - specifies label pattern for view labels valid only if bCreateLabels is true
// Input      : owningSpaceId - specifies owning space (model or paper space) for new instance of annotation view,
//                              annotation view is created in active layout if owningSpaceId is kNull (by default)
AMIAPI AmiStatus ami2DSInstanceAnnotationView (AmiAnnotationViewDefKey*& pNewAnnotationViewDefKey,
                  AmiFolderKey*& pFolderInstKey,
                  const AcGeMatrix3d& position,
                  const AcArray<AcGeMatrix3d*>& arMatrices,
                  AmiCompDefKey* pCompDefKey, 
                  const AcArray<AmiCompViewDefKey*>& arCompViewDefKeys,
                  const ACHAR* annotationViewDefName = NULL,
                  bool bCreateLabels = false,
                  const ACHAR *labelPattern = NULL,
                  const AcDbObjectId &owningSpaceId = AcDbObjectId::kNull
                  );

AMIAPI AmiStatus ami2DSInstanceAnnotationView2(AmiAnnotationViewDefKey* pDefToInstance,
                   const AcGeMatrix3d& position,
                   AmiFolderKey*& pFolderInstKey,
                   const AcDbObjectId& viewSpaceId = AcDbObjectId::kNull
                  );

//-----------------------------------------------------------------------------
// Description: Extract the component definition that the annotation view is based on
// input      : pViewDefKey - the annotation view def key.
// output     : pCompDefKey - the component definition.
AMIAPI AmiStatus ami2DSGetAnnotationViewDefCompDef(AmiAnnotationViewDefKey* pViewDefKey, AmiCompDefKey*& pCompDefKey);

//-----------------------------------------------------------------------------
// Description: Add an annotation view for the specified component view definition.
// input      : pDefToInstance - component view definition whose annotation is to be created.
// input      : pTargetDefKey - the target annotation view definition that the new annotation will be added to.
// input      : position - new position of the annotation view.
// output     : pCompViewInstKey - points to the newly created annotation view.
AMIAPI AmiStatus ami2DSAddViewToAnnotationView(AmiCompViewDefKey* pDefToInstance, AmiAnnotationViewDefKey* pTargetDefKey,
                  const AcGeMatrix3d& position, AmiCompViewKey *& pCompViewInstKey);

AMIAPI AmiStatus ami2DSGetViewOwningSpace(AmiFolderKey* pViewKey, AcDbObjectId& viewSpaceId);

AMIAPI AmiStatus ami2DSCreateAnnotationViewLabels(AmiAnnotationViewDefKey* pViewDefKey, const ACHAR *labelPattern = NULL);

AMIAPI AmiStatus ami2DSCreateAnnotationViewLabel(AmiCompViewKey* pSubViewKey, const ACHAR *labelPattern = NULL);

AMIAPI AmiStatus ami2DSEraseAnnotationViewLabel(AmiCompViewKey* pSubViewKey);

AMIAPI AmiStatus ami2DSGetAnnotationViewLabel(AmiCompViewKey* pSubViewKey, AmiFolderKey*& pViewLabelKey);

AMIAPI AmiStatus ami2DSGetAnnotationViewLabelPattern(AmiCompViewKey* pSubViewKey, ACHAR*& pLabelPattern);

AMIAPI AmiStatus ami2DSSetAnnotationViewLabelPattern(AmiCompViewKey* pSubViewKey, const ACHAR* pLabelPattern);

AMIAPI AmiStatus ami2DSHasAnnotationViewLabel(AmiCompViewKey* pSubViewKey, Adesk::Boolean &bHasLabel);

//-----------------------------------------------------------------------------
// Description: Remove the specified child view of the parent definition.
// input      : pParentDefKey - the parent definition.
// input      : pCompViewKey - the child component view to be removed.
AMIAPI AmiStatus ami2DSRemoveChildView(AmiFolderDefKey* pParentDef, AmiCompViewKey* pCompViewInstKey);

AMIAPI AmiStatus ami2DSGetHidesSuppressState(AmiFolderDefKey* pViewDefKey, bool bSuppressed, bool &bState, bool &bHasHides);

AMIAPI AmiStatus ami2DSSetHidesSuppressState(AmiFolderDefKey* pViewDefKey, bool bSuppressed);

AMIAPI AmiStatus ami2DSGetCompViewDefs( long& count,
                  AmiCompViewDefKey**& pCompViewDefs,
                  bool bIncludeExernals = false,
                  AcDbDatabase* pDb = NULL);

AMIAPI AmiStatus ami2DSCreateBlocksFromStructure( bool bRemoveStructure = true);

//-----------------------------------------------------------------------------
// Description: Purge all definitions whose name matches the pattern.
// Input      : pNamePattern - Refer to the Object Arx documentation of 
//                             acutWcMatch() for details of the wildcard characters.
//                             Specify "*" to match everything.
AMIAPI AmiStatus ami2DSPurgeAll(const ACHAR* pNamePattern = ACRX_T(/*MSG0*/"*"));

//-----------------------------------------------------------------------------
// Description: Purge all component definitions whose name matches the pattern.
// Input      : pNamePattern - Refer to the Object Arx documentation of 
//                             acutWcMatch() for details of the wildcard characters.
//                             Specify "*" to match everything.
AMIAPI AmiStatus ami2DSPurgeComponentDefinitions(const ACHAR* pNamePattern = ACRX_T(/*MSG0*/"*"));

//-----------------------------------------------------------------------------
// Description: Purge all annotation view definitions whose name matches the pattern.
// Input      : pNamePattern - Refer to the Object Arx documentation of 
//                             acutWcMatch() for details of the wildcard characters.
//                             Specify "*" to match everything.
AMIAPI AmiStatus ami2DSPurgeAnnotationViewDefinitions(const ACHAR* pNamePattern = ACRX_T(/*MSG0*/"*"));

//-----------------------------------------------------------------------------
// Description: Purge all component view definitions whose name matches the pattern.
// Input      : pNamePattern - Refer to the Object Arx documentation of 
//                             acutWcMatch() for details of the wildcard characters.
//                             Specify "*" to match everything.
AMIAPI AmiStatus ami2DSPurgeComponentViewDefinitions(const ACHAR* pNamePattern = ACRX_T(/*MSG0*/"*"));

//-----------------------------------------------------------------------------
// Description: Purge all folder definitions whose name matches the pattern.
// Input      : pNamePattern - Refer to the Object Arx documentation of 
//                             acutWcMatch() for details of the wildcard characters.
//                             Specify "*" to match everything.
AMIAPI AmiStatus ami2DSPurgeFolderDefinitions(const ACHAR* pNamePattern = ACRX_T(/*MSG0*/"*"));


////////////////////////////////////////////////
// AMSHIDE 2D
//
AMIAPI AmiStatus ami2DSGetDefHideSituations(AmiFolderDefKey* pFolderDefKey,
                   AmiArray<AmiHideSituationKey>& rVal);

AMIAPI AmiStatus ami2DSGetDefComplexHideSituations(AmiFolderDefKey* pFolderDefKey,
                   AmiArray<AmiComplexHideSituationKey>& rVal);

AMIAPI AmiStatus ami2DSFindHideSituations( AmiFolderDefKey* pFolderDefKey,
                                const AmiFolderKey* pSubent, 
                                AmiArray<AmiHideSituationKey>& rVal,
                                long** referredToAs,
                                AmiHideSituationRefType refType = Ami::mc2DSAllRef );

AMIAPI AmiStatus ami2DSAddHideSiatuation(AmiFolderDefKey*& pFolderDefKey,
                     const ACHAR* name,
                     const AcDbObjectIdArray& fgObjIds,
                     const AmiArray<AmiFolderKey>& fgKeys,
                     const AcDbObjectIdArray& bgObjIds,
                     const AmiArray<AmiFolderKey>& bgKeys,
                     AmiHideSituationKey*& pHideSituation);

AMIAPI AmiStatus ami2DSAddComplexHideSiatuation(AmiFolderDefKey*& pFolderDefKey,
                     const ACHAR* name,
                     AmiArray<AmiHideSituationKey>& rHideKeys,
                     AmiComplexHideSituationKey*& pHideSituation);


////////////////////////////////////////////////
AMIAPI AmiStatus amiFEGetFormulaEvaluator(AmiFormulaEvaluator*& pFormulaEvaluatorKey, 
                  const AcDbObjectId& id);

AMIAPI AmiStatus amiFESetAttributeDataProvider(AmiFormulaEvaluator* pFormulaEvaluatorKey, 
                   const AcDbObjectId& id);

AMIAPI AmiStatus amiFEExistAttribute(AmiFormulaEvaluator* pFormulaEvaluatorKey, 
                   const ACHAR* attName, Adesk::Boolean& exist);

AMIAPI AmiStatus amiFEIsAttributeEditable(AmiFormulaEvaluator* pFormulaEvaluatorKey, 
                   const ACHAR* attName, Adesk::Boolean& isEditable);

AMIAPI AmiStatus amiFESetAttributeData(AmiFormulaEvaluator* pFormulaEvaluatorKey, 
                   const ACHAR* attName, const ACHAR* attData);

AMIAPI AmiStatus amiFEGetAttributeData(AmiFormulaEvaluator* pFormulaEvaluatorKey, 
                  const ACHAR* attName, ACHAR*& attData);

AMIAPI AmiStatus amiFEGetAllAttributeData(AmiFormulaEvaluator* pFormulaEvaluatorKey, 
                   const ACHAR* attName, ACHAR*& attValue, ACHAR*& attData,
                   Adesk::Boolean& editFlag, Adesk::Boolean& result);

AMIAPI AmiStatus amiFEGetAllValuesOfAttribute(AmiFormulaEvaluator* pFormulaEvaluatorKey, 
                   const ACHAR* attName,
                   int& numValues, ACHAR**& values);

AMIAPI AmiStatus amiFEAttributeArray(AmiFormulaEvaluator* pFormulaEvaluatorKey, 
                    int& numValues, ACHAR**& values);

AMIAPI AmiStatus amiFEvaluate(AmiFormulaEvaluator* pFormulaEvaluatorKey, 
                     const ACHAR* formula,
                     ACHAR*& value);

#endif  // AMICOMP_H
