confuzzled Posted September 9, 2010 Posted September 9, 2010 Hi. Right now, I am trying to return any layer name via debug.print function with the certain text in it. For example if there were 10 different layers then I only want to display layers containing the text string "local" in the layer name. Does anyone know how to go about doing this? Help is much appreciated. Quote
BIGAL Posted September 10, 2010 Posted September 10, 2010 (edited) You can access the layer table pretty easy just looking for it now and make a list of your layer names and then you can step through this list and search within each layer name for a match to your text and then do your thing using vla would be the way to go the layer name is a bit easier to retrive than old lisp. Found (tblnext "layer") repeated it will walk through your layers (cadr (tblnext "layer")) or (assoc 2 (tblnext "layer")) Search for any lee mac or alanjt program doing layer stuff here they will all read the layer table generally at the start. Sorry you want it in vba Dont have a layer but here is blocks layers are done similar FilterDXFCode(0) = 0 FilterDXFVal(0) = "INSERT" Set SS = ThisDrawing.SelectionSets.Add("mysel") SS.Select acSelectionSetAll, , , FilterDXFCode, FilterDXFVal For Cntr = 0 To SS.Count - 1 If SS.Item(Cntr).Name = BLOCK_NAME Then change this to look for your partial layer name Else: End If Next Cntr Edited September 10, 2010 by BIGAL added vba Quote
BlackBox Posted September 10, 2010 Posted September 10, 2010 While Visual LISP and VBA both use the ActiveX COM API, I am not versed in VBA syntax. However, using Visual LISP, this is one method (of many) to return a list of layer names containing 'local': (defun c:TEST (/ layerName layerList) (vl-load-com) (cond (*activeDoc*) ((setq *activeDoc* (vla-get-activedocument (vlax-get-acad-object))))) (vlax-for lay (vla-get-layers *activeDoc*) (if (wcmatch (setq layerName (strcase (vla-get-name lay))) "*LOCAL*") (setq layerList (cons layerName layerList)))) (setq layerList layerList)) ;_end defun Maybe one of the Guru's can offer you better advice...? (nothing against ya' Bigal) Hope this helps! Quote
confuzzled Posted September 10, 2010 Author Posted September 10, 2010 Alright thanks a lot. It works. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.