andyb57J Posted March 18 Posted March 18 (edited) Below is a section of code which we use to automatically colour code parcels based on their area. At present it automatically creates layers based on colour (ie Hatch_25512177). Is it possible to have it so it creates the layer based on the area as shown (ie Hatch_400 - 450) using the area1 values +.5 Sorry if I haven't explained it well 'but I hope you get what I mean. Also apologize that I cannot supply the full lisp routine which also colours lots based on frontage and/or frontage and depth but I am not the owner. (cond (( < area1 399.5) (setq col "255,121,77")) ((and( >= area1 399.5)(< area1 449.5)) (setq col "242,95,171")) ((and( >= area1 449.5)(< area1 549.5)) (setq col "253,134,206")) ((and( >= area1 549.5)(< area1 599.5)) (setq col "253,206,243")) ((and( >= area1 599.5)(< area1 699.5)) (setq col "242,187,166")) (( >= area1 699.5) (setq col "253,237,206")) ) (setq colx (vl-string-subst "" "," col)) (setq colx (vl-string-subst "" "," colx)) (setq lay (strcat "Hatch_" colx)) (command "layer" "new" lay "") (command "layer" "color" "truecolor" col lay "") (command "LAYER" "SET" lay "") (command "color" "bylayer") (command "-bhatch" "p" "solid" "s" name "" "") Edited March 18 by SLW210 Added Code Tags! Quote
SLW210 Posted March 18 Posted March 18 Please use Code Tags for your Code in the future, this will be your final warning. (just select <> in the Editor toolbar and put the code in the blank area and hit insert) Quote
pkenewell Posted March 18 Posted March 18 @andyb57J without your full code, I cannot say if this will work, but here is my modification to your snippet: ;;Added "lay" variable to the setq statement for each condition. ((and( >= area1 399.5)(< area1 449.5)) (setq col "242,95,171" lay "Area_400-450")) ((and( >= area1 449.5)(< area1 549.5)) (setq col "253,134,206" lay "Area_450-550")) ((and( >= area1 549.5)(< area1 599.5)) (setq col "253,206,243" lay "Area_550-600")) ((and( >= area1 599.5)(< area1 699.5)) (setq col "242,187,166" lay "Area_600-700")) Quote
ronjonp Posted March 18 Posted March 18 @pkenewell FWIW, all the range checks could be shortened to this. No need for AND (<= 399.5 area1 449.5) 1 Quote
pkenewell Posted March 18 Posted March 18 On 3/18/2025 at 8:28 PM, ronjonp said: @pkenewell FWIW, all the range checks could be shortened to this. No need for AND (<= 399.5 area1 449.5) Expand Sure they could. I was just answering the OP specifically for what he was asking for, with his own code. I would address your improvement to the OP as well. Quote
andyb57J Posted March 18 Author Posted March 18 On 3/18/2025 at 1:20 PM, pkenewell said: @andyb57J without your full code, I cannot say if this will work, but here is my modification to your snippet: ;;Added "lay" variable to the setq statement for each condition. ((and( >= area1 399.5)(< area1 449.5)) (setq col "242,95,171" lay "Area_400-450")) ((and( >= area1 449.5)(< area1 549.5)) (setq col "253,134,206" lay "Area_450-550")) ((and( >= area1 549.5)(< area1 599.5)) (setq col "253,206,243" lay "Area_550-600")) ((and( >= area1 599.5)(< area1 699.5)) (setq col "242,187,166" lay "Area_600-700")) Expand thankyou - This works perfectly Quote
Lee Mac Posted March 18 Posted March 18 On 3/18/2025 at 8:28 PM, ronjonp said: @pkenewell FWIW, all the range checks could be shortened to this. No need for AND (<= 399.5 area1 449.5) Expand Or just to - (setq col (cond ((< area1 399.5) "255,121,77") ((< area1 449.5) "242,95,171") ((< area1 549.5) "253,134,206") ((< area1 599.5) "253,206,243") ((< area1 699.5) "242,187,166") ("253,237,206") ) ) 1 Quote
ronjonp Posted March 19 Posted March 19 On 3/18/2025 at 9:54 PM, Lee Mac said: Or just to - (setq col (cond ((< area1 399.5) "255,121,77") ((< area1 449.5) "242,95,171") ((< area1 549.5) "253,134,206") ((< area1 599.5) "253,206,243") ((< area1 699.5) "242,187,166") ("253,237,206") ) ) Expand Very true. Glad to see you posting more Lee. 2 Quote
pkenewell Posted March 19 Posted March 19 On 3/18/2025 at 9:54 PM, Lee Mac said: Or just to - (setq col (cond ((< area1 399.5) "255,121,77") ((< area1 449.5) "242,95,171") ((< area1 549.5) "253,134,206") ((< area1 599.5) "253,206,243") ((< area1 699.5) "242,187,166") ("253,237,206") ) ) Expand @Lee Mac Agreed. Although personally I would have done it like RonJonP just for readability; when I'm trying to understand the code I wrote later. I don't mean it's the best way - just how I prefer Quote
andyb57J Posted Friday at 01:38 PM Author Posted Friday at 01:38 PM On 3/19/2025 at 4:10 PM, pkenewell said: @Lee Mac Agreed. Although personally I would have done it like RonJonP just for readability; when I'm trying to understand the code I wrote later. I don't mean it's the best way - just how I prefer Expand In the original portion of the lisp that I supplied could you please show me where I can add the code to add 30% transparency to each of the layers created. Personally I do this after the case in the Layers Properties Manager and but users have asked if it could be added at the creation stage Quote
ronjonp Posted Friday at 02:23 PM Posted Friday at 02:23 PM After the layer is created add this line to set 30% transparency: (entmod (append (entget (tblobjname "layer" lay)) '((-3("AcCmTransparency" (1071 . 33554610)))))) 1 Quote
Lee Mac Posted Friday at 06:53 PM Posted Friday at 06:53 PM Where layer transparency is concerned, this may be of interest - https://www.theswamp.org/index.php?topic=52473.msg574001#msg574001 3 Quote
andyb57J Posted Friday at 11:57 PM Author Posted Friday at 11:57 PM On 3/21/2025 at 2:23 PM, ronjonp said: After the layer is created add this line to set 30% transparency: (entmod (append (entget (tblobjname "layer" lay)) '((-3("AcCmTransparency" (1071 . 33554610)))))) Expand thankyou - is perfect Quote
ronjonp Posted Saturday at 04:23 PM Posted Saturday at 04:23 PM On 3/21/2025 at 11:57 PM, andyb57J said: thankyou - is perfect Expand 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.