keebo Posted January 15, 2020 Posted January 15, 2020 I'm looking to pick objects and have their layers set to no plot. I dont have a full working understanding of Lisp (or any programming), but I've generally managed to fudge things together based on others hard work and some trial and error.... But not this time!! More often than not i'll be selecting entities nested within a block/xref, so have been looking at doing it via (vla-put-Plottable objectLayer :vlax-False) But this is my first foray in to VLA, and I can't get my head around the object grouping & syntax order. I've tried lots of variations, so this might not be the 'closest' I've come, but the autocad error isnt really helping me figure things out. Currently I have; (defun c:NoP ( / doc enm obj objLayer) (setq doc (vla-get-activedocument (vlax-get-acad-object))) (while (setq enm (car (nentsel))) (setq obj (vlax-ename->vla-object enm)) (setq objLayer (vla-get-layer obj)) ) (vla-put-Plottable objLayer :vlax-False) (princ) ) The autocad error returns the correct Layer name, but it's obviously not getting it the way I want it to. Select object: ; error: bad argument type: VLA-OBJECT "LayerName" Do I need to look at retrieving a full list of layers at some point? Is it failing because the Command is set up to get a list of layers, but then I'm processing it as if there's only one? Thanks in advance for any pointers! Quote
Tharwat Posted January 15, 2020 Posted January 15, 2020 Hi, DXF is much faster than vlisp and simpler so give this a shot. (defun c:unplot ( / sel int ent get plt) ;; Tharwat - 15.Jan.2020 ;; (and (setq int -1 sel (ssget)) (while (setq int (1+ int) ent (ssname sel int)) (setq get (entget (tblobjname "LAYER" (cdr (assoc 8 (entget ent))))) plt (assoc 290 get) ) (or (= 0 (cdr plt)) (entmod (subst '(290 . 0) plt get)) ) ) ) (princ) ) Quote
keebo Posted January 15, 2020 Author Posted January 15, 2020 (edited) That's similar to where I started. But unfortunately I'll mostly be using it for items within blocks and xrefs, and that just selects the layer that the xref is on, rather than the nested object's layer. Thanks for taking a look though! e: I initially tried including :V or :N with the ssget, but couldnt get anywhere with it. Edited January 15, 2020 by keebo Quote
Tharwat Posted January 15, 2020 Posted January 15, 2020 If you are looking for a nested objects then you need to use either of the two functions nentsel or nentselp and both of them with single and direct pick on an object so you can modify the codes to do so and just ask if you stuck somewhere with the codes. Quote
keebo Posted January 15, 2020 Author Posted January 15, 2020 (edited) Yeah, in my OP I'm using nentsel, and the selection portion seems to work fine and returns the layer name, but I then get the mentioned error. I'm tending to think the selection process is forming a list but (vla-put-Plottable objLayer :vlax-False) is using a single entity as its input? But like I say I've no programming background besides tinkering. E: Have received help elsewhere. The following works as I hoped. (defun c:NoP ( / doc lyrs enm lyr l_obj) (setq doc (vla-get-activedocument (vlax-get-acad-object)) lyrs (vla-get-layers doc) ) (while (setq enm (car (nentsel))) (setq lyr (vla-get-layer (vlax-ename->vla-object enm)) l_obj (vla-item lyrs lyr) ) (vla-put-Plottable l_obj :vlax-False) );end_while (princ) ) Edited January 15, 2020 by keebo Solved: 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.