Name Property (IAttributeDefinition)

Name Property (IAttributeDefinition) | Send Feedback
See Also Example

Gets or sets the BlockAttribute name.

# Syntax

Visual Basic |
--- | ---
    Property Name As System.String

C# |
--- | ---
    System.string Name {get; set;}

JavaScript |
--- | ---
    get_Name () : String
    put_Name (
       NewVal : String
    )

COM native C++ |
--- | ---
    HRESULT get_Name(
       BSTR* Val
    )
    HRESULT put_Name(
       BSTR NewVal

C++ |
--- | ---
    DSRESULT get_Name (
       dsString* Val
    )
    DSRESULT put_Name(
       const dsString& NewVal
    )

#### Property Value

Name of the BlockAttribute

# Example

This code snippet shows how to write the captions, names, and values of the BlockAttribute definitions to a file.

#### COM native C++

void CAddinDumpManager::DumpAttributeDefinitions( CStdioFile& fileOutput, LPCWSTR tabStr, IBlockDefinitionPtr blkDefs )
{
CString strPrint;
_variant_t pVariantArrayAD = blkDefs->GetAttributeDefinitions();
if( V_VT( &pVariantArrayAD ) != VT_EMPTY )
{
IAttributeDefinitionPtr *blkAttDefs = NULL;
int countOfAttDefs = 0;
TypeConverter::convertVariantArrayToPtrArray<IAttributeDefinitionPtr, IAttributeDefinition>( pVariantArrayAD, blkAttDefs, countOfAttDefs );

strPrint.Format( L"\tAttribute definitions (%d):\r\n", countOfAttDefs );
fileOutput.WriteString( strPrint );

if( blkAttDefs && countOfAttDefs > 0)
{
for( int i = 0; i < countOfAttDefs; ++i )
{
bstr_t AttDefCaption= blkAttDefs[i]->GetCaption();
strPrint.Format( L"\tCaption: %s\r\n", AttDefCaption.operator const wchar_t*() );
fileOutput.WriteString( strPrint );

bstr_t AttDefName= blkAttDefs[i]->GetName();
strPrint.Format( L"\tName: %s\r\n", AttDefName.operator const wchar_t*() );
fileOutput.WriteString(strPrint);

bstr_t AttDefValue= blkAttDefs[i]->GetValue();
strPrint.Format( L"\tValue: %s\r\n", AttDefValue.operator const wchar_t*() );
fileOutput.WriteString( strPrint );

}
delete[] blkAttDefs;
}
else
fileOutput.WriteString( L"\tERROR GetAttributeDefinitions\r\n" );
}
else
fileOutput.WriteString( L"\tERROR GetAttributeDefinitions\r\n" );
}

This code snippet shows how to write the name, caption, and value of the BlockAttribute definition to a file, if the selected object is an IAttributeDefinition object.

#### COM native C++

long selCount = dsSelManager->GetSelectedObjectCount( dsSelectionSetType_Current );
strPrint.Format( L"Selected objects: (%d):\r\n", selCount );
fileOutput.WriteString( strPrint );

if( selCount > 0 )
{
for( long i = 0; i < selCount; ++i )
{
//Get selected object type
dsObjectType_e retObjType;
IDispatchPtr selObj = dsSelManager->GetSelectedObject( dsSelectionSetType_Current, i, &retObjType );

//If selected object is BlockAttribute definition
if( dsAttributeDefinitionType == retObjType )
{
IAttributeDefinitionPtr AttDefs( selObj );

//Get BlockAttribute definition name
bstr_t AttDefName = AttDefs->GetName();

strPrint.Format( L"Attribute definition (%s) \r\n", AttDefName.operator const wchar_t*() );
fileOutput.WriteString( strPrint );

//Get BlockAttribute definition caption
bstr_t AttDefCaption = AttDefs->GetCaption();

strPrint.Format( L"\tCaption: %s\r\n", AttDefCaption.operator const wchar_t*() );
fileOutput.WriteString( strPrint );

strPrint.Format( L"\tName: %s\r\n", AttDefName.operator const wchar_t*() );
fileOutput.WriteString( strPrint );
//Get BlockAttribute definition value
bstr_t AttDefValue = AttDefs->GetValue();

strPrint.Format( L"\tValue: %s\r\n", AttDefValue.operator const wchar_t*() );
fileOutput.WriteString( strPrint );

# Example

Get and Set Block Definitions, Block Instances, and BlockAttribute Instances (C#)
Get and Set Block Definitions, Block Instances, and BlockAttribute Instances (VB.NET)
Get and Set Block Definitions, Block Instances, and BlockAttribute Instances (VBA)

# See Also

####

IAttributeDefinition Interface
IAttributeDefinition Members

# Availability

DraftSight V1R1