PDA

View Full Version : Create layer from files



pumpkin
2014-03-10, 08:36 PM
Hi



I need some help



I try to create list of layer from a files, but I don't understand the Do /While and I have a message error like missing information for the creation of layer



Ex. of my list files

;Layername, colour,linetype

*Layer1
layer1a,7,continuous
Layer1b,12,hidden

*layer2
layer2a,70,continous
Layer2b,82,hidden


The code I have from now



Dim sTemp As String
Dim sTemp1 As String
Dim nFile As Integer
Dim sLAYER As String
Dim sColor As String
Dim sLinetype As String

Dim objLayer As AcadLayer

sTemp = ListBox1.Text

nFile = FreeFile

Open sFile For Input As #nFile
While Not EOF(nFile)
Line Input #nFile, sTemp1
If sTemp1 = "*" & sTemp Then
Input #nFile, sLAYER, sColor, sLinetype
Set objLayer = ThisDrawing.Layers.Add(sLAYER)
objLayer.color = sColor
objLayer.Linetype = sLinetype
End If
Wend



So is there someone could tell me how fix it



Thanks!

arshiel88
2014-03-16, 07:36 AM
Its simply generating an error on the 2nd entry because Acad can't find the "continous"...its mispelled. And also, it will generate an error if the linetype isn't loaded, so you might want to add the code below. (taken from Help)




Dim entry As AcadLineType
Dim found As Boolean
found = False
For Each entry In ThisDrawing.Linetypes
If StrComp(entry.Name, "DASHDOT", 1) = 0 Then
found = True
Exit For
End If
Next
If Not (found) Then ThisDrawing.Linetypes.Load "DASHDOT", "acad.lin"