Aliases.Add method

AutoCAD Map 3D ActiveX

Aliases.Add method

Defines a drive alias.

Add(AliasName As String, AliasPath As String) As Alias

Returns the new drive alias.

AliasName

Name of the alias.

The name must be unique, use only alphanumeric characters (including hyphen and underscore), contain no spaces or colons, start with a character, and not exceed 31 characters.

AliasPath

An existing path that the alias represents.

If the path represented by AliasPath does not exist, the Add method does not create an alias. Trying to add an alias of the same name as an existing one causes an error.

The following example checks for an alias of the same name before adding an alias for the Temp directory called SHAREDDRIVE.

Dim als As Alias

Dim amap As AcadMap

Dim cAls As Integer, i As Integer

Dim strAlsName As String

Dim boolAlsOK As Boolean

 

boolAlsOK = True

strAlsName = "SHAREDDRIVE"

Set amap = ThisDrawing.Application. _

GetInterfaceObject("AutoCADMap.Application") 

cAls = amap.aliases.Count

For i = 0 To cAls - 1

Set als = amap.aliases.Item(i) 

If als.Name = strAlsName Then 

Debug.Print "Alias already exists" 

boolAlsOK = False 

End If 

Next i

If boolAlsOK = True Then

Set als = amap.aliases.Add(strAlsName, "C:\\Temp") 

End If