//////////////////////////////////////////////////////////////////////////////
//
//  Copyright 2023 Autodesk, Inc.  All rights reserved.
//
//  Use of this software is subject to the terms of the Autodesk license 
//  agreement provided at the time of installation or download, or which 
//  otherwise accompanies this software in either electronic or hard copy form.   
//
//////////////////////////////////////////////////////////////////////////////

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

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

class AmiBodyKey;
class AmiSolidKey;
class AmiCompConstrKey;
class AmiHideSituationKey;
class AmiComplexHideSituationKey;

namespace Ami
{
    ///<summary>View type enumeration.</summary>
    enum View2DType
    {
      k2DSUndefinedView = 0,  // default, used for views created by user
      k2DSFrontView,
      k2DSTopView,
      k2DSBackView,
      k2DSSideView,
      k2DSSideLeftView,
      k2DSSideRightView,
      k2DSBottomView,
      k2DSPartialView,
      k2DSSectionView,
      k2DSDetailView,
      k2DSHalfSectionView,
      k2DSHalfSectionVisibleView,
      k2DSAuxiliaryView,
    };

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

    ///<summary>Enumerates all available 2D Structure selection order options.</summary>
    enum SelectionOrderOption
    {
      ///<summary>Specifies that the 2D Structure selection order is from top to bottom.</summary>
      kTopDown = 0,
      ///<summary>Specifies that the 2D Structure selection order is from bottom to top.</summary>
      kBottomUp = 1
    };
};

///<summary>Component key class.</summary>
class AMIAPI AmiCompKey : public AmiObjectKey
{
  public:
    MCADAPI_DECLARE_MEMBERS(AmiCompKey);
};

///<summary>Component definition key class.</summary>
class AMIAPI AmiCompDefKey : public AmiObjectKey
{
  public:
    MCADAPI_DECLARE_MEMBERS(AmiCompDefKey);
};


///<summary>Folder key class.</summary>
class AMIAPI AmiFolderKey : public AmiObjectKey
{
public:
  MCADAPI_DECLARE_MEMBERS(AmiFolderKey);
};

///<summary>Folder definition key class.</summary>
class AMIAPI AmiFolderDefKey : public AmiObjectKey
{
public:
  MCADAPI_DECLARE_MEMBERS(AmiFolderDefKey);
};

///<summary>Component view key class.</summary>
class AMIAPI AmiCompViewKey : public AmiFolderKey
{
  public:
    MCADAPI_DECLARE_MEMBERS(AmiCompViewKey);
};

///<summary>Component view definition key class.</summary>
class AMIAPI AmiCompViewDefKey : public AmiFolderDefKey
{
  public:
    MCADAPI_DECLARE_MEMBERS(AmiCompViewDefKey);
};

///<summary>Annotation view definition key class.</summary>
class AMIAPI AmiAnnotationViewDefKey : public AmiFolderDefKey
{
public:
  MCADAPI_DECLARE_MEMBERS(AmiAnnotationViewDefKey);
};

///<summary>This is class AmiFormulaEvaluator.</summary>
class AMIAPI AmiFormulaEvaluator : public AmiObjectBase
{
public:
  MCADAPI_DECLARE_MEMBERS(AmiFormulaEvaluator);
};


///<summary>Removes entities from 2d structure view (folder or component view).</summary>
///<param name="entitiesToRemove">entities to remove.</param>
AMIAPI AmiStatus amiRemoveViewEntities(AcDbObjectIdArray& entitiesToRemove);

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

///<summary>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.</summary>
///<param name="pDefKey">Pointer to the component definition key for
///                           the component being inserted.</param>
///<param name="pTargetKey">Pointer to the component definition key
///                           which will consume the new component.</param>
///<param name="pCompKey">The pointer to the new component key.</param>
AMIAPI AmiStatus amiInstance2dComp( AmiCompKey*& pCompKey, AmiCompDefKey* pDefKey, AmiCompDefKey* pTargetKey );

///<summary>Erases component view specified by key.</summary>
///<param name="pCompViewKey">The pointer to the component view key to be erased.</param>
AMIAPI AmiStatus amiRemoveView( AmiCompViewKey *& pCompViewKey );

///<summary>Adds entities to component view.</summary>
///<param name="entitiesToAdd">entities to add.</param>
///<param name="pCompViewKey">component view key</param>
AMIAPI AmiStatus amiAddEntitiesToView( AcDbObjectIdArray& entitiesToAdd, AmiCompViewKey *& pCompViewKey );

///<summary>Erases folder specified by key.</summary>
///<param name="pFolderKey">The pointer to the folder key to be erased.</param>
AMIAPI AmiStatus amiRemoveFolder(AmiFolderKey *& pFolderKey);

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

///<summary>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</summary>
///<param name="pPrompt">command prompt which will be displayed during selection of drawing entities</param>
///<param name="excludeEnts">an array of object ids of entities that have been
///              already selected as view geometry and cannot be selected again
///              for another view</param>
///<param name="selectedEnts">an array of object ids of selected entities</param>
AMIAPI AmiStatus amiSelectViewGeometry( const ACHAR* pPrompt,
									    const AcDbObjectIdArray& excludeEnts,
										AcDbObjectIdArray& selectedEnts );

///<summary>Retrieves all the component definitions that exist in
///              the current database. This list does NOT include the
///              master component definition. It is the caller�s responsibility
///              to release all the keys in the array and delete the array.</summary>
///<param name="appName">Name of the application to perform the function.</param>
///<param name="size">Number of keys returned.</param>
///<param name="pCompKeys">The pointer to an array of pointers to component definition keys.</param>
AMIAPI AmiStatus amiGetAllCompDefs ( long& size, AmiCompDefKey**& pCompDefKeys,
                             const ACHAR* appName = Designer_Assemblies );

///<summary>Returns the name of the component definition. If
///              fullPath is true and the component definition is
///              external, the full path to the file will be returned.
///              The user is responsible for releasing the memory for
///              compDefName.</summary>
///<param name="pCompDefKey">The pointer to the component definition key.</param>
///<param name="fullPath">If true, and the component definition is
///              external, the full path to the file will be returned.</param>
///<param name="compDefName">Name of the component definition.</param>
AMIAPI AmiStatus amiGetCompDefName ( AmiCompDefKey* pCompDefKey, ACHAR*& compDefName,
                                    const Adesk::Boolean& fullPath = Adesk::kFalse );

/* --------- 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 --------- */

///<summary>Creates an empty 2d component definition. The caller is
///              responsible for releasing the key.</summary>
///<param name="compDefName">Name of the new component definition.</param>
///<param name="appName">Name of application to perform the function.</param>
///<param name="pCompDefKey">The pointer to the new component</param>
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 );


////////////////////////////////////////////////
///<summary>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.</summary>
///<param name="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.</param>
///<param name="appName">Name of the application to perform the function (optional).</param>
///<param name="pCompDefKey"><A pointer to a key for the requested master component definition./param>
AMIAPI AmiStatus amiGetMasterCompDef ( AmiCompDefKey*& pCompDefKey,
                                AcDbDatabase* pDb = NULL,
                                const ACHAR* appName = Designer_Assemblies );

///<summary>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.</summary>
///<param name="pCompDefKey">Pointer to component defintion key.</param>
///<param name="size">Number of keys returned.</param>
///<param name="pKeys">Array of pointers to component keys used by
///                          component definition.</param>
AMIAPI AmiStatus amiGetCompDefChildren(AmiCompDefKey* pCompDefKey,
                   long& size, AmiCompKey**& pKeys);

///<summary>Sets the name of the component definition. An error
///              status is returned if the name is invalid.</summary>
///<param name="pCompDefKey">The pointer to the component definition key.</param>
///<param name="name">Name to be given to component definition.</param>
AMIAPI AmiStatus amiSetCompDefName(AmiCompDefKey* pCompDefKey,
                   const ACHAR* name);

///<summary>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.</summary>
///<param name="def">Pointer to the component definition key for
///                          the component being inserted.</param>
///<param name="target">Pointer to the component definition key
///                          which will consume the new component.</param>
///<param name="matrix">WCS position for the component.</param>
///<param name="pCompKey">The pointer to the new component key.</param>
AMIAPI AmiStatus amiAddCompToCompDef(AmiCompKey*& pCompKey,
                   AmiCompDefKey* def, AmiCompDefKey* target,
                   const AcGeMatrix3d& matrix);

///<summary>Removes a component from a component definition. An
///              error is returned if the component does not   exist
///              within the component definition.</summary>
///<param name="pCompKey">The pointer to the component key to be removed.</param>
///<param name="pOwner">The pointer to the component definition key from which the component will be removed.</param>
AMIAPI AmiStatus amiRemoveCompFromCompDef(AmiCompKey* pCompKey,
                   AmiCompDefKey* pOwner);

///<summary>Checks if the component definition is an external component definition.</summary>
///<param name="pCompDefKey">The pointer to the component definition key.</param>
///<param name="external">True if external; false if local.</param>
AMIAPI AmiStatus amiIsCompDefExternal(AmiCompDefKey* pCompDefKey,
									  Adesk::Boolean& external);

///<summary>Checks if the given component definition is the master definition.</summary>
///<param name="pCompDefKey">The pointer to the component definition key.</param>
///<param name="master">Returns true if the component definition is the master.</param>
AMIAPI AmiStatus amiIsCompDefMaster(AmiCompDefKey* pCompDefKey,
									Adesk::Boolean& master);

///<summary>Checks if the component definition is that of a leaf node.</summary>
///<param name="pCompDefKey">The pointer to the component definition key.</param>
///<param name="leaf">True, if the component is a leaf node; false, if
///                     the component definition is not a leaf node.</param>
AMIAPI AmiStatus amiIsCompDefLeafNode(AmiCompDefKey* pCompDefKey,
                   Adesk::Boolean& leaf);

///<summary>Retrieves the name for the component specified by the
///              component key.  The user is responsible for releasing
///              the memory used by compName.</summary>
///<param name="pCompKey">The pointer to the component key.</param>
///<param name="compName">Name of component of the given key.</param>
AMIAPI AmiStatus amiGetCompName(AmiCompKey* pCompKey,
                   ACHAR*& compName);

///<summary>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.</summary>
///<param name="pCompKey">The pointer to the component key.</param>
///<param name="compName">Name of component of the given key.</param>
AMIAPI AmiStatus amiSetCompName(AmiCompKey* pCompKey,
                   const ACHAR* compName);

///<summary>Gets the component's definition. It is the caller�s
///              responsibility to release the key.</summary>
///<param name="pCompKey">Pointer to the component key.</param>
///<param name="pCompDefKey">Pointer to key to the component's
///                            definition.</param>
AMIAPI AmiStatus amiGetCompDef(AmiCompKey* pCompKey,
                   AmiCompDefKey*& pCompDefKey);

///<summary>Gets the definition to the component owning the
///              component passed-in. The user is responsible for releasing
///              the component definition key.</summary>
///<param name="pCompKey">The pointer to the component key.</param>
///<param name="pCompDefKey">The pointer to the component definition key.</param>
AMIAPI AmiStatus amiGetCompOwner(AmiCompKey* pCompKey,
                   AmiCompDefKey*& pCompDefKey);

///<summary>Returnsthe current WCS position of the component. .</summary>
///<param name="pCompKey">The pointer to the component key.</param>
///<param name="matrix">Actual position of component in current WCS
///              space.</param>
AMIAPI AmiStatus amiGetCompPosition(AmiCompKey* pCompKey,
                   AcGeMatrix3d& matrix);

///<summary>Sets the component to the new WCS position. All
///              instances of the component will also update accordingly.</summary>
///<param name="pCompKey">The pointer to the component key.</param>
///<param name="matrix">New WCS position for the component.</param>
AMIAPI AmiStatus amiSetCompPosition(AmiCompKey* pCompKey,
                   const AcGeMatrix3d& matrix);

///<summary>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.</summary>
///<param name="pCompKey">The pointer to the component key.</param>
///<param name="size">Number of component key pointers being returned.</param>
///<param name="pCompKeys">A pointer to an array of component key pointers.</param>
AMIAPI AmiStatus amiGetCompChildren(AmiCompKey* pCompKey,
                   long& size, AmiCompKey**& pKeys);

///<summary>Given a key to a component returns the key to the component
///              which is its corresponding component in its space of definition.</summary>
///<param name="pCompKey1">The pointer to the first component key.</param>
///<param name="pCompKey2">Pointer to corresponding component key.</param>
AMIAPI AmiStatus amiGetCompInDef(AmiCompKey* pCompKey1,
                   AmiCompKey*& pCompKey2);

///<summary>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).</summary>
///<param name="pObjKey">Pointer to object key.</param>
///<param name="pCompKey">Pointer to component key referencing the component that
///                         "contains" the object specified,</param>
AMIAPI AmiStatus amiGetContainingComp ( AmiObjectKey* pObjKey, AmiCompKey*& pCompKey );

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

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

///<summary>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.</summary>
///<param name="pDefKey">Component definition for which instances are returned.</param>
///<param name="pScopeKey">Context/scope for the search for instances.
///                  Only instances within this subassembly will be</param>
///<param name="numInstances">number of instances returned.</param>
///<param name="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.</param>
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 );

///<summary>Replace the component with a new definition</summary>
///<param name="pCompKey">Component to be replaced.</param>
///<param name="pNewDefKey">New definition to replace with.</param>
AMIAPI AmiStatus ami2DSReplaceCompDef( AmiCompKey* pCompKey, AmiCompDefKey* pNewDefKey);

///<summary>Create a copy of the definition for the specified component</summary>
///<param name="pCompKey">the component to be assigned the new definiton</param>
///<param name="newDefName">the new name of the definition, must be unique.</param>
AMIAPI AmiStatus ami2DSCopyCompDefinition(AmiCompKey* pCompKey, const ACHAR* newDefName);

///<summary>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.</summary>
///<param name="pCompKey">component key</param>
///<param name="fullPath">true: give full path name (XREF name)
///                         false: give stripped name</param>
///<param name="name">name of component definition</param>
AMIAPI AmiStatus ami2DSGetCompDefName(AmiCompDefKey* pCompDefKey,
										ACHAR*& name, const Adesk::Boolean& fullPath = Adesk::kFalse );


////////////////////////////////////////////////

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

///<summary>Remove entities from the parent view.</summary>
///<param name="entitiesToRemove">entities to remove.</param>
///<param name="pViewKey">the parent folder/component view key</param>
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 );

///<summary>Explode the specified folder or component view</summary>
///<param name="pFolderKey">the view / folder to be exploded.</param>
AMIAPI AmiStatus ami2DSExplodeView(AmiFolderKey * pFolderKey);

///<summary>Replace the folder with a new definition</summary>
///<param name="pFolderKey">Folder to be replaced.</param>
///<param name="pNewDefKey">New definition to replace with.</param>
AMIAPI AmiStatus ami2DSReplaceViewDef( AmiFolderKey* pFolderKey, AmiFolderDefKey* pNewDefKey);

///<summary>Create a copy of the definition for the specified folder or component view</summary>
///<param name="pFolderKey">the view / folder to be assigned the new definition</param>
///<param name="newDefName">the new name of the definition, must be unique.</param>
AMIAPI AmiStatus ami2DSCopyViewDefinition(AmiFolderKey * pFolderKey, const ACHAR* newDefName);

///<summary>Copy the entities to the folder / component view.</summary>
///<param name="entitiesToCopy">entities to copy.</param>
///<param name="pViewKey">destination folder / component view key</param>
AMIAPI AmiStatus ami2DSCopyEntitiesToView(AcDbObjectIdArray& entitiesToCopy, AmiObjectKey* pViewKey);

///<summary>Copy the specified view to the destination view</summary>
///<param name="pFolderToCopyKey">the view/folder to be copied.</param>
///<param name="pTargetKey">the target view/folder to copy to.</param>
AMIAPI AmiStatus ami2DSCopyViewToView(AmiFolderKey * pFolderToCopyKey, AmiFolderKey* pTargetKey);

///<summary>Retrieve the view scale</summary>
///<param name="pFolderKey">the view/folder to whose view scale is to be obtained.</param>
///<param name="curScale">the current view scale.</param>
AMIAPI AmiStatus ami2DSGetViewScale(AmiFolderKey * pFolderKey, double &curScale);

///<summary>Set the view scale</summary>
///<param name="pFolderKey">the view/folder to be scaled.</param>
///<param name="newScale">the scale to set to.</param>
AMIAPI AmiStatus ami2DSSetViewScale(AmiFolderKey * pFolderKey, double newScale);

///<summary>Set the view base point</summary>
///<param name="pFolderKey">the key of the folder or component view, whose base point is to be set.</param>
///<param name="basePt">the base point to set to.</param>
AMIAPI AmiStatus ami2DSSetViewBasePoint(AmiFolderKey* pFolderKey, const AcGePoint3d& basePt);

///<summary>Retrieve the view base point</summary>
///<param name="pFolderKey">the key of the folder or component view, whose base point is to be obtained.</param>
///<param name="basePt">the current base point.</param>
AMIAPI AmiStatus ami2DSGetViewBasePoint(AmiFolderKey* pFolderKey, AcGePoint3d& basePt);

///<summary>Checks whether the folder or component view has property override.</summary>
///<param name="pFolderKey">key of the view /folder to be checked.</param>
///<param name="bHasOverride">returns whether property overrides exist.</param>
AMIAPI AmiStatus ami2DSHasViewOverrideProperties(AmiFolderKey * pFolderKey, bool &bHasOverride);

///<summary>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.</summary>
///<param name="pFolderKey">the view to whose override is to be set.</param>
///<param name="bColor">true to set color and false to unset.</param>
///<param name="bContoursColorOnly">whether to set only only for contours.</param>
///<param name="trueColour">points to the color to set to. Can be null which will
///                           result in the colour value to be unchanged.</param>
AMIAPI AmiStatus ami2DSSetViewColorOverride(AmiFolderKey * pFolderKey,
                  bool bColor,
                  bool bContoursColorOnly,
                  const AcCmColor *trueColor = NULL);

///<summary>Set visibility overrides for the folder or component view.</summary>
///<param name="pFolderKey">the view to whose override is to be set.</param>
///<param name="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.</param>
///<param name="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.</param>
///<param name="bCenterLines">control centerline visibility.</param>
AMIAPI AmiStatus ami2DSSetViewVisibilityOverride(AmiFolderKey * pFolderKey,
                                           bool bContoursOnly,
                                           bool bHiddenLines,
                                           bool bCenterLines);

///<summary>Set predefined reference overrides for the folder or component view.</summary>
///<param name="pFolderKey">the view to whose override is to be set.</param>
///<param name="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).</param>
AMIAPI AmiStatus ami2DSSetViewPredefinedRefOverride(AmiFolderKey * pFolderKey,
                                             bool bPredefinedRef);

///<summary>Clear the override properties for the folder or component view.</summary>
///<param name="pFolderKey">the view whose override, if any, is to be clear.</param>
AMIAPI AmiStatus ami2DSClearViewOverrideProperties(AmiFolderKey * pFolderKey);

///<summary>Checks whether any of the component's view(/s) has property override.</summary>
///<param name="pCompKey">the component whose override is to be checked.</param>
///<param name="bHasOverride">returns whether property overrides exist.</param>
AMIAPI AmiStatus ami2DSHasCompOverrideProperties(AmiCompKey * pCompKey, bool &bHasOverride);

///<summary>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.</summary>
///<param name="pCompKey">the component to whose override is to be set.</param>
///<param name="bColor">true to set color and false to unset.</param>
///<param name="bContoursColorOnly">whether to set only only for contours.</param>
///<param name="trueColour">points to the color to set to. Can be null which will
///                           result in the colour value to be unchanged.</param>
AMIAPI AmiStatus ami2DSSetCompColorOverride(AmiCompKey * pCompKey,
                  bool bColor,
                  bool bContoursColorOnly,
                  const AcCmColor *trueColor = NULL);

///<summary>Set visibility overrides for the component. All the views of the
///              component will be affected.</summary>
///<param name="pCompKey">the component whose override is to be set.</param>
///<param name="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.</param>
///<param name="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.</param>
///<param name="bCenterLines">control centerline visibility.</param>
AMIAPI AmiStatus ami2DSSetCompVisibilityOverride(AmiCompKey * pCompKey,
                  bool bContoursOnly,
                  bool bHiddenLines,
                  bool bCenterLines);

///<summary>Set predefined reference overrides for the component.</summary>
///<param name="pCompKey">the component whose override is to be set.</param>
///<param name="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).</param>
AMIAPI AmiStatus ami2DSSetCompPredefinedRefOverride(AmiCompKey * pCompKey,
                  bool bPredefinedRef);

///<summary>Clear the override properties for the component.
///              All the component views associated with the component will have
///              their override properties, if any, clear.</summary>
///<param name="pCompKey">the component whose override is to be clear.</param>
AMIAPI AmiStatus ami2DSClearCompOverrideProperties(AmiCompKey * pCompKey);



//////
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);


///<summary>Create an annotation view and definition based on the specified component definition and component view definitions.</summary>
///<param name="pNewAnnotationViewDefKey">new annotation view definition that will be created.</param>
///<param name="pFolderInstKey">folder of the newly created annotation view.</param>
///<param name="position">Matrix to be used to position the new definition in WCS.</param>
///<param name="arMatrices">array of matrices for the new position of each of the new views.</param>
///<param name="pCompDefKey">component definition to base annotation on.</param>
///<param name="arCompViewDefKeys">array of component view definitions of pCompDefKey whose corresponding annotation view position are specified in arMatrices.</param>
///<param name="annotationViewName">name of annotation view e.g. COMP1(AV). Optional. If not
///                                   supplied, the system will fill in the appropriate name.</param>
///<param name="bCreateLabels">specifies whether to create labels for annotation view sub views, default is false</param>
///<param name="labelPattern">specifies label pattern for view labels valid only if bCreateLabels is true</param>
///<param name="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)</param>
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
                  );

///<summary>Extract the component definition that the annotation view is based on</summary>
///<param name="pViewDefKey">the annotation view def key.</param>
///<param name="pCompDefKey">the component definition.</param>
AMIAPI AmiStatus ami2DSGetAnnotationViewDefCompDef(AmiAnnotationViewDefKey* pViewDefKey, AmiCompDefKey*& pCompDefKey);

///<summary>Add an annotation view for the specified component view definition.</summary>
///<param name="pDefToInstance">component view definition whose annotation is to be created.</param>
///<param name="pTargetDefKey">the target annotation view definition that the new annotation will be added to.</param>
///<param name="position">new position of the annotation view.</param>
///<param name="pCompViewInstKey">points to the newly created annotation view.</param>
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);

///<summary>Remove the specified child view of the parent definition.</summary>
///<param name="pParentDefKey">the parent definition.</param>
///<param name="pCompViewKey">the child component view to be removed.</param>
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);

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

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

///<summary>Purge all annotation view definitions whose name matches the pattern.</summary>
///<param name="pNamePattern">Refer to the Object Arx documentation of 
///                             acutWcMatch() for details of the wildcard characters.
///                             Specify "*" to match everything.</param>

AMIAPI AmiStatus ami2DSPurgeAnnotationViewDefinitions(const ACHAR* pNamePattern = ACRX_T(/*MSG0*/"*"));

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

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

///<summary>Creates master view definition in the specified database.</summary>
///<param name="pMVD">Pointer to created or existing master view definition.</param>
///<param name="pDb">database where to create master view definition, if NULL working database is used.</param>
AMIAPI AmiStatus ami2DSCreateMasterViewDef(AmiFolderDefKey*& pMVD, AcDbDatabase* pDb = NULL);

///<summary>Check whether structure exists in the specified database.</summary>
///<param name="existsStructure">true if drawing contains view or folder definitions.</param>
///<param name="pDb">database to test, if NULL working database is used.</param>
AMIAPI AmiStatus ami2DSExistsStructure (Adesk::Boolean& existsStructure, AcDbDatabase* pDb = NULL);

////////////////////////////////////////////////
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
