Simon1976 Posted May 14, 2016 Share Posted May 14, 2016 Hello all I have created a lisp to modify sub entities of block(s) using the tblobjname "block" bkn (while ent (entnext method & it works very well. BUT I wish it to ignore sub entities on frozen layers possibly using something like the following psuedo code: (if (not "FROZEN LAYER") [obviously using the appropriate assoc function] THEN: Modify sub entities as required Is there a DXF code added to an entity when a layer is frozen? If so then I cannot find it. I created a new drawing, drew a line on a new layer, then froze that new layer. Then (setq s (ssget "_X" )) (entget (ssname s 0)) to retrive the DXF codes for that one entity The DXF code list is the same whether or not the layer is frozen Alternatively is there a vl function to detect whether an entity is on a frozen layer? Quote Link to comment Share on other sites More sharing options...
Tharwat Posted May 14, 2016 Share Posted May 14, 2016 Hi, Firstly retrieve the Layer name then retrieve the DXF codes for that layer from the tblobjname and have a look about the DXF 70 Have a look at this LINK Quote Link to comment Share on other sites More sharing options...
Simon1976 Posted May 14, 2016 Author Share Posted May 14, 2016 Sorry I don't follow you. How does one extract the DXF data from a layer name exactly? Ideally it needs to be added to the line using an and: (if (not (eq(cdr(assoc 8 tblentx)) "NO PRINT")) "NO PRINT" is a layer we use for the users benefit & which is set to non printing BTW My code: (defun c:test ( / bln blnlst ent idx mess1 n ss tblent tblentx) (command "UNDO" "BE") (Setq ss (ssget "_:L" '((0 . "INSERT")))) (if ss (progn (command "change" ss "" "P" "LA" "0" "") (repeat (setq idx (sslength ss)) (setq idx (1- idx) ent (ssname ss idx) bln (cdr (assoc 2 (entget ent)))) ;; get the BLOCK name (if (not(member bln blnlst)) ;; check to see if block name has already been added (setq blnlst (cons bln blnlst)) ;; Build a list of unique block names from the ssget ) ) (repeat (setq n (length blnlst)) (setq n (1- n)) (setq tblent (tblobjname "block" (nth n blnlst))) ;; get the block entity name from the block name list (while (setq tblent (entnext tblent)) ;; Step through the entities in the block definition (setq tblentx (entget tblent)) ;; DXF codes for tblent (if (assoc 6 tblentx) ;;; if assoc 6 [linetype] exists (setq tblentx (subst '(6 . "BYLAYER") (assoc 6 tblentx) tblentx));;;THEN set linetype to "BYLAYER" (setq tblentx (append tblentx '((6 . "BYLAYER"))));;;ELSE add assoc 6 to list & set linetype to "BYLAYER" ) (if (assoc 48 tblentx) ;;; if assoc 48 [ltscale] exists (setq tblentx (subst '(48 . 1) (assoc 48 tblentx) tblentx));;; THEN set LTSCALE to 1 (setq tblentx (append tblentx '((48 . 1)))) ;;;ELSE add assoc 48 to list & set LTSCALE to 1 ) (if (assoc 62 tblentx) ;;; if assoc 62 [colour] exists (setq tblentx (subst '(62 . 256) (assoc 62 tblentx) tblentx));;; THEN set colour to 256 which is "BYLAYER" (setq tblentx (append tblentx '((62 . 256)))) ;;;ELSE add assoc 62 to list & set colour to 256 which is "BYLAYER" ) (entmod tblentx) (if (not (eq(cdr(assoc 8 tblentx)) "NO PRINT")) ;; exclude all items on layer "NO PRINT" (if (eq (cdr(assoc 0 tblentx)) "ATTDEF") ;;; if tblentx is an attribute & not on layer NO PRINT (progn ;;; THEN put attrbutes on layer ATTRIBUTES (setvar 'expert 3) (command "-layer" "m" "ATTRIBUTES" "c" "2" "" "" ) ;; Make layer ATTRIBUTES (setvar 'expert 0) (setvar 'clayer "0") ;; Set layer back to 0 (entmod (subst '( 8 . "ATTRIBUTES") (assoc 8 tblentx) tblentx));; Change layer of attributes to "ATTRIBUTES" );; progn (entmod (subst '(8 . "0") (assoc 8 tblentx) tblentx));; ELSE change layer of non attribute items to "0" ) );;; if not layer "NO PRINT" ) ;; end WHILE (command "_.attsync" "_n" (nth n blnlst)) ) );; progn if ss (setq mess1 t) );; if ss (command "_regen") (command "UNDO" "END") (if mess1 (princ "\nNo Blocks Selected")) (princ) ) There's lots of tidying up yet to be done BTW! Quote Link to comment Share on other sites More sharing options...
Tharwat Posted May 14, 2016 Share Posted May 14, 2016 An example: (setq LayerName (cdr (assoc 8 (entget <entityName>)))) (eq 1 (logand 1 (cdr (assoc 70 (entget (tblobjname "LAYER" LayerName)))))) ;; 1 = Frozen Quote Link to comment Share on other sites More sharing options...
Simon1976 Posted May 15, 2016 Author Share Posted May 15, 2016 Oh I seeee A few experiments have clarified it for me Thank you very much Tharwat Quote Link to comment Share on other sites More sharing options...
Tharwat Posted May 15, 2016 Share Posted May 15, 2016 Excellent. You are most welcome Simon. Quote Link to comment Share on other sites More sharing options...
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.