Jump to content

Recommended Posts

Posted (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 by SLW210
Added Code Tags!
Posted

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)

Posted

@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"))

 

Posted

@pkenewell FWIW, all the range checks could be shortened to this. No need for AND

(<= 399.5 area1 449.5)

 

  • Like 1
Posted
  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.

Posted
  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

Posted
  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")
    )
)

 

  • Like 1
Posted
  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. :beer:

  • Like 2
Posted
  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 🙂

Posted
  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

Posted

After the layer is created add this line to set 30% transparency:
 

(entmod (append (entget (tblobjname "layer" lay)) '((-3("AcCmTransparency" (1071 . 33554610))))))

 

  • Like 1
Posted
  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

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...