Hi, Is it possible to write a code to print all layer's names. Thanks, A.K.
It was much better if I could first see them in a msgbox then send the contents of that msgbox to the printer. Thanks.
Here is the quick and dirty way. Public Sub ListLayers() Dim oLayer As AcadLayer For Each oLayer In ThisDrawing.Layers Debug.Print oLayer.Name Next oLayer End Sub Then highlight everything in the immediate window [Ctrl-A]. C/P it to Notepad and print it. If you need a more substantial and permanently method then let me know. Joe
If you want the layer names sorted, you'll need to add them to an array or collection & process accordingly. Alternatively, you could always import this text file into excel and do a quick sort there... Code: Sub listem_V2() Dim oLYR As AcadLayer Dim strTemp As String Dim strFullFileName As String 'output filename & path ' must make sure any directory(s) you specify here exist already strFullFileName = "g:\MyNewTest.TXT" strTemp = strTemp & "Begin Layer Listing" & vbNewLine 'ThisDrawing.Utility.Prompt "Begin Layer Listing" 'AcadApplication.Update For Each oLYR In ThisDrawing.Layers 'Debug.Print oLYR.Name 'ThisDrawing.Utility.Prompt oLYR.Name 'AcadApplication.Update strTemp = strTemp & oLYR.Name & vbNewLine Next 'output to file WriteStringToFile strFullFileName, strTemp ' view in notepad SendFileToNotePad strFullFileName End Sub Sub WriteStringToFile(pFileName As String, pString As String) Dim intFileNum As Integer intFileNum = FreeFile Open pFileName For Output As intFileNum Print #intFileNum, pString Close intFileNum End Sub Sub SendFileToNotePad(pFileName As String) Dim lngReturn As Long lngReturn = Shell("NOTEPAD.EXE " & pFileName, vbNormalFocus) End Sub
Oberer, Can I also have information like COLOR,ON and OFF ,FREEZE & Etc. of each layer on that list ? Thanks A.K.
Change this line: strTemp = strTemp & oLYR.Name & vbNewLine to this line: strTemp = strTemp & oLYR.Name & "," & oLYR.Color & "," & oLYR.Linetype & "," & oLYR.Freeze & "," & oLYR.LayerOn & vbNewLine This will create a comma delimited file with layer name, color, linetype, freeze state (expressed as boolean), on/off state (expressed as boolean) -- I support two teams: The Red Sox and whoever beats the Yankees.
That is slick! Man could I have used that many-a-time in the past! -- I support two teams: The Red Sox and whoever beats the Yankees.
It's folks like you Joe who keep me coming back. There's SO much to learn. Very nice utliity. One request? How would i had the word app until it's finished formatting? I'm working with acad 2k2 and ld3 on xp sp 2, p4 3.6, 2 gigs of ram and the table formatting was kinda slow. I didn't realize it wasn't finished until i get a few more hourglasses...