VB created Layer Filters

VB created Layer Filters

Anonymous
Not applicable
270 Views
1 Reply
Message 1 of 2

VB created Layer Filters

Anonymous
Not applicable
Hi. Heres what I found and being that I am not that versed on VB I am having a hard time on getting to do what I want.

Linked from
http://discussion.autodesk.com/forums/message.jspa?messageID=6118662#6118662

Sub CreateXrefLayerFilter()
Dim xRec As AcadXRecord
Dim oDict1 As AcadDictionary, oDict2 As AcadDictionary
Dim xtype(0 To 6) As Integer
Dim xvalue(0 To 6) As Variant
Dim name As String

name = "Non-Xref layers" 'Filter name
xtype(0) = 1: xvalue(0) = name 'Filter Name:
xtype(1) = 1: xvalue(1) = "~*|*" 'Layer Name
xtype(2) = 1: xvalue(2) = "*" 'Color
xtype(3) = 1: xvalue(3) = "*" 'Lineyype
xtype(4) = 70: xvalue(4) = 0 'DXF (0 Both (On/Off) + 0 Both (Frz/Thaw) = 0)
xtype(5) = 1: xvalue(5) = "*" 'Lineweight
xtype(6) = 1: xvalue(6) = "*" 'PlotStyle

Set oDict1 = ThisDrawing.Layers.GetExtensionDictionary
Set oDict2 = oDict1.AddObject("ACAD_LAYERFILTERS", "AcDbDictionary")
Set xRec = oDict2.AddXRecord(name)
xRec.SetXRecordData xtype, xvalue
ThisDrawing.Utility.Prompt "Layer Filter Added" & vbCrLf
End Sub

I would like the layer filter to be able to have more then one record. For example a Layer Filter lets call it Arch, and for it to filter everything thats name has *Wall, and *Room Title, and for good measure *Arch. I tried a few things but everything I did either made AutoCad not create a layerfilter or would just not do anything. I would love to understand how this code works instead of getting a new snippet of code. Thanks for the help and I hope to hear back from you guys.

--Zac
0 Likes
271 Views
1 Reply
Reply (1)
Message 2 of 2

Anonymous
Not applicable
using the same code replace xtype(1) = 1: xvalue(1) = "*arch,*wall,*room title" ' separate Layer Names with commas
0 Likes