fathihvac Posted April 26, 2012 Posted April 26, 2012 Hello everybody§, Please help me correct this lisp. (defun c:TEST (/ layername) ;; FUNCTION FILTER SELECTION OF OBJECT ON SPECIFIC LAYER BY LINE TYPE (setq ent (car (entsel "\nSelect object to get its layer name : "))); (setq layername (cdr (assoc 8 (entget ent)))) (setq layerinf (tblsearch "LAYER" l_name)) (setq layerltype (cdr (assoc 6 layerinf))) (setq lay (list (cons 0 "*LINE")(cons 8 layername)(cons 6 layerltype))) ;; MAKE THE SELECTION SELECTION THEN ENTER AND OBJEST HIGHLIGHTED (princ) ) Quote
MSasu Posted April 26, 2012 Posted April 26, 2012 What do you want to achieve with that? Select an item, get his layer and after select all lines/polylines from that layer that have their linetype directly associated? Meantime, please add code tags to your excerpt. Quote
fathihvac Posted April 26, 2012 Author Posted April 26, 2012 i want to selest objects on one layer filtered by linetype. Some objests drawn by lines with "Continuous" linetype.and not by "DASHED" for example Quote
MSasu Posted April 26, 2012 Posted April 26, 2012 I have made some corrections to your code: (defun c:TEST ( / ent layername layerinf linetype lay index ) ;; FUNCTION FILTER SELECTION OF OBJECT ON SPECIFIC LAYER BY LINE TYPE (if (setq ent (car (entsel "\nSelect object to get its layer name : "))) (progn (setq layername (cdr (assoc 8 (entget ent)))) (setq layerinf (tblsearch "LAYER" layername)) (setq linetype (cdr (assoc 6 layerinf))) ;; MAKE THE SELECTION SELECTION THEN ENTER AND OBJEST HIGHLIGHTED (if (setq lay (ssget "_X" (list '(0 . "*LINE") (cons 8 layername) (cons 6 linetype)))) (progn (setq index 0) (repeat (sslength lay) (redraw (cdr (assoc -1 (entget (ssname lay index)))) 3) (setq index (1+ index)) ) ) ) ) ) (princ) ) Quote
MSasu Posted April 26, 2012 Posted April 26, 2012 True, simpler and more efficient! Especially when user intend to access the selection set outside his routine. I always forget about this function, maybe is time to stick it on the side of my display... Quote
Lee Mac Posted April 26, 2012 Posted April 26, 2012 @MSasu, Consider: (defun c:test ( / en la ) (if (setq en (car (entsel))) (progn (setq en (entget en) la (tblsearch "LAYER" (cdr (assoc 8 en))) ) (sssetfirst nil (ssget "_X" (list '(0 . "*LINE") (assoc 8 en) (assoc 6 la)))) ) ) (princ) ) Quote
fathihvac Posted April 26, 2012 Author Posted April 26, 2012 Thank you not working . select objects filtered by linetype on specific layer and keep them hightlighted to allow me make some modifications. Quote
SLW210 Posted April 26, 2012 Posted April 26, 2012 fathihvac, Please edit your post to include CODE TAGS! Quote
MSasu Posted April 26, 2012 Posted April 26, 2012 Thank you not working. Have you tried the one proposed by Lee Mac? Or may change the one changed by me considering Lee's observation. Quote
btraemoore Posted April 26, 2012 Posted April 26, 2012 (defun [color="red"]namedfunction[/color]( / ss_lay cnt i nm ent lt nlt) (setq ss_lay (ssget "X" (list (cons 0 "LINE")(cons 8 "[color="red"]layer name[/color]")))) (if ss_lay (progn (setq Cnt (sslength ss_lay)) (setq i 0) (repeat Cnt (setq NM (ssname ss_lay i)) (setq ENT (entget NM)) (setq LT (cdr (assoc 6 ent)) NLT "Continuous") (while (< i cnt) (if (= LT NLT) ([color="red"]what ever you want to do with the lines[/color]) );if );while (setq i (+ i 1)) );repeat );progn );if );defun Quote
Lee Mac Posted April 26, 2012 Posted April 26, 2012 Thank you not working . select objects filtered by linetype on specific layer and keep them hightlighted to allow me make some modifications. If the wrong objects are being selected, or nothing is selected then you will need to better describe the conditions for what needs to be selected. Quote
fathihvac Posted April 30, 2012 Author Posted April 30, 2012 (edited) Hello, Here again my code with more comments ,Please help me correct it. Edited April 30, 2012 by fathihvac Quote
SLW210 Posted April 30, 2012 Posted April 30, 2012 Once Again..... PLEASE READ CODE POSTING GUIDELINES!!! 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.