Import/Export File Data.
This application will show you how to Import and Export Data to and
from external text files. The dialogue box contains two list boxes.
The first contains a list of all the layers contained in the current
drawing.
By selecting the Export Layers button, the layer names will be written to
file ExLayers.txt.
Selecting the Layers Import button will bring in a list of layers
contained
in the file InLayers.txt.
Note : Please ensure that all the files are in the same directory and
within
your AutoCAD support path. Thanks :-))
You will need to create a new form with 2 list boxes and 3 buttons.
Keep the default names. Now create a new form and add this coding :
Option Explicit
Private Sub CommandButton1_Click()
Dim objLayer As AcadLayer
Dim Lname As String
'declare variables
Open "Exlayer.txt" For Output As #1
'open text file
For Each objLayer In ThisDrawing.Layers
'start looping thru' the layer names
Lname = objLayer.Name
'get the layer name
Print #1, Lname
'print it to the file
Next
Close #1
'close the file
Unload Me
'unload dialogue
End Sub
Private Sub CommandButton2_Click()
End
End Sub
Private Sub CommandButton3_Click()
Dim sTemp As String
'declare variable
ListBox2.Clear
'clear the listbox
Open "Inlayer.txt" For Input As #1
'open the external file
While Not EOF(1)
'until the end of file is reached
Line Input #1, sTemp
'get a layer name
ListBox2.AddItem sTemp
'add it to the list box
Wend
Close #1
'close the file
End Sub
Private Sub UserForm_Initialize()
Dim objLayer As AcadLayer
'declare variables
For Each objLayer In ThisDrawing.Layers
'get the layer names and loop thru' them
ListBox1.AddItem objLayer.Name
'add them to the list box
Next
End Sub
Now create a new module and add this coding :
Sub EILayer()
UserForm1.Show
End Sub
Now run the macro "EILayer.....Good Hey!!!
If you would like to download the source code for this Application/s, then
click Here |