Jump to content

Recommended Posts

Posted

I have used the attached lisp for a few years now to classify parcels based on the parcel frontage and depth.  It has worked well for me and provided the results I was looking for i.e. parcels hatched on separate layers based on a set of conditions with the lisp creating the required layers if they did not exist in the drawing.  My only downfall is that the frontage and depth of each parcel had to be manually selected and then a point inside each parcel had to be selected before the parcel could be hatched, which when faced with developments that contained a large number of parcels was very time consuming.  I was wondering if the lisp routine could be modified so that all processes were autonomise, whilst generally retaining most of the current routine, particularly the conditions and layer structuring.

 

I generally see the user firstly selecting all the closed polylines within a drawing and the routine the obtaining the distances between each vertice.  The shortest of these distances would be identified as the frontage (mfront).  The depth would be the mean between the two longest distances i.e (longest/second longest)/2, (mdepth).

 

To eliminate errors I would like the routine to bypass all polylines with more than 4 vertices as these would generally be corner parcels or irregularly shaped parcels and the shortest distance would not be the true frontage.  These parcels can be manually classified using the original lisp.

 

The routine would then use the current conditions to create the necessary layer is not present in the drawing and hatch the current enclosed polyline with a solid colored hatch, then move to the next enclosed polyline and continue until all enclosed polylines have been completed.

 

I hope I have explained it clearly enough.  I have tried modifying it myself and have also used AI, which to some extent worked, but I wish to retain the current code as stated as much as possible.

 

I have also attached a drawing which can be used.

 

 

;hatch lots based on both Frontage and Depth with RGB colours

(defun c:hl4(/ Mfront Mdepth P1 DN DE col lay pt1 pt2 pt3 Mdst colx layx)
	;

	(setvar "cmdecho" 0)

	(setq pt1 (getpoint "\nSelect first frontage point (Right click to exit) : "))
	(if (/= nil pt1)(setq pt2 (getpoint "\nSelect second frontage point (Right click to exit) : ")))
	(if (/= nil pt2)(setq pt3 (getpoint "\nSelect depth point (Right click to exit) : ")))
	
	
	;find frontage
	(setq DN (-(cadr Pt2) (cadr Pt1)))
	(setq DE (-(car Pt2) (car Pt1)))
	(setq Mfront (sqrt(+(* DE DE)(* DN DN))))

	;find depth
	(setq DN (-(cadr Pt3) (cadr Pt2)))
	(setq DE (-(car Pt3) (car Pt2)))
	(setq Mdepth (sqrt(+(* DE DE)(* DN DN))))
	
	(setq col 1)	

	(cond
	;Terrace lots < 7.5m frontage - Change TE to TF for front loaded lots and TE to TR for rear loaded terraces.  
	(( <= Mfront 7.49949)
	
		(cond
		;depth range 
		((<= Mdepth 24.99949)	(setq col "198,110,78" lay "TE_(F)-7.5m_(D)-25m"))
		((<= Mdepth 27.99949) 	(setq col "192,76,54" lay "TE_(F)-7.5m_(D)25m"))
		((<= Mdepth 29.99949) 	(setq col "183,49,44" lay "TE_(F)-7.5m_(D)28m"))
		((<= Mdepth 31.99949) 	(setq col "171,35,40" lay "TE_(F)-7.5m_(D)30m"))
		((<= Mdepth 35.99949) 	(setq col "147,39,44" lay "TE_(F)-7.5m_(D)32m"))
		(( > Mdepth 35.99949)	(setq col "138,42,43" lay "TE_(F)-7.5m_(D)36m"))
		)						
	)
	;Terrace Lots 7.5m frontage - Change TE to TF for front loaded lots and TE to TR for rear loaded terraces.
	((and(<= Mfront 7.50049 )) 
	
		(cond
		;depth range
		((<= Mdepth 24.99949)   (setq col "104,101,159" lay "TE_(F)7.5m_(D)-25m"))
		((<= Mdepth 27.99949)   (setq col "97,94,155" lay "TE_(F)7.5m_(D)25m"))
		((<= Mdepth 29.99949)   (setq col "86,82,148" lay "TE_(F)7.5m_(D)28m"))
		((<= Mdepth 31.99949)   (setq col "81,70,137" lay "TE_(F)7.5m_(D)30m"))
		((<= Mdepth 35.99949)   (setq col "76,65,132" lay "TE_(F)7.5m_(D)32m"))
		(( > Mdepth 35.99949)   (setq col "83,84,74" lay "TE_(F)7.5m_(D)36m"))
		)
	)
	
	;Terrace Lots between 7.5m and 10.5m frontage - Change TE to TF for front loaded lots and TE to TR for rear loaded terraces.
	((<= Mfront 10.49949)
	
		(cond
		;depth range
		((<= Mdepth 24.99949)   (setq col "186,187,177" lay "TE_(F)7.5m+_(D)-25m"))
		((<= Mdepth 27.99949)   (setq col "168,169,158" lay "TE_(F)7.5m+_(D)25m"))
		((<= Mdepth 29.99949)   (setq col "145,147,136" lay "TE_(F)7.5m+_(D)28m"))
		((<= Mdepth 31.99949)   (setq col "126,127,116" lay "TE_(F)7.5m+_(D)30m"))
		((<= Mdepth 35.99949)   (setq col "101,102,92" lay "TE_(F)7.5m+_(D)32m"))
		(( > Mdepth 35.99949)   (setq col "81,83,74" lay "TE_(F)7.5m+_(D)36m"))
		)
	)
	
	;Standard Lots between 10.5m and 12.5m frontage
	((<= Mfront 12.49949)
	
		(cond
		;depth range
		((<= Mdepth 24.99949)   (setq col "169,133,132" lay "_V_(F)10.5m_(D)-25m"))
		((<= Mdepth 27.99949)   (setq col "129,107,183" lay "_V_(F)10.5m_(D)25m"))
		((<= Mdepth 29.99949)   (setq col "138,52,83" lay "_V_(F)10.5m_(D)28m"))
		((<= Mdepth 31.99949)   (setq col "245,101,83" lay "_V_(F)10.5m_(D)30m"))
		((<= Mdepth 35.99949)   (setq col "116,72,57" lay "_V_(F)10.5m_(D)32m"))
		(( > Mdepth 35.99949)   (setq col "54,114,142" lay "_V_(F)10.5m_(D)36m"))
		)
	)
	
	;Standard Lots between 12.5m and 14.0m frontage
	((<= Mfront 13.99949)
	
		(cond
		;depth range
		((<= Mdepth 24.99949)   (setq col "181,149,148" lay "PV_(F)12.5m_(D)-25m"))
		((<= Mdepth 27.99949)   (setq col "156,128,199" lay "PV_(F)12.5m_(D)25m"))
		((<= Mdepth 29.99949)   (setq col "174,72,103" lay "PV_(F)12.5m_(D)28m"))
		((<= Mdepth 31.99949)   (setq col "245,130,73" lay "PV_(F)12.5m_(D)30m"))
		((<= Mdepth 35.99949)   (setq col "114,89,71" lay "PV_(F)12.5m_(D)32m"))
		(( > Mdepth 35.99949)   (setq col "73,142,164" lay "PV_(F)12.5m_(D)36m"))
		)
	)
	
	;Standard Lots between 14.0m and 16.0m frontage
	((<= Mfront 15.99949)
	
		(cond
		;depth range
		((<= Mdepth 24.99949)   (setq col "195,162,168" lay "C_(F)14m_(D)-25m"))
		((<= Mdepth 27.99949)   (setq col "182,150,214" lay "C_(F)14m_(D)25m"))
		((<= Mdepth 29.99949)   (setq col "203,98,123" lay "C_(F)14m_(D)28m"))
		((<= Mdepth 31.99949)   (setq col "243,155,76" lay "C_(F)14m_(D)30m"))
		((<= Mdepth 35.99949)   (setq col "176,115,94" lay "C_(F)14m_(D)32m"))
		(( > Mdepth 35.99949)   (setq col "103,169,182" lay "C_(F)14m_(D)36m"))
		)
	)
	
	;Standard Lots between 16.0m and 18.0m frontage
	((<= Mfront 17.99949)
	
		(cond
		;depth range
		((<= Mdepth 24.99949)   (setq col "211,187,191" lay "PC_(F)16m_(D)-25m"))
		((<= Mdepth 27.99949)   (setq col "207,173,229" lay "PC_(F)16m_(D)25m"))
		((<= Mdepth 29.99949)   (setq col "221,132,146" lay "PC_(F)16m_(D)28m"))
		((<= Mdepth 31.99949)   (setq col "240,177,94" lay "PC_(F)16m_(D)30m"))
		((<= Mdepth 35.99949)   (setq col "196,151,135" lay "PC_(F)16m_(D)32m"))
		(( > Mdepth 35.99949)   (setq col "136,195,200" lay "PC_(F)16m_(D)36m"))
		)
	)
	
	;Standard Lots between 18.0m and 20.0m frontage
	((<= Mfront 19.99949)
	
		(cond
		;depth range
		((<= Mdepth 24.99949)   (setq col "225,209,212" lay "T_(F)18m_(D)-25m"))
		((<= Mdepth 27.99949)   (setq col "230,198,243" lay "T_(F)18m_(D)25m"))
		((<= Mdepth 29.99949)   (setq col "239,165,172" lay "T_(F)18m_(D)28m"))
		((<= Mdepth 31.99949)   (setq col "237,198,122" lay "T_(F)18m_(D)30m"))
		((<= Mdepth 35.99949)   (setq col "215,183,173" lay "T_(F)18m_(D)32m"))
		(( > Mdepth 35.99949)   (setq col "170,219,218" lay "T_(F)18m_(D)36m"))
		)
	)
	
	;Standard Lots 20m frontage or greater
	(( > Mfront 19.99949)
	
		(cond
		;depth range
		((<= Mdepth 24.99949)   (setq col "241,221,226" lay "PT_(F)20m_(D)-25m"))
		((<= Mdepth 27.99949)   (setq col "231,211,248" lay "PT_(F)20m_(D)25m"))
		((<= Mdepth 29.99949)   (setq col "255,197,199" lay "PT_(F)20m_(D)28m"))
		((<= Mdepth 31.99949)   (setq col "236,217,153" lay "PT_(F)20m_(D)30m"))
		((<= Mdepth 35.99949)   (setq col "230,210,204" lay "PT_(F)20m_(D)32m"))
		(( > Mdepth 35.99949)   (setq col "210,238,234" lay "PT_(F)20m_(D)36m"))
		)
	)
	)
	
	(setq layx (vl-string-subst "" "," lay))
	(setq layx (vl-string-subst "" "," layx))
	
	(setq lay (strcat "SHG_Hatch_(FD)_" layx))
	(command "layer" "new" lay "")
	(command "layer" "color" "truecolor" col lay "")		
	(command "LAYER" "SET" lay "")
	(command "color" "bylayer")	
	(entmod (append (entget (tblobjname "layer" lay)) '((-3("AcCmTransparency" (1071 . 33554610))))))			

	(setq P1 (getpoint "\nSelect inside lot : "))
	(command "Bhatch" P1 "")
	
	
	(print "Hatch completed")(terpri)	
	
	)

 

 

Hatch_Frontage_Depth (with Lot Type) v3.lsp Drawing2.dwg

Posted

Hi @andyb57J,

 

I'v modified the posted lisp, try this:

 

;hatch lots based on both Frontage and Depth with RGB colours

(prompt "To run a LISP type: hl4")
(princ)

(defun c:hl4 (/ ss len i ent ptlist min_pt max_pt mid_pt Mfront Mdepth P1 DN DE col lay pt1 pt2 pt3 Mdst colx layx)
  
  (setvar "cmdecho" 0)
  
  ;;;	(setq pt1 (getpoint "\nSelect first frontage point (Right click to exit) : "))
  ;;;	(if (/= nil pt1)(setq pt2 (getpoint pt1 "\nSelect second frontage point (Right click to exit) : ")))
  ;;;	(if (/= nil pt2)(setq pt3 (getpoint "\nSelect depth point (Right click to exit) : ")))

  (prompt "\Select entities for HATCH:")
  (setq ss (ssget '((0 . "LWPOLYLINE") (70 . 1))) ;; use that just to SEE if there are some LWPOLYLINES which are not CLOSED when trying to select entities for HATCHING
	len (sslength ss)
	i 0
	)
  
  (while ( < i len)
    
    (setq ent (ssname ss i)	  
	  ptlist (mapcar 'cdr (vl-remove-if-not '(lambda (x)  (= (car x) 10)) (entget ent)))
          min_pt (nth 0 (vl-sort ptlist (function (lambda (pt1 pt2) (< (cadr pt1) (cadr pt2))))))
	  max_pt (nth (- (length ptlist) 1) (vl-sort ptlist (function (lambda (pt1 pt2) (< (cadr pt1) (cadr pt2))))))
	  mid_pt (polar min_pt (angle min_pt max_pt) (/ (distance min_pt max_pt) 2))
	  )    
    
    ;find frontage
    ;;;	(setq DN (- (cadr Pt2) (cadr Pt1)))
    ;;;	(setq DE (- (car Pt2) (car Pt1)))
    ;;;	(setq Mfront (sqrt(+(* DE DE)(* DN DN))))
    (setq Mfront (distance min_pt max_pt))
    
    ;find depth
    ;;;    (setq DN (-(cadr Pt3) (cadr Pt2)))
    ;;;    (setq DE (-(car Pt3) (car Pt2)))
    ;;;    (setq Mdepth (sqrt(+(* DE DE)(* DN DN))))
    (setq Mdepth (sqrt (vla-get-Area (vlax-ename->vla-object ent))))
    
    (setq col 1)
    
    (cond
      ;Terrace lots < 7.5m frontage - Change TE to TF for front loaded lots and TE to TR for rear loaded terraces.
      (( <= Mfront 7.49949)
       
       (cond
	 ;depth range
	 ((<= Mdepth 24.99949)	(setq col "198,110,78" lay "TE_(F)-7.5m_(D)-25m"))
	 ((<= Mdepth 27.99949) 	(setq col "192,76,54" lay "TE_(F)-7.5m_(D)25m"))
	 ((<= Mdepth 29.99949) 	(setq col "183,49,44" lay "TE_(F)-7.5m_(D)28m"))
	 ((<= Mdepth 31.99949) 	(setq col "171,35,40" lay "TE_(F)-7.5m_(D)30m"))
	 ((<= Mdepth 35.99949) 	(setq col "147,39,44" lay "TE_(F)-7.5m_(D)32m"))
	 (( > Mdepth 35.99949)	(setq col "138,42,43" lay "TE_(F)-7.5m_(D)36m"))
	 )
       )
      ;Terrace Lots 7.5m frontage - Change TE to TF for front loaded lots and TE to TR for rear loaded terraces.
      ((and(<= Mfront 7.50049 ))
       
       (cond
	 ;depth range
	 ((<= Mdepth 24.99949)   (setq col "104,101,159" lay "TE_(F)7.5m_(D)-25m"))
	 ((<= Mdepth 27.99949)   (setq col "97,94,155" lay "TE_(F)7.5m_(D)25m"))
	 ((<= Mdepth 29.99949)   (setq col "86,82,148" lay "TE_(F)7.5m_(D)28m"))
	 ((<= Mdepth 31.99949)   (setq col "81,70,137" lay "TE_(F)7.5m_(D)30m"))
	 ((<= Mdepth 35.99949)   (setq col "76,65,132" lay "TE_(F)7.5m_(D)32m"))
	 (( > Mdepth 35.99949)   (setq col "83,84,74" lay "TE_(F)7.5m_(D)36m"))
	 )
       )
      
      ;Terrace Lots between 7.5m and 10.5m frontage - Change TE to TF for front loaded lots and TE to TR for rear loaded terraces.
      ((<= Mfront 10.49949)
       
       (cond
	 ;depth range
	 ((<= Mdepth 24.99949)   (setq col "186,187,177" lay "TE_(F)7.5m+_(D)-25m"))
	 ((<= Mdepth 27.99949)   (setq col "168,169,158" lay "TE_(F)7.5m+_(D)25m"))
	 ((<= Mdepth 29.99949)   (setq col "145,147,136" lay "TE_(F)7.5m+_(D)28m"))
	 ((<= Mdepth 31.99949)   (setq col "126,127,116" lay "TE_(F)7.5m+_(D)30m"))
	 ((<= Mdepth 35.99949)   (setq col "101,102,92" lay "TE_(F)7.5m+_(D)32m"))
	 (( > Mdepth 35.99949)   (setq col "81,83,74" lay "TE_(F)7.5m+_(D)36m"))
	 )
       )
      
      ;Standard Lots between 10.5m and 12.5m frontage
      ((<= Mfront 12.49949)
       
       (cond
	 ;depth range
	 ((<= Mdepth 24.99949)   (setq col "169,133,132" lay "_V_(F)10.5m_(D)-25m"))
	 ((<= Mdepth 27.99949)   (setq col "129,107,183" lay "_V_(F)10.5m_(D)25m"))
	 ((<= Mdepth 29.99949)   (setq col "138,52,83" lay "_V_(F)10.5m_(D)28m"))
	 ((<= Mdepth 31.99949)   (setq col "245,101,83" lay "_V_(F)10.5m_(D)30m"))
	 ((<= Mdepth 35.99949)   (setq col "116,72,57" lay "_V_(F)10.5m_(D)32m"))
	 (( > Mdepth 35.99949)   (setq col "54,114,142" lay "_V_(F)10.5m_(D)36m"))
	 )
       )
      
      ;Standard Lots between 12.5m and 14.0m frontage
      ((<= Mfront 13.99949)
       
       (cond
	 ;depth range
	 ((<= Mdepth 24.99949)   (setq col "181,149,148" lay "PV_(F)12.5m_(D)-25m"))
	 ((<= Mdepth 27.99949)   (setq col "156,128,199" lay "PV_(F)12.5m_(D)25m"))
	 ((<= Mdepth 29.99949)   (setq col "174,72,103" lay "PV_(F)12.5m_(D)28m"))
	 ((<= Mdepth 31.99949)   (setq col "245,130,73" lay "PV_(F)12.5m_(D)30m"))
	 ((<= Mdepth 35.99949)   (setq col "114,89,71" lay "PV_(F)12.5m_(D)32m"))
	 (( > Mdepth 35.99949)   (setq col "73,142,164" lay "PV_(F)12.5m_(D)36m"))
	 )
       )
      
      ;Standard Lots between 14.0m and 16.0m frontage
      ((<= Mfront 15.99949)
       
       (cond
	 ;depth range
	 ((<= Mdepth 24.99949)   (setq col "195,162,168" lay "C_(F)14m_(D)-25m"))
	 ((<= Mdepth 27.99949)   (setq col "182,150,214" lay "C_(F)14m_(D)25m"))
	 ((<= Mdepth 29.99949)   (setq col "203,98,123" lay "C_(F)14m_(D)28m"))
	 ((<= Mdepth 31.99949)   (setq col "243,155,76" lay "C_(F)14m_(D)30m"))
	 ((<= Mdepth 35.99949)   (setq col "176,115,94" lay "C_(F)14m_(D)32m"))
	 (( > Mdepth 35.99949)   (setq col "103,169,182" lay "C_(F)14m_(D)36m"))
	 )
       )
      
      ;Standard Lots between 16.0m and 18.0m frontage
      ((<= Mfront 17.99949)
       
       (cond
	 ;depth range
	 ((<= Mdepth 24.99949)   (setq col "211,187,191" lay "PC_(F)16m_(D)-25m"))
	 ((<= Mdepth 27.99949)   (setq col "207,173,229" lay "PC_(F)16m_(D)25m"))
	 ((<= Mdepth 29.99949)   (setq col "221,132,146" lay "PC_(F)16m_(D)28m"))
	 ((<= Mdepth 31.99949)   (setq col "240,177,94" lay "PC_(F)16m_(D)30m"))
	 ((<= Mdepth 35.99949)   (setq col "196,151,135" lay "PC_(F)16m_(D)32m"))
	 (( > Mdepth 35.99949)   (setq col "136,195,200" lay "PC_(F)16m_(D)36m"))
	 )
       )
      
      ;Standard Lots between 18.0m and 20.0m frontage
      ((<= Mfront 19.99949)
       
       (cond
	 ;depth range
	 ((<= Mdepth 24.99949)   (setq col "225,209,212" lay "T_(F)18m_(D)-25m"))
	 ((<= Mdepth 27.99949)   (setq col "230,198,243" lay "T_(F)18m_(D)25m"))
	 ((<= Mdepth 29.99949)   (setq col "239,165,172" lay "T_(F)18m_(D)28m"))
	 ((<= Mdepth 31.99949)   (setq col "237,198,122" lay "T_(F)18m_(D)30m"))
	 ((<= Mdepth 35.99949)   (setq col "215,183,173" lay "T_(F)18m_(D)32m"))
	 (( > Mdepth 35.99949)   (setq col "170,219,218" lay "T_(F)18m_(D)36m"))
	 )
       )
      
      ;Standard Lots 20m frontage or greater
      (( > Mfront 19.99949)
       
       (cond
	 ;depth range
	 ((<= Mdepth 24.99949)   (setq col "241,221,226" lay "PT_(F)20m_(D)-25m"))
	 ((<= Mdepth 27.99949)   (setq col "231,211,248" lay "PT_(F)20m_(D)25m"))
	 ((<= Mdepth 29.99949)   (setq col "255,197,199" lay "PT_(F)20m_(D)28m"))
	 ((<= Mdepth 31.99949)   (setq col "236,217,153" lay "PT_(F)20m_(D)30m"))
	 ((<= Mdepth 35.99949)   (setq col "230,210,204" lay "PT_(F)20m_(D)32m"))
	 (( > Mdepth 35.99949)   (setq col "210,238,234" lay "PT_(F)20m_(D)36m"))
	 )
       )
      )
    
    (setq layx (vl-string-subst "" "," lay))
    (setq layx (vl-string-subst "" "," layx))
    
    (setq lay (strcat "SHG_Hatch_(FD)_" layx))
    (command "layer" "new" lay "")
    (command "layer" "color" "truecolor" col lay "")
    (command "LAYER" "SET" lay "")
    (command "color" "bylayer")
    (entmod (append (entget (tblobjname "layer" lay)) '((-3("AcCmTransparency" (1071 . 33554610))))))
    
    ;;;	(setq P1 (getpoint "\nSelect inside lot : "))
    (command "Bhatch" "s" ent "" "")
    (setq i (1+ i))
    )
    
  (print "Hatch completed")
  (terpri)  
  )

 

See if it work as expected (for me, when tested it, it works good, but didn't know are the selected lwpolylines hatched in desired layer). Let me know if something need to be changed.

Posted
10 minutes ago, Saxlle said:

Hi @andyb57J,

 

I'v modified the posted lisp, try this:

 

;hatch lots based on both Frontage and Depth with RGB colours

(prompt "To run a LISP type: hl4")
(princ)

(defun c:hl4 (/ ss len i ent ptlist min_pt max_pt mid_pt Mfront Mdepth P1 DN DE col lay pt1 pt2 pt3 Mdst colx layx)
  
  (setvar "cmdecho" 0)
  
  ;;;	(setq pt1 (getpoint "\nSelect first frontage point (Right click to exit) : "))
  ;;;	(if (/= nil pt1)(setq pt2 (getpoint pt1 "\nSelect second frontage point (Right click to exit) : ")))
  ;;;	(if (/= nil pt2)(setq pt3 (getpoint "\nSelect depth point (Right click to exit) : ")))

  (prompt "\Select entities for HATCH:")
  (setq ss (ssget '((0 . "LWPOLYLINE") (70 . 1))) ;; use that just to SEE if there are some LWPOLYLINES which are not CLOSED when trying to select entities for HATCHING
	len (sslength ss)
	i 0
	)
  
  (while ( < i len)
    
    (setq ent (ssname ss i)	  
	  ptlist (mapcar 'cdr (vl-remove-if-not '(lambda (x)  (= (car x) 10)) (entget ent)))
          min_pt (nth 0 (vl-sort ptlist (function (lambda (pt1 pt2) (< (cadr pt1) (cadr pt2))))))
	  max_pt (nth (- (length ptlist) 1) (vl-sort ptlist (function (lambda (pt1 pt2) (< (cadr pt1) (cadr pt2))))))
	  mid_pt (polar min_pt (angle min_pt max_pt) (/ (distance min_pt max_pt) 2))
	  )    
    
    ;find frontage
    ;;;	(setq DN (- (cadr Pt2) (cadr Pt1)))
    ;;;	(setq DE (- (car Pt2) (car Pt1)))
    ;;;	(setq Mfront (sqrt(+(* DE DE)(* DN DN))))
    (setq Mfront (distance min_pt max_pt))
    
    ;find depth
    ;;;    (setq DN (-(cadr Pt3) (cadr Pt2)))
    ;;;    (setq DE (-(car Pt3) (car Pt2)))
    ;;;    (setq Mdepth (sqrt(+(* DE DE)(* DN DN))))
    (setq Mdepth (sqrt (vla-get-Area (vlax-ename->vla-object ent))))
    
    (setq col 1)
    
    (cond
      ;Terrace lots < 7.5m frontage - Change TE to TF for front loaded lots and TE to TR for rear loaded terraces.
      (( <= Mfront 7.49949)
       
       (cond
	 ;depth range
	 ((<= Mdepth 24.99949)	(setq col "198,110,78" lay "TE_(F)-7.5m_(D)-25m"))
	 ((<= Mdepth 27.99949) 	(setq col "192,76,54" lay "TE_(F)-7.5m_(D)25m"))
	 ((<= Mdepth 29.99949) 	(setq col "183,49,44" lay "TE_(F)-7.5m_(D)28m"))
	 ((<= Mdepth 31.99949) 	(setq col "171,35,40" lay "TE_(F)-7.5m_(D)30m"))
	 ((<= Mdepth 35.99949) 	(setq col "147,39,44" lay "TE_(F)-7.5m_(D)32m"))
	 (( > Mdepth 35.99949)	(setq col "138,42,43" lay "TE_(F)-7.5m_(D)36m"))
	 )
       )
      ;Terrace Lots 7.5m frontage - Change TE to TF for front loaded lots and TE to TR for rear loaded terraces.
      ((and(<= Mfront 7.50049 ))
       
       (cond
	 ;depth range
	 ((<= Mdepth 24.99949)   (setq col "104,101,159" lay "TE_(F)7.5m_(D)-25m"))
	 ((<= Mdepth 27.99949)   (setq col "97,94,155" lay "TE_(F)7.5m_(D)25m"))
	 ((<= Mdepth 29.99949)   (setq col "86,82,148" lay "TE_(F)7.5m_(D)28m"))
	 ((<= Mdepth 31.99949)   (setq col "81,70,137" lay "TE_(F)7.5m_(D)30m"))
	 ((<= Mdepth 35.99949)   (setq col "76,65,132" lay "TE_(F)7.5m_(D)32m"))
	 (( > Mdepth 35.99949)   (setq col "83,84,74" lay "TE_(F)7.5m_(D)36m"))
	 )
       )
      
      ;Terrace Lots between 7.5m and 10.5m frontage - Change TE to TF for front loaded lots and TE to TR for rear loaded terraces.
      ((<= Mfront 10.49949)
       
       (cond
	 ;depth range
	 ((<= Mdepth 24.99949)   (setq col "186,187,177" lay "TE_(F)7.5m+_(D)-25m"))
	 ((<= Mdepth 27.99949)   (setq col "168,169,158" lay "TE_(F)7.5m+_(D)25m"))
	 ((<= Mdepth 29.99949)   (setq col "145,147,136" lay "TE_(F)7.5m+_(D)28m"))
	 ((<= Mdepth 31.99949)   (setq col "126,127,116" lay "TE_(F)7.5m+_(D)30m"))
	 ((<= Mdepth 35.99949)   (setq col "101,102,92" lay "TE_(F)7.5m+_(D)32m"))
	 (( > Mdepth 35.99949)   (setq col "81,83,74" lay "TE_(F)7.5m+_(D)36m"))
	 )
       )
      
      ;Standard Lots between 10.5m and 12.5m frontage
      ((<= Mfront 12.49949)
       
       (cond
	 ;depth range
	 ((<= Mdepth 24.99949)   (setq col "169,133,132" lay "_V_(F)10.5m_(D)-25m"))
	 ((<= Mdepth 27.99949)   (setq col "129,107,183" lay "_V_(F)10.5m_(D)25m"))
	 ((<= Mdepth 29.99949)   (setq col "138,52,83" lay "_V_(F)10.5m_(D)28m"))
	 ((<= Mdepth 31.99949)   (setq col "245,101,83" lay "_V_(F)10.5m_(D)30m"))
	 ((<= Mdepth 35.99949)   (setq col "116,72,57" lay "_V_(F)10.5m_(D)32m"))
	 (( > Mdepth 35.99949)   (setq col "54,114,142" lay "_V_(F)10.5m_(D)36m"))
	 )
       )
      
      ;Standard Lots between 12.5m and 14.0m frontage
      ((<= Mfront 13.99949)
       
       (cond
	 ;depth range
	 ((<= Mdepth 24.99949)   (setq col "181,149,148" lay "PV_(F)12.5m_(D)-25m"))
	 ((<= Mdepth 27.99949)   (setq col "156,128,199" lay "PV_(F)12.5m_(D)25m"))
	 ((<= Mdepth 29.99949)   (setq col "174,72,103" lay "PV_(F)12.5m_(D)28m"))
	 ((<= Mdepth 31.99949)   (setq col "245,130,73" lay "PV_(F)12.5m_(D)30m"))
	 ((<= Mdepth 35.99949)   (setq col "114,89,71" lay "PV_(F)12.5m_(D)32m"))
	 (( > Mdepth 35.99949)   (setq col "73,142,164" lay "PV_(F)12.5m_(D)36m"))
	 )
       )
      
      ;Standard Lots between 14.0m and 16.0m frontage
      ((<= Mfront 15.99949)
       
       (cond
	 ;depth range
	 ((<= Mdepth 24.99949)   (setq col "195,162,168" lay "C_(F)14m_(D)-25m"))
	 ((<= Mdepth 27.99949)   (setq col "182,150,214" lay "C_(F)14m_(D)25m"))
	 ((<= Mdepth 29.99949)   (setq col "203,98,123" lay "C_(F)14m_(D)28m"))
	 ((<= Mdepth 31.99949)   (setq col "243,155,76" lay "C_(F)14m_(D)30m"))
	 ((<= Mdepth 35.99949)   (setq col "176,115,94" lay "C_(F)14m_(D)32m"))
	 (( > Mdepth 35.99949)   (setq col "103,169,182" lay "C_(F)14m_(D)36m"))
	 )
       )
      
      ;Standard Lots between 16.0m and 18.0m frontage
      ((<= Mfront 17.99949)
       
       (cond
	 ;depth range
	 ((<= Mdepth 24.99949)   (setq col "211,187,191" lay "PC_(F)16m_(D)-25m"))
	 ((<= Mdepth 27.99949)   (setq col "207,173,229" lay "PC_(F)16m_(D)25m"))
	 ((<= Mdepth 29.99949)   (setq col "221,132,146" lay "PC_(F)16m_(D)28m"))
	 ((<= Mdepth 31.99949)   (setq col "240,177,94" lay "PC_(F)16m_(D)30m"))
	 ((<= Mdepth 35.99949)   (setq col "196,151,135" lay "PC_(F)16m_(D)32m"))
	 (( > Mdepth 35.99949)   (setq col "136,195,200" lay "PC_(F)16m_(D)36m"))
	 )
       )
      
      ;Standard Lots between 18.0m and 20.0m frontage
      ((<= Mfront 19.99949)
       
       (cond
	 ;depth range
	 ((<= Mdepth 24.99949)   (setq col "225,209,212" lay "T_(F)18m_(D)-25m"))
	 ((<= Mdepth 27.99949)   (setq col "230,198,243" lay "T_(F)18m_(D)25m"))
	 ((<= Mdepth 29.99949)   (setq col "239,165,172" lay "T_(F)18m_(D)28m"))
	 ((<= Mdepth 31.99949)   (setq col "237,198,122" lay "T_(F)18m_(D)30m"))
	 ((<= Mdepth 35.99949)   (setq col "215,183,173" lay "T_(F)18m_(D)32m"))
	 (( > Mdepth 35.99949)   (setq col "170,219,218" lay "T_(F)18m_(D)36m"))
	 )
       )
      
      ;Standard Lots 20m frontage or greater
      (( > Mfront 19.99949)
       
       (cond
	 ;depth range
	 ((<= Mdepth 24.99949)   (setq col "241,221,226" lay "PT_(F)20m_(D)-25m"))
	 ((<= Mdepth 27.99949)   (setq col "231,211,248" lay "PT_(F)20m_(D)25m"))
	 ((<= Mdepth 29.99949)   (setq col "255,197,199" lay "PT_(F)20m_(D)28m"))
	 ((<= Mdepth 31.99949)   (setq col "236,217,153" lay "PT_(F)20m_(D)30m"))
	 ((<= Mdepth 35.99949)   (setq col "230,210,204" lay "PT_(F)20m_(D)32m"))
	 (( > Mdepth 35.99949)   (setq col "210,238,234" lay "PT_(F)20m_(D)36m"))
	 )
       )
      )
    
    (setq layx (vl-string-subst "" "," lay))
    (setq layx (vl-string-subst "" "," layx))
    
    (setq lay (strcat "SHG_Hatch_(FD)_" layx))
    (command "layer" "new" lay "")
    (command "layer" "color" "truecolor" col lay "")
    (command "LAYER" "SET" lay "")
    (command "color" "bylayer")
    (entmod (append (entget (tblobjname "layer" lay)) '((-3("AcCmTransparency" (1071 . 33554610))))))
    
    ;;;	(setq P1 (getpoint "\nSelect inside lot : "))
    (command "Bhatch" "s" ent "" "")
    (setq i (1+ i))
    )
    
  (print "Hatch completed")
  (terpri)  
  )

 

See if it work as expected (for me, when tested it, it works good, but didn't know are the selected lwpolylines hatched in desired layer). Let me know if something need to be changed.

Thankyou but it isnt calculating the frontage and depth correctly and not hatchuring the lots by the correct conditions

Posted
Just now, andyb57J said:

Thankyou but it isnt calculating the frontage and depth correctly and not hatchuring the lots by the correct conditions

it is also processing all closed polylines, not just the ones with 4 or less vertices.  Want it to ignore all closed polylines with 5 or more vertices. And not sure how you calculate the depth being the mean of the two longest sides, or the frontage being the min distance

;find frontage
    ;;;	(setq DN (- (cadr Pt2) (cadr Pt1)))
    ;;;	(setq DE (- (car Pt2) (car Pt1)))
    ;;;	(setq Mfront (sqrt(+(* DE DE)(* DN DN))))
    (setq Mfront (distance min_pt max_pt))

 

;find depth
    ;;;    (setq DN (-(cadr Pt3) (cadr Pt2)))
    ;;;    (setq DE (-(car Pt3) (car Pt2)))
    ;;;    (setq Mdepth (sqrt(+(* DE DE)(* DN DN))))
    (setq Mdepth (sqrt (vla-get-Area (vlax-ename->vla-object ent))))

 

Posted

Try this modification: 

 

;hatch lots based on both Frontage and Depth with RGB colours

(prompt "To run a LISP type: hl4")
(princ)

(defun c:hl4 (/ min_vertices ss len i ent ptlist min_pt max_pt mid_pt Mfront Mdepth P1 DN DE col lay pt1 pt2 pt3 Mdst colx layx)
  
  (setvar "cmdecho" 0)
  
  ;;;	(setq pt1 (getpoint "\nSelect first frontage point (Right click to exit) : "))
  ;;;	(if (/= nil pt1)(setq pt2 (getpoint pt1 "\nSelect second frontage point (Right click to exit) : ")))
  ;;;	(if (/= nil pt2)(setq pt3 (getpoint "\nSelect depth point (Right click to exit) : ")))
  (setq min_vertices 4)
  (setq min_vertices (getint (strcat "\nEnter the number of vertex to proccessed selection <" (itoa min_vertices) ">:")))
  
  (prompt "\Select entities for HATCH:")
  (setq ss (ssget (list (cons 0 "LWPOLYLINE") (cons 70 1) (cons -4 "<=") (cons 90 min_vertices)))) ;; use that just to SEE if there are some LWPOLYLINES which are not CLOSED when trying to select entities for HATCHING
	len (sslength ss)
	i 0
	)
  
  (while ( < i len)
    
    (setq ent (ssname ss i)
	  ptlist (mapcar 'cdr (vl-remove-if-not '(lambda (x)  (= (car x) 10)) (entget ent)))
	  j 0)
       
    (repeat (length ptlist)
      (if (/= j (- (length ptlist) 1))
	(setq dist (distance (nth j ptlist) (nth (1+ j) ptlist))
	      dist_lst (cons dist dist_lst)
	      j (1+ j)
	      )
	(setq dist (distance (nth j ptlist) (nth 0 ptlist))
	      dist_lst (cons dist dist_lst)
	      )
	)
      )

;;;    (setq min_pt (nth 0 (vl-sort ptlist (function (lambda (pt1 pt2) (< (cadr pt1) (cadr pt2))))))
;;;	  max_pt (nth (- (length ptlist) 1) (vl-sort ptlist (function (lambda (pt1 pt2) (< (cadr pt1) (cadr pt2))))))
;;;	  mid_pt (polar min_pt (angle min_pt max_pt) (/ (distance min_pt max_pt) 2))
;;;	  )
    
    ;find frontage
    ;;;	(setq DN (- (cadr Pt2) (cadr Pt1)))
    ;;;	(setq DE (- (car Pt2) (car Pt1)))
    ;;;	(setq Mfront (sqrt(+(* DE DE)(* DN DN))))
    ;;; (setq Mfront (distance min_pt max_pt))
    (setq Mfront (apply 'min dist_lst)) ;; from dist_lst I find here the min distance between two vertices
    
    ;find depth
;;;    (setq DN (-(cadr mid_pt) (cadr min_pt)))
;;;    (setq DE (-(car mid_pt) (car min_pt)))
    (setq Mdepth (/ (apply 'max dist_lst) 2)) ;; from dist_lst I find here the max distance between two vertices and divide by 2
    
    (setq col 1)
    
    (cond
      ;Terrace lots < 7.5m frontage - Change TE to TF for front loaded lots and TE to TR for rear loaded terraces.
      (( <= Mfront 7.49949)
       
       (cond
	 ;depth range
	 ((<= Mdepth 24.99949)	(setq col "198,110,78" lay "TE_(F)-7.5m_(D)-25m"))
	 ((<= Mdepth 27.99949) 	(setq col "192,76,54" lay "TE_(F)-7.5m_(D)25m"))
	 ((<= Mdepth 29.99949) 	(setq col "183,49,44" lay "TE_(F)-7.5m_(D)28m"))
	 ((<= Mdepth 31.99949) 	(setq col "171,35,40" lay "TE_(F)-7.5m_(D)30m"))
	 ((<= Mdepth 35.99949) 	(setq col "147,39,44" lay "TE_(F)-7.5m_(D)32m"))
	 (( > Mdepth 35.99949)	(setq col "138,42,43" lay "TE_(F)-7.5m_(D)36m"))
	 )
       )
      ;Terrace Lots 7.5m frontage - Change TE to TF for front loaded lots and TE to TR for rear loaded terraces.
      ((and(<= Mfront 7.50049 ))
       
       (cond
	 ;depth range
	 ((<= Mdepth 24.99949)   (setq col "104,101,159" lay "TE_(F)7.5m_(D)-25m"))
	 ((<= Mdepth 27.99949)   (setq col "97,94,155" lay "TE_(F)7.5m_(D)25m"))
	 ((<= Mdepth 29.99949)   (setq col "86,82,148" lay "TE_(F)7.5m_(D)28m"))
	 ((<= Mdepth 31.99949)   (setq col "81,70,137" lay "TE_(F)7.5m_(D)30m"))
	 ((<= Mdepth 35.99949)   (setq col "76,65,132" lay "TE_(F)7.5m_(D)32m"))
	 (( > Mdepth 35.99949)   (setq col "83,84,74" lay "TE_(F)7.5m_(D)36m"))
	 )
       )
      
      ;Terrace Lots between 7.5m and 10.5m frontage - Change TE to TF for front loaded lots and TE to TR for rear loaded terraces.
      ((<= Mfront 10.49949)
       
       (cond
	 ;depth range
	 ((<= Mdepth 24.99949)   (setq col "186,187,177" lay "TE_(F)7.5m+_(D)-25m"))
	 ((<= Mdepth 27.99949)   (setq col "168,169,158" lay "TE_(F)7.5m+_(D)25m"))
	 ((<= Mdepth 29.99949)   (setq col "145,147,136" lay "TE_(F)7.5m+_(D)28m"))
	 ((<= Mdepth 31.99949)   (setq col "126,127,116" lay "TE_(F)7.5m+_(D)30m"))
	 ((<= Mdepth 35.99949)   (setq col "101,102,92" lay "TE_(F)7.5m+_(D)32m"))
	 (( > Mdepth 35.99949)   (setq col "81,83,74" lay "TE_(F)7.5m+_(D)36m"))
	 )
       )
      
      ;Standard Lots between 10.5m and 12.5m frontage
      ((<= Mfront 12.49949)
       
       (cond
	 ;depth range
	 ((<= Mdepth 24.99949)   (setq col "169,133,132" lay "_V_(F)10.5m_(D)-25m"))
	 ((<= Mdepth 27.99949)   (setq col "129,107,183" lay "_V_(F)10.5m_(D)25m"))
	 ((<= Mdepth 29.99949)   (setq col "138,52,83" lay "_V_(F)10.5m_(D)28m"))
	 ((<= Mdepth 31.99949)   (setq col "245,101,83" lay "_V_(F)10.5m_(D)30m"))
	 ((<= Mdepth 35.99949)   (setq col "116,72,57" lay "_V_(F)10.5m_(D)32m"))
	 (( > Mdepth 35.99949)   (setq col "54,114,142" lay "_V_(F)10.5m_(D)36m"))
	 )
       )
      
      ;Standard Lots between 12.5m and 14.0m frontage
      ((<= Mfront 13.99949)
       
       (cond
	 ;depth range
	 ((<= Mdepth 24.99949)   (setq col "181,149,148" lay "PV_(F)12.5m_(D)-25m"))
	 ((<= Mdepth 27.99949)   (setq col "156,128,199" lay "PV_(F)12.5m_(D)25m"))
	 ((<= Mdepth 29.99949)   (setq col "174,72,103" lay "PV_(F)12.5m_(D)28m"))
	 ((<= Mdepth 31.99949)   (setq col "245,130,73" lay "PV_(F)12.5m_(D)30m"))
	 ((<= Mdepth 35.99949)   (setq col "114,89,71" lay "PV_(F)12.5m_(D)32m"))
	 (( > Mdepth 35.99949)   (setq col "73,142,164" lay "PV_(F)12.5m_(D)36m"))
	 )
       )
      
      ;Standard Lots between 14.0m and 16.0m frontage
      ((<= Mfront 15.99949)
       
       (cond
	 ;depth range
	 ((<= Mdepth 24.99949)   (setq col "195,162,168" lay "C_(F)14m_(D)-25m"))
	 ((<= Mdepth 27.99949)   (setq col "182,150,214" lay "C_(F)14m_(D)25m"))
	 ((<= Mdepth 29.99949)   (setq col "203,98,123" lay "C_(F)14m_(D)28m"))
	 ((<= Mdepth 31.99949)   (setq col "243,155,76" lay "C_(F)14m_(D)30m"))
	 ((<= Mdepth 35.99949)   (setq col "176,115,94" lay "C_(F)14m_(D)32m"))
	 (( > Mdepth 35.99949)   (setq col "103,169,182" lay "C_(F)14m_(D)36m"))
	 )
       )
      
      ;Standard Lots between 16.0m and 18.0m frontage
      ((<= Mfront 17.99949)
       
       (cond
	 ;depth range
	 ((<= Mdepth 24.99949)   (setq col "211,187,191" lay "PC_(F)16m_(D)-25m"))
	 ((<= Mdepth 27.99949)   (setq col "207,173,229" lay "PC_(F)16m_(D)25m"))
	 ((<= Mdepth 29.99949)   (setq col "221,132,146" lay "PC_(F)16m_(D)28m"))
	 ((<= Mdepth 31.99949)   (setq col "240,177,94" lay "PC_(F)16m_(D)30m"))
	 ((<= Mdepth 35.99949)   (setq col "196,151,135" lay "PC_(F)16m_(D)32m"))
	 (( > Mdepth 35.99949)   (setq col "136,195,200" lay "PC_(F)16m_(D)36m"))
	 )
       )
      
      ;Standard Lots between 18.0m and 20.0m frontage
      ((<= Mfront 19.99949)
       
       (cond
	 ;depth range
	 ((<= Mdepth 24.99949)   (setq col "225,209,212" lay "T_(F)18m_(D)-25m"))
	 ((<= Mdepth 27.99949)   (setq col "230,198,243" lay "T_(F)18m_(D)25m"))
	 ((<= Mdepth 29.99949)   (setq col "239,165,172" lay "T_(F)18m_(D)28m"))
	 ((<= Mdepth 31.99949)   (setq col "237,198,122" lay "T_(F)18m_(D)30m"))
	 ((<= Mdepth 35.99949)   (setq col "215,183,173" lay "T_(F)18m_(D)32m"))
	 (( > Mdepth 35.99949)   (setq col "170,219,218" lay "T_(F)18m_(D)36m"))
	 )
       )
      
      ;Standard Lots 20m frontage or greater
      (( > Mfront 19.99949)
       
       (cond
	 ;depth range
	 ((<= Mdepth 24.99949)   (setq col "241,221,226" lay "PT_(F)20m_(D)-25m"))
	 ((<= Mdepth 27.99949)   (setq col "231,211,248" lay "PT_(F)20m_(D)25m"))
	 ((<= Mdepth 29.99949)   (setq col "255,197,199" lay "PT_(F)20m_(D)28m"))
	 ((<= Mdepth 31.99949)   (setq col "236,217,153" lay "PT_(F)20m_(D)30m"))
	 ((<= Mdepth 35.99949)   (setq col "230,210,204" lay "PT_(F)20m_(D)32m"))
	 (( > Mdepth 35.99949)   (setq col "210,238,234" lay "PT_(F)20m_(D)36m"))
	 )
       )
      )
    
    (setq layx (vl-string-subst "" "," lay))
    (setq layx (vl-string-subst "" "," layx))
    
    (setq lay (strcat "SHG_Hatch_(FD)_" layx))
    (command "layer" "new" lay "")
    (command "layer" "color" "truecolor" col lay "")
    (command "LAYER" "SET" lay "")
    (command "color" "bylayer")
    (entmod (append (entget (tblobjname "layer" lay)) '((-3("AcCmTransparency" (1071 . 33554610))))))
    
    ;;;	(setq P1 (getpoint "\nSelect inside lot : "))
    (command "Bhatch" "s" ent "" "")
    (setq i (1+ i))
    )
    
  (print "Hatch completed")
  (terpri)  
  )

 

Posted
9 hours ago, Saxlle said:

Try this modification: 

 

;hatch lots based on both Frontage and Depth with RGB colours

(prompt "To run a LISP type: hl4")
(princ)

(defun c:hl4 (/ min_vertices ss len i ent ptlist min_pt max_pt mid_pt Mfront Mdepth P1 DN DE col lay pt1 pt2 pt3 Mdst colx layx)
  
  (setvar "cmdecho" 0)
  
  ;;;	(setq pt1 (getpoint "\nSelect first frontage point (Right click to exit) : "))
  ;;;	(if (/= nil pt1)(setq pt2 (getpoint pt1 "\nSelect second frontage point (Right click to exit) : ")))
  ;;;	(if (/= nil pt2)(setq pt3 (getpoint "\nSelect depth point (Right click to exit) : ")))
  (setq min_vertices 4)
  (setq min_vertices (getint (strcat "\nEnter the number of vertex to proccessed selection <" (itoa min_vertices) ">:")))
  
  (prompt "\Select entities for HATCH:")
  (setq ss (ssget (list (cons 0 "LWPOLYLINE") (cons 70 1) (cons -4 "<=") (cons 90 min_vertices)))) ;; use that just to SEE if there are some LWPOLYLINES which are not CLOSED when trying to select entities for HATCHING
	len (sslength ss)
	i 0
	)
  
  (while ( < i len)
    
    (setq ent (ssname ss i)
	  ptlist (mapcar 'cdr (vl-remove-if-not '(lambda (x)  (= (car x) 10)) (entget ent)))
	  j 0)
       
    (repeat (length ptlist)
      (if (/= j (- (length ptlist) 1))
	(setq dist (distance (nth j ptlist) (nth (1+ j) ptlist))
	      dist_lst (cons dist dist_lst)
	      j (1+ j)
	      )
	(setq dist (distance (nth j ptlist) (nth 0 ptlist))
	      dist_lst (cons dist dist_lst)
	      )
	)
      )

;;;    (setq min_pt (nth 0 (vl-sort ptlist (function (lambda (pt1 pt2) (< (cadr pt1) (cadr pt2))))))
;;;	  max_pt (nth (- (length ptlist) 1) (vl-sort ptlist (function (lambda (pt1 pt2) (< (cadr pt1) (cadr pt2))))))
;;;	  mid_pt (polar min_pt (angle min_pt max_pt) (/ (distance min_pt max_pt) 2))
;;;	  )
    
    ;find frontage
    ;;;	(setq DN (- (cadr Pt2) (cadr Pt1)))
    ;;;	(setq DE (- (car Pt2) (car Pt1)))
    ;;;	(setq Mfront (sqrt(+(* DE DE)(* DN DN))))
    ;;; (setq Mfront (distance min_pt max_pt))
    (setq Mfront (apply 'min dist_lst)) ;; from dist_lst I find here the min distance between two vertices
    
    ;find depth
;;;    (setq DN (-(cadr mid_pt) (cadr min_pt)))
;;;    (setq DE (-(car mid_pt) (car min_pt)))
    (setq Mdepth (/ (apply 'max dist_lst) 2)) ;; from dist_lst I find here the max distance between two vertices and divide by 2
    
    (setq col 1)
    
    (cond
      ;Terrace lots < 7.5m frontage - Change TE to TF for front loaded lots and TE to TR for rear loaded terraces.
      (( <= Mfront 7.49949)
       
       (cond
	 ;depth range
	 ((<= Mdepth 24.99949)	(setq col "198,110,78" lay "TE_(F)-7.5m_(D)-25m"))
	 ((<= Mdepth 27.99949) 	(setq col "192,76,54" lay "TE_(F)-7.5m_(D)25m"))
	 ((<= Mdepth 29.99949) 	(setq col "183,49,44" lay "TE_(F)-7.5m_(D)28m"))
	 ((<= Mdepth 31.99949) 	(setq col "171,35,40" lay "TE_(F)-7.5m_(D)30m"))
	 ((<= Mdepth 35.99949) 	(setq col "147,39,44" lay "TE_(F)-7.5m_(D)32m"))
	 (( > Mdepth 35.99949)	(setq col "138,42,43" lay "TE_(F)-7.5m_(D)36m"))
	 )
       )
      ;Terrace Lots 7.5m frontage - Change TE to TF for front loaded lots and TE to TR for rear loaded terraces.
      ((and(<= Mfront 7.50049 ))
       
       (cond
	 ;depth range
	 ((<= Mdepth 24.99949)   (setq col "104,101,159" lay "TE_(F)7.5m_(D)-25m"))
	 ((<= Mdepth 27.99949)   (setq col "97,94,155" lay "TE_(F)7.5m_(D)25m"))
	 ((<= Mdepth 29.99949)   (setq col "86,82,148" lay "TE_(F)7.5m_(D)28m"))
	 ((<= Mdepth 31.99949)   (setq col "81,70,137" lay "TE_(F)7.5m_(D)30m"))
	 ((<= Mdepth 35.99949)   (setq col "76,65,132" lay "TE_(F)7.5m_(D)32m"))
	 (( > Mdepth 35.99949)   (setq col "83,84,74" lay "TE_(F)7.5m_(D)36m"))
	 )
       )
      
      ;Terrace Lots between 7.5m and 10.5m frontage - Change TE to TF for front loaded lots and TE to TR for rear loaded terraces.
      ((<= Mfront 10.49949)
       
       (cond
	 ;depth range
	 ((<= Mdepth 24.99949)   (setq col "186,187,177" lay "TE_(F)7.5m+_(D)-25m"))
	 ((<= Mdepth 27.99949)   (setq col "168,169,158" lay "TE_(F)7.5m+_(D)25m"))
	 ((<= Mdepth 29.99949)   (setq col "145,147,136" lay "TE_(F)7.5m+_(D)28m"))
	 ((<= Mdepth 31.99949)   (setq col "126,127,116" lay "TE_(F)7.5m+_(D)30m"))
	 ((<= Mdepth 35.99949)   (setq col "101,102,92" lay "TE_(F)7.5m+_(D)32m"))
	 (( > Mdepth 35.99949)   (setq col "81,83,74" lay "TE_(F)7.5m+_(D)36m"))
	 )
       )
      
      ;Standard Lots between 10.5m and 12.5m frontage
      ((<= Mfront 12.49949)
       
       (cond
	 ;depth range
	 ((<= Mdepth 24.99949)   (setq col "169,133,132" lay "_V_(F)10.5m_(D)-25m"))
	 ((<= Mdepth 27.99949)   (setq col "129,107,183" lay "_V_(F)10.5m_(D)25m"))
	 ((<= Mdepth 29.99949)   (setq col "138,52,83" lay "_V_(F)10.5m_(D)28m"))
	 ((<= Mdepth 31.99949)   (setq col "245,101,83" lay "_V_(F)10.5m_(D)30m"))
	 ((<= Mdepth 35.99949)   (setq col "116,72,57" lay "_V_(F)10.5m_(D)32m"))
	 (( > Mdepth 35.99949)   (setq col "54,114,142" lay "_V_(F)10.5m_(D)36m"))
	 )
       )
      
      ;Standard Lots between 12.5m and 14.0m frontage
      ((<= Mfront 13.99949)
       
       (cond
	 ;depth range
	 ((<= Mdepth 24.99949)   (setq col "181,149,148" lay "PV_(F)12.5m_(D)-25m"))
	 ((<= Mdepth 27.99949)   (setq col "156,128,199" lay "PV_(F)12.5m_(D)25m"))
	 ((<= Mdepth 29.99949)   (setq col "174,72,103" lay "PV_(F)12.5m_(D)28m"))
	 ((<= Mdepth 31.99949)   (setq col "245,130,73" lay "PV_(F)12.5m_(D)30m"))
	 ((<= Mdepth 35.99949)   (setq col "114,89,71" lay "PV_(F)12.5m_(D)32m"))
	 (( > Mdepth 35.99949)   (setq col "73,142,164" lay "PV_(F)12.5m_(D)36m"))
	 )
       )
      
      ;Standard Lots between 14.0m and 16.0m frontage
      ((<= Mfront 15.99949)
       
       (cond
	 ;depth range
	 ((<= Mdepth 24.99949)   (setq col "195,162,168" lay "C_(F)14m_(D)-25m"))
	 ((<= Mdepth 27.99949)   (setq col "182,150,214" lay "C_(F)14m_(D)25m"))
	 ((<= Mdepth 29.99949)   (setq col "203,98,123" lay "C_(F)14m_(D)28m"))
	 ((<= Mdepth 31.99949)   (setq col "243,155,76" lay "C_(F)14m_(D)30m"))
	 ((<= Mdepth 35.99949)   (setq col "176,115,94" lay "C_(F)14m_(D)32m"))
	 (( > Mdepth 35.99949)   (setq col "103,169,182" lay "C_(F)14m_(D)36m"))
	 )
       )
      
      ;Standard Lots between 16.0m and 18.0m frontage
      ((<= Mfront 17.99949)
       
       (cond
	 ;depth range
	 ((<= Mdepth 24.99949)   (setq col "211,187,191" lay "PC_(F)16m_(D)-25m"))
	 ((<= Mdepth 27.99949)   (setq col "207,173,229" lay "PC_(F)16m_(D)25m"))
	 ((<= Mdepth 29.99949)   (setq col "221,132,146" lay "PC_(F)16m_(D)28m"))
	 ((<= Mdepth 31.99949)   (setq col "240,177,94" lay "PC_(F)16m_(D)30m"))
	 ((<= Mdepth 35.99949)   (setq col "196,151,135" lay "PC_(F)16m_(D)32m"))
	 (( > Mdepth 35.99949)   (setq col "136,195,200" lay "PC_(F)16m_(D)36m"))
	 )
       )
      
      ;Standard Lots between 18.0m and 20.0m frontage
      ((<= Mfront 19.99949)
       
       (cond
	 ;depth range
	 ((<= Mdepth 24.99949)   (setq col "225,209,212" lay "T_(F)18m_(D)-25m"))
	 ((<= Mdepth 27.99949)   (setq col "230,198,243" lay "T_(F)18m_(D)25m"))
	 ((<= Mdepth 29.99949)   (setq col "239,165,172" lay "T_(F)18m_(D)28m"))
	 ((<= Mdepth 31.99949)   (setq col "237,198,122" lay "T_(F)18m_(D)30m"))
	 ((<= Mdepth 35.99949)   (setq col "215,183,173" lay "T_(F)18m_(D)32m"))
	 (( > Mdepth 35.99949)   (setq col "170,219,218" lay "T_(F)18m_(D)36m"))
	 )
       )
      
      ;Standard Lots 20m frontage or greater
      (( > Mfront 19.99949)
       
       (cond
	 ;depth range
	 ((<= Mdepth 24.99949)   (setq col "241,221,226" lay "PT_(F)20m_(D)-25m"))
	 ((<= Mdepth 27.99949)   (setq col "231,211,248" lay "PT_(F)20m_(D)25m"))
	 ((<= Mdepth 29.99949)   (setq col "255,197,199" lay "PT_(F)20m_(D)28m"))
	 ((<= Mdepth 31.99949)   (setq col "236,217,153" lay "PT_(F)20m_(D)30m"))
	 ((<= Mdepth 35.99949)   (setq col "230,210,204" lay "PT_(F)20m_(D)32m"))
	 (( > Mdepth 35.99949)   (setq col "210,238,234" lay "PT_(F)20m_(D)36m"))
	 )
       )
      )
    
    (setq layx (vl-string-subst "" "," lay))
    (setq layx (vl-string-subst "" "," layx))
    
    (setq lay (strcat "SHG_Hatch_(FD)_" layx))
    (command "layer" "new" lay "")
    (command "layer" "color" "truecolor" col lay "")
    (command "LAYER" "SET" lay "")
    (command "color" "bylayer")
    (entmod (append (entget (tblobjname "layer" lay)) '((-3("AcCmTransparency" (1071 . 33554610))))))
    
    ;;;	(setq P1 (getpoint "\nSelect inside lot : "))
    (command "Bhatch" "s" ent "" "")
    (setq i (1+ i))
    )
    
  (print "Hatch completed")
  (terpri)  
  )

 

image.png.a79f256719b06aeb694f7805182d15a3.png

 

I receive the above message when I attempt to use the routine.

 

Also I note that you are calculating the depth of the lot incorrectly.

It should be the sum of the two longest lengths added together and then that result divided by two.

image.thumb.png.5fc2d51ddfee2e3c37ef2e39ea4763d4.png

 

Posted (edited)
7 hours ago, andyb57J said:

I receive the above message when I attempt to use the routine.

This is beacuse the input value for number of vertices to processed selection is nil, so you need to input value 4 (I added this to allow you to enter the HATCHING for a vertex count greater than 4 as well, as well as lower than 4).

 

7 hours ago, andyb57J said:

It should be the sum of the two longest lengths added together and then that result divided by two.

After this I did modification in code. Try with this:

 

;hatch lots based on both Frontage and Depth with RGB colours

(prompt "To run a LISP type: hl4")
(princ)

(defun c:hl4 (/ min_vertices ss len i ent ptlist j dist_lst max_val1 max_val2 min_pt max_pt mid_pt Mfront Mdepth P1 DN DE col lay pt1 pt2 pt3 Mdst colx layx)
  
  (setvar "cmdecho" 0)
  
  ;;;	(setq pt1 (getpoint "\nSelect first frontage point (Right click to exit) : "))
  ;;;	(if (/= nil pt1)(setq pt2 (getpoint pt1 "\nSelect second frontage point (Right click to exit) : ")))
  ;;;	(if (/= nil pt2)(setq pt3 (getpoint "\nSelect depth point (Right click to exit) : ")))
  (setq min_vertices 4)
  (setq min_vertices (getint (strcat "\nEnter the number of vertex to proccessed selection <" (itoa min_vertices) ">:")))
  (while (equal min_vertices nil)
    (prompt "\nThe input value can't be nil! Try again...")
    (setq min_vertices (getint (strcat "\nEnter the number of vertex to proccessed selection: ")))
    (princ)
    )
  
  (prompt "\Select entities for HATCH:")
  (setq ss (ssget (list (cons 0 "LWPOLYLINE") (cons 70 1) (cons -4 "<=") (cons 90 min_vertices))) ;; use that just to SEE if there are some LWPOLYLINES which are not CLOSED when trying to select entities for HATCHING
	len (sslength ss)
	i 0
	)
  
  (while ( < i len)
    
    (setq ent (ssname ss i)
	  ptlist (mapcar 'cdr (vl-remove-if-not '(lambda (x)  (= (car x) 10)) (entget ent)))
	  j 0)
       
    (repeat (length ptlist)
      (if (/= j (- (length ptlist) 1))
	(setq dist (distance (nth j ptlist) (nth (1+ j) ptlist))
	      dist_lst (cons dist dist_lst)
	      j (1+ j)
	      )
	(setq dist (distance (nth j ptlist) (nth 0 ptlist))
	      dist_lst (cons dist dist_lst)
	      )
	)
      )

    (setq dist_lst (vl-sort dist_lst '<)
	  max_val1 (nth (- (length dist_lst) 1) dist_lst) ;; find the first largest number from dist_lst
	  max_val2 (nth (- (length dist_lst) 2) dist_lst) ;; find the second largest number from dist_lst
	  )

;;;    (setq min_pt (nth 0 (vl-sort ptlist (function (lambda (pt1 pt2) (< (cadr pt1) (cadr pt2))))))
;;;	  max_pt (nth (- (length ptlist) 1) (vl-sort ptlist (function (lambda (pt1 pt2) (< (cadr pt1) (cadr pt2))))))
;;;	  mid_pt (polar min_pt (angle min_pt max_pt) (/ (distance min_pt max_pt) 2))
;;;	  )
    
    ;find frontage
    ;;;	(setq DN (- (cadr Pt2) (cadr Pt1)))
    ;;;	(setq DE (- (car Pt2) (car Pt1)))
    ;;;	(setq Mfront (sqrt(+(* DE DE)(* DN DN))))
    ;;; (setq Mfront (distance min_pt max_pt))
    (setq Mfront (apply 'min dist_lst)) ;; from dist_lst I find here the min distance between two vertices
    
    ;find depth
;;;    (setq DN (-(cadr mid_pt) (cadr min_pt)))
;;;    (setq DE (-(car mid_pt) (car min_pt)))
    (setq Mdepth (/ (+ max_val1 max_val2) 2)) ;; sum the max_val1 and max_val2 and divide by 2
    
    (setq col 1)
    
    (cond
      ;Terrace lots < 7.5m frontage - Change TE to TF for front loaded lots and TE to TR for rear loaded terraces.
      (( <= Mfront 7.49949)
       
       (cond
	 ;depth range
	 ((<= Mdepth 24.99949)	(setq col "198,110,78" lay "TE_(F)-7.5m_(D)-25m"))
	 ((<= Mdepth 27.99949) 	(setq col "192,76,54" lay "TE_(F)-7.5m_(D)25m"))
	 ((<= Mdepth 29.99949) 	(setq col "183,49,44" lay "TE_(F)-7.5m_(D)28m"))
	 ((<= Mdepth 31.99949) 	(setq col "171,35,40" lay "TE_(F)-7.5m_(D)30m"))
	 ((<= Mdepth 35.99949) 	(setq col "147,39,44" lay "TE_(F)-7.5m_(D)32m"))
	 (( > Mdepth 35.99949)	(setq col "138,42,43" lay "TE_(F)-7.5m_(D)36m"))
	 )
       )
      ;Terrace Lots 7.5m frontage - Change TE to TF for front loaded lots and TE to TR for rear loaded terraces.
      ((and(<= Mfront 7.50049 ))
       
       (cond
	 ;depth range
	 ((<= Mdepth 24.99949)   (setq col "104,101,159" lay "TE_(F)7.5m_(D)-25m"))
	 ((<= Mdepth 27.99949)   (setq col "97,94,155" lay "TE_(F)7.5m_(D)25m"))
	 ((<= Mdepth 29.99949)   (setq col "86,82,148" lay "TE_(F)7.5m_(D)28m"))
	 ((<= Mdepth 31.99949)   (setq col "81,70,137" lay "TE_(F)7.5m_(D)30m"))
	 ((<= Mdepth 35.99949)   (setq col "76,65,132" lay "TE_(F)7.5m_(D)32m"))
	 (( > Mdepth 35.99949)   (setq col "83,84,74" lay "TE_(F)7.5m_(D)36m"))
	 )
       )
      
      ;Terrace Lots between 7.5m and 10.5m frontage - Change TE to TF for front loaded lots and TE to TR for rear loaded terraces.
      ((<= Mfront 10.49949)
       
       (cond
	 ;depth range
	 ((<= Mdepth 24.99949)   (setq col "186,187,177" lay "TE_(F)7.5m+_(D)-25m"))
	 ((<= Mdepth 27.99949)   (setq col "168,169,158" lay "TE_(F)7.5m+_(D)25m"))
	 ((<= Mdepth 29.99949)   (setq col "145,147,136" lay "TE_(F)7.5m+_(D)28m"))
	 ((<= Mdepth 31.99949)   (setq col "126,127,116" lay "TE_(F)7.5m+_(D)30m"))
	 ((<= Mdepth 35.99949)   (setq col "101,102,92" lay "TE_(F)7.5m+_(D)32m"))
	 (( > Mdepth 35.99949)   (setq col "81,83,74" lay "TE_(F)7.5m+_(D)36m"))
	 )
       )
      
      ;Standard Lots between 10.5m and 12.5m frontage
      ((<= Mfront 12.49949)
       
       (cond
	 ;depth range
	 ((<= Mdepth 24.99949)   (setq col "169,133,132" lay "_V_(F)10.5m_(D)-25m"))
	 ((<= Mdepth 27.99949)   (setq col "129,107,183" lay "_V_(F)10.5m_(D)25m"))
	 ((<= Mdepth 29.99949)   (setq col "138,52,83" lay "_V_(F)10.5m_(D)28m"))
	 ((<= Mdepth 31.99949)   (setq col "245,101,83" lay "_V_(F)10.5m_(D)30m"))
	 ((<= Mdepth 35.99949)   (setq col "116,72,57" lay "_V_(F)10.5m_(D)32m"))
	 (( > Mdepth 35.99949)   (setq col "54,114,142" lay "_V_(F)10.5m_(D)36m"))
	 )
       )
      
      ;Standard Lots between 12.5m and 14.0m frontage
      ((<= Mfront 13.99949)
       
       (cond
	 ;depth range
	 ((<= Mdepth 24.99949)   (setq col "181,149,148" lay "PV_(F)12.5m_(D)-25m"))
	 ((<= Mdepth 27.99949)   (setq col "156,128,199" lay "PV_(F)12.5m_(D)25m"))
	 ((<= Mdepth 29.99949)   (setq col "174,72,103" lay "PV_(F)12.5m_(D)28m"))
	 ((<= Mdepth 31.99949)   (setq col "245,130,73" lay "PV_(F)12.5m_(D)30m"))
	 ((<= Mdepth 35.99949)   (setq col "114,89,71" lay "PV_(F)12.5m_(D)32m"))
	 (( > Mdepth 35.99949)   (setq col "73,142,164" lay "PV_(F)12.5m_(D)36m"))
	 )
       )
      
      ;Standard Lots between 14.0m and 16.0m frontage
      ((<= Mfront 15.99949)
       
       (cond
	 ;depth range
	 ((<= Mdepth 24.99949)   (setq col "195,162,168" lay "C_(F)14m_(D)-25m"))
	 ((<= Mdepth 27.99949)   (setq col "182,150,214" lay "C_(F)14m_(D)25m"))
	 ((<= Mdepth 29.99949)   (setq col "203,98,123" lay "C_(F)14m_(D)28m"))
	 ((<= Mdepth 31.99949)   (setq col "243,155,76" lay "C_(F)14m_(D)30m"))
	 ((<= Mdepth 35.99949)   (setq col "176,115,94" lay "C_(F)14m_(D)32m"))
	 (( > Mdepth 35.99949)   (setq col "103,169,182" lay "C_(F)14m_(D)36m"))
	 )
       )
      
      ;Standard Lots between 16.0m and 18.0m frontage
      ((<= Mfront 17.99949)
       
       (cond
	 ;depth range
	 ((<= Mdepth 24.99949)   (setq col "211,187,191" lay "PC_(F)16m_(D)-25m"))
	 ((<= Mdepth 27.99949)   (setq col "207,173,229" lay "PC_(F)16m_(D)25m"))
	 ((<= Mdepth 29.99949)   (setq col "221,132,146" lay "PC_(F)16m_(D)28m"))
	 ((<= Mdepth 31.99949)   (setq col "240,177,94" lay "PC_(F)16m_(D)30m"))
	 ((<= Mdepth 35.99949)   (setq col "196,151,135" lay "PC_(F)16m_(D)32m"))
	 (( > Mdepth 35.99949)   (setq col "136,195,200" lay "PC_(F)16m_(D)36m"))
	 )
       )
      
      ;Standard Lots between 18.0m and 20.0m frontage
      ((<= Mfront 19.99949)
       
       (cond
	 ;depth range
	 ((<= Mdepth 24.99949)   (setq col "225,209,212" lay "T_(F)18m_(D)-25m"))
	 ((<= Mdepth 27.99949)   (setq col "230,198,243" lay "T_(F)18m_(D)25m"))
	 ((<= Mdepth 29.99949)   (setq col "239,165,172" lay "T_(F)18m_(D)28m"))
	 ((<= Mdepth 31.99949)   (setq col "237,198,122" lay "T_(F)18m_(D)30m"))
	 ((<= Mdepth 35.99949)   (setq col "215,183,173" lay "T_(F)18m_(D)32m"))
	 (( > Mdepth 35.99949)   (setq col "170,219,218" lay "T_(F)18m_(D)36m"))
	 )
       )
      
      ;Standard Lots 20m frontage or greater
      (( > Mfront 19.99949)
       
       (cond
	 ;depth range
	 ((<= Mdepth 24.99949)   (setq col "241,221,226" lay "PT_(F)20m_(D)-25m"))
	 ((<= Mdepth 27.99949)   (setq col "231,211,248" lay "PT_(F)20m_(D)25m"))
	 ((<= Mdepth 29.99949)   (setq col "255,197,199" lay "PT_(F)20m_(D)28m"))
	 ((<= Mdepth 31.99949)   (setq col "236,217,153" lay "PT_(F)20m_(D)30m"))
	 ((<= Mdepth 35.99949)   (setq col "230,210,204" lay "PT_(F)20m_(D)32m"))
	 (( > Mdepth 35.99949)   (setq col "210,238,234" lay "PT_(F)20m_(D)36m"))
	 )
       )
      )
    
    (setq layx (vl-string-subst "" "," lay))
    (setq layx (vl-string-subst "" "," layx))
    
    (setq lay (strcat "SHG_Hatch_(FD)_" layx))
    (command "layer" "new" lay "")
    (command "layer" "color" "truecolor" col lay "")
    (command "LAYER" "SET" lay "")
    (command "color" "bylayer")
    (entmod (append (entget (tblobjname "layer" lay)) '((-3("AcCmTransparency" (1071 . 33554610))))))
    
    ;;;	(setq P1 (getpoint "\nSelect inside lot : "))
    (command "Bhatch" "s" ent "" "")
    (setq i (1+ i))
    )
    
  (print "Hatch completed")
  (terpri)  
  )

 

Edited by Saxlle
  • Like 1
Posted (edited)
1 hour ago, Saxlle said:

This is beacuse the input value for number of vertices to processed selection is nil, so you need to input value 4 (I added this to allow you to enter the HATCHING for a vertex count greater than 4 as well, as well as lower than 4).

 

After this I did modification in code. Try with this:

 

;hatch lots based on both Frontage and Depth with RGB colours

(prompt "To run a LISP type: hl4")
(princ)

(defun c:hl4 (/ min_vertices ss len i ent ptlist j dist_lst max_val1 max_val2 min_pt max_pt mid_pt Mfront Mdepth P1 DN DE col lay pt1 pt2 pt3 Mdst colx layx)
  
  (setvar "cmdecho" 0)
  
  ;;;	(setq pt1 (getpoint "\nSelect first frontage point (Right click to exit) : "))
  ;;;	(if (/= nil pt1)(setq pt2 (getpoint pt1 "\nSelect second frontage point (Right click to exit) : ")))
  ;;;	(if (/= nil pt2)(setq pt3 (getpoint "\nSelect depth point (Right click to exit) : ")))
  (setq min_vertices 4)
  (setq min_vertices (getint (strcat "\nEnter the number of vertex to proccessed selection <" (itoa min_vertices) ">:")))
  (while (equal min_vertices nil)
    (prompt "\nThe input value can't be nil! Try again...")
    (setq min_vertices (getint (strcat "\nEnter the number of vertex to proccessed selection: ")))
    (princ)
    )
  
  (prompt "\Select entities for HATCH:")
  (setq ss (ssget (list (cons 0 "LWPOLYLINE") (cons 70 1) (cons -4 "<=") (cons 90 min_vertices))) ;; use that just to SEE if there are some LWPOLYLINES which are not CLOSED when trying to select entities for HATCHING
	len (sslength ss)
	i 0
	)
  
  (while ( < i len)
    
    (setq ent (ssname ss i)
	  ptlist (mapcar 'cdr (vl-remove-if-not '(lambda (x)  (= (car x) 10)) (entget ent)))
	  j 0)
       
    (repeat (length ptlist)
      (if (/= j (- (length ptlist) 1))
	(setq dist (distance (nth j ptlist) (nth (1+ j) ptlist))
	      dist_lst (cons dist dist_lst)
	      j (1+ j)
	      )
	(setq dist (distance (nth j ptlist) (nth 0 ptlist))
	      dist_lst (cons dist dist_lst)
	      )
	)
      )

    (setq dist_lst (vl-sort dist_lst '<)
	  max_val1 (nth (- (length dist_lst) 1) dist_lst) ;; find the first largest number from dist_lst
	  max_val2 (nth (- (length dist_lst) 2) dist_lst) ;; find the second largest number from dist_lst
	  )

;;;    (setq min_pt (nth 0 (vl-sort ptlist (function (lambda (pt1 pt2) (< (cadr pt1) (cadr pt2))))))
;;;	  max_pt (nth (- (length ptlist) 1) (vl-sort ptlist (function (lambda (pt1 pt2) (< (cadr pt1) (cadr pt2))))))
;;;	  mid_pt (polar min_pt (angle min_pt max_pt) (/ (distance min_pt max_pt) 2))
;;;	  )
    
    ;find frontage
    ;;;	(setq DN (- (cadr Pt2) (cadr Pt1)))
    ;;;	(setq DE (- (car Pt2) (car Pt1)))
    ;;;	(setq Mfront (sqrt(+(* DE DE)(* DN DN))))
    ;;; (setq Mfront (distance min_pt max_pt))
    (setq Mfront (apply 'min dist_lst)) ;; from dist_lst I find here the min distance between two vertices
    
    ;find depth
;;;    (setq DN (-(cadr mid_pt) (cadr min_pt)))
;;;    (setq DE (-(car mid_pt) (car min_pt)))
    (setq Mdepth (/ (+ max_val1 max_val2) 2)) ;; sum the max_val1 and max_val2 and divide by 2
    
    (setq col 1)
    
    (cond
      ;Terrace lots < 7.5m frontage - Change TE to TF for front loaded lots and TE to TR for rear loaded terraces.
      (( <= Mfront 7.49949)
       
       (cond
	 ;depth range
	 ((<= Mdepth 24.99949)	(setq col "198,110,78" lay "TE_(F)-7.5m_(D)-25m"))
	 ((<= Mdepth 27.99949) 	(setq col "192,76,54" lay "TE_(F)-7.5m_(D)25m"))
	 ((<= Mdepth 29.99949) 	(setq col "183,49,44" lay "TE_(F)-7.5m_(D)28m"))
	 ((<= Mdepth 31.99949) 	(setq col "171,35,40" lay "TE_(F)-7.5m_(D)30m"))
	 ((<= Mdepth 35.99949) 	(setq col "147,39,44" lay "TE_(F)-7.5m_(D)32m"))
	 (( > Mdepth 35.99949)	(setq col "138,42,43" lay "TE_(F)-7.5m_(D)36m"))
	 )
       )
      ;Terrace Lots 7.5m frontage - Change TE to TF for front loaded lots and TE to TR for rear loaded terraces.
      ((and(<= Mfront 7.50049 ))
       
       (cond
	 ;depth range
	 ((<= Mdepth 24.99949)   (setq col "104,101,159" lay "TE_(F)7.5m_(D)-25m"))
	 ((<= Mdepth 27.99949)   (setq col "97,94,155" lay "TE_(F)7.5m_(D)25m"))
	 ((<= Mdepth 29.99949)   (setq col "86,82,148" lay "TE_(F)7.5m_(D)28m"))
	 ((<= Mdepth 31.99949)   (setq col "81,70,137" lay "TE_(F)7.5m_(D)30m"))
	 ((<= Mdepth 35.99949)   (setq col "76,65,132" lay "TE_(F)7.5m_(D)32m"))
	 (( > Mdepth 35.99949)   (setq col "83,84,74" lay "TE_(F)7.5m_(D)36m"))
	 )
       )
      
      ;Terrace Lots between 7.5m and 10.5m frontage - Change TE to TF for front loaded lots and TE to TR for rear loaded terraces.
      ((<= Mfront 10.49949)
       
       (cond
	 ;depth range
	 ((<= Mdepth 24.99949)   (setq col "186,187,177" lay "TE_(F)7.5m+_(D)-25m"))
	 ((<= Mdepth 27.99949)   (setq col "168,169,158" lay "TE_(F)7.5m+_(D)25m"))
	 ((<= Mdepth 29.99949)   (setq col "145,147,136" lay "TE_(F)7.5m+_(D)28m"))
	 ((<= Mdepth 31.99949)   (setq col "126,127,116" lay "TE_(F)7.5m+_(D)30m"))
	 ((<= Mdepth 35.99949)   (setq col "101,102,92" lay "TE_(F)7.5m+_(D)32m"))
	 (( > Mdepth 35.99949)   (setq col "81,83,74" lay "TE_(F)7.5m+_(D)36m"))
	 )
       )
      
      ;Standard Lots between 10.5m and 12.5m frontage
      ((<= Mfront 12.49949)
       
       (cond
	 ;depth range
	 ((<= Mdepth 24.99949)   (setq col "169,133,132" lay "_V_(F)10.5m_(D)-25m"))
	 ((<= Mdepth 27.99949)   (setq col "129,107,183" lay "_V_(F)10.5m_(D)25m"))
	 ((<= Mdepth 29.99949)   (setq col "138,52,83" lay "_V_(F)10.5m_(D)28m"))
	 ((<= Mdepth 31.99949)   (setq col "245,101,83" lay "_V_(F)10.5m_(D)30m"))
	 ((<= Mdepth 35.99949)   (setq col "116,72,57" lay "_V_(F)10.5m_(D)32m"))
	 (( > Mdepth 35.99949)   (setq col "54,114,142" lay "_V_(F)10.5m_(D)36m"))
	 )
       )
      
      ;Standard Lots between 12.5m and 14.0m frontage
      ((<= Mfront 13.99949)
       
       (cond
	 ;depth range
	 ((<= Mdepth 24.99949)   (setq col "181,149,148" lay "PV_(F)12.5m_(D)-25m"))
	 ((<= Mdepth 27.99949)   (setq col "156,128,199" lay "PV_(F)12.5m_(D)25m"))
	 ((<= Mdepth 29.99949)   (setq col "174,72,103" lay "PV_(F)12.5m_(D)28m"))
	 ((<= Mdepth 31.99949)   (setq col "245,130,73" lay "PV_(F)12.5m_(D)30m"))
	 ((<= Mdepth 35.99949)   (setq col "114,89,71" lay "PV_(F)12.5m_(D)32m"))
	 (( > Mdepth 35.99949)   (setq col "73,142,164" lay "PV_(F)12.5m_(D)36m"))
	 )
       )
      
      ;Standard Lots between 14.0m and 16.0m frontage
      ((<= Mfront 15.99949)
       
       (cond
	 ;depth range
	 ((<= Mdepth 24.99949)   (setq col "195,162,168" lay "C_(F)14m_(D)-25m"))
	 ((<= Mdepth 27.99949)   (setq col "182,150,214" lay "C_(F)14m_(D)25m"))
	 ((<= Mdepth 29.99949)   (setq col "203,98,123" lay "C_(F)14m_(D)28m"))
	 ((<= Mdepth 31.99949)   (setq col "243,155,76" lay "C_(F)14m_(D)30m"))
	 ((<= Mdepth 35.99949)   (setq col "176,115,94" lay "C_(F)14m_(D)32m"))
	 (( > Mdepth 35.99949)   (setq col "103,169,182" lay "C_(F)14m_(D)36m"))
	 )
       )
      
      ;Standard Lots between 16.0m and 18.0m frontage
      ((<= Mfront 17.99949)
       
       (cond
	 ;depth range
	 ((<= Mdepth 24.99949)   (setq col "211,187,191" lay "PC_(F)16m_(D)-25m"))
	 ((<= Mdepth 27.99949)   (setq col "207,173,229" lay "PC_(F)16m_(D)25m"))
	 ((<= Mdepth 29.99949)   (setq col "221,132,146" lay "PC_(F)16m_(D)28m"))
	 ((<= Mdepth 31.99949)   (setq col "240,177,94" lay "PC_(F)16m_(D)30m"))
	 ((<= Mdepth 35.99949)   (setq col "196,151,135" lay "PC_(F)16m_(D)32m"))
	 (( > Mdepth 35.99949)   (setq col "136,195,200" lay "PC_(F)16m_(D)36m"))
	 )
       )
      
      ;Standard Lots between 18.0m and 20.0m frontage
      ((<= Mfront 19.99949)
       
       (cond
	 ;depth range
	 ((<= Mdepth 24.99949)   (setq col "225,209,212" lay "T_(F)18m_(D)-25m"))
	 ((<= Mdepth 27.99949)   (setq col "230,198,243" lay "T_(F)18m_(D)25m"))
	 ((<= Mdepth 29.99949)   (setq col "239,165,172" lay "T_(F)18m_(D)28m"))
	 ((<= Mdepth 31.99949)   (setq col "237,198,122" lay "T_(F)18m_(D)30m"))
	 ((<= Mdepth 35.99949)   (setq col "215,183,173" lay "T_(F)18m_(D)32m"))
	 (( > Mdepth 35.99949)   (setq col "170,219,218" lay "T_(F)18m_(D)36m"))
	 )
       )
      
      ;Standard Lots 20m frontage or greater
      (( > Mfront 19.99949)
       
       (cond
	 ;depth range
	 ((<= Mdepth 24.99949)   (setq col "241,221,226" lay "PT_(F)20m_(D)-25m"))
	 ((<= Mdepth 27.99949)   (setq col "231,211,248" lay "PT_(F)20m_(D)25m"))
	 ((<= Mdepth 29.99949)   (setq col "255,197,199" lay "PT_(F)20m_(D)28m"))
	 ((<= Mdepth 31.99949)   (setq col "236,217,153" lay "PT_(F)20m_(D)30m"))
	 ((<= Mdepth 35.99949)   (setq col "230,210,204" lay "PT_(F)20m_(D)32m"))
	 (( > Mdepth 35.99949)   (setq col "210,238,234" lay "PT_(F)20m_(D)36m"))
	 )
       )
      )
    
    (setq layx (vl-string-subst "" "," lay))
    (setq layx (vl-string-subst "" "," layx))
    
    (setq lay (strcat "SHG_Hatch_(FD)_" layx))
    (command "layer" "new" lay "")
    (command "layer" "color" "truecolor" col lay "")
    (command "LAYER" "SET" lay "")
    (command "color" "bylayer")
    (entmod (append (entget (tblobjname "layer" lay)) '((-3("AcCmTransparency" (1071 . 33554610))))))
    
    ;;;	(setq P1 (getpoint "\nSelect inside lot : "))
    (command "Bhatch" "s" ent "" "")
    (setq i (1+ i))
    )
    
  (print "Hatch completed")
  (terpri)  
  )

 

lot selection is working perfectly.  The calculation of the frontages and depths is not functioning correctly still. it seems to be dividing the mfront by 2 as well as the mdepth.

 

Can you set mfront component to be the shortest distance between two vertices and the mdepth component to be the length of second longest distance between two vertices without any division. 

 

image.thumb.png.d6244c3e8626cb3c1c67af5aa3e848cd.png

 

With all being right hatch for parcel 146 should be on layer  SHG_Hatch_(FD)_C_(F)14m_(D)28m, hatch or Parcel 144 should be on layer SHG_Hatch_(FD)_T_(F)18m_(D)25m, hatch for parcel 143 should be on layer SHG_Hatch_(FD)_C_(F)14m_(D)25m, hatch for parcel 138 should be on layer SHG_Hatch_(FD)_PV_(F)12.5m_(D)36m, hatch for parcel 137 should be on layer SHG_Hatch_(FD)_PC_(F)16m_(D)36m, etc.

image.thumb.png.6d62a9f413de5eec2a145c43de059794.png

Edited by andyb57J
Posted

@andyb57J

 

From picture 1 I get thoose layers for parcels. Also, according to your last request, the Mfront will always be the SHORTEST distance between two vertices. From your last request, the Mdepth will always be the SECOND largest number measuring distances between every vertices. Thoose values are stored in dist_lst variable.  Description is on the Picture 2.  The colors of the hatch is not as yours!

 

picture1.thumb.JPG.09ac92bca2a8b7541a1fee2dcf920e77.JPG

Picture 1.

 

picture2.thumb.JPG.36561e1bde09971a8823120960d2e884.JPG

Picture 2.

 

This is the last modification from me, for the rest, do it on your own:

;hatch lots based on both Frontage and Depth with RGB colours

(prompt "To run a LISP type: hl4")
(princ)

(defun c:hl4 (/ min_vertices ss len i ent ptlist j dist_lst max_val1 max_val2 min_pt max_pt mid_pt Mfront Mdepth P1 DN DE col lay pt1 pt2 pt3 Mdst colx layx)
  
  (setvar "cmdecho" 0)
  
  ;;;	(setq pt1 (getpoint "\nSelect first frontage point (Right click to exit) : "))
  ;;;	(if (/= nil pt1)(setq pt2 (getpoint pt1 "\nSelect second frontage point (Right click to exit) : ")))
  ;;;	(if (/= nil pt2)(setq pt3 (getpoint "\nSelect depth point (Right click to exit) : ")))
  (setq min_vertices 4)
  (setq min_vertices (getint (strcat "\nEnter the number of vertex to proccessed selection <" (itoa min_vertices) ">:")))
  (while (equal min_vertices nil)
    (prompt "\nThe input value can't be nil! Try again...")
    (setq min_vertices (getint (strcat "\nEnter the number of vertex to proccessed selection: ")))
    (princ)
    )
  
  (prompt "\Select entities for HATCH:")
  (setq ss (ssget (list (cons 0 "LWPOLYLINE") (cons 70 1) (cons -4 "<=") (cons 90 min_vertices))) ;; use that just to SEE if there are some LWPOLYLINES which are not CLOSED when trying to select entities for HATCHING
	len (sslength ss)
	i 0
	)
  
  (while ( < i len)
    
    (setq ent (ssname ss i)
	  ptlist (mapcar 'cdr (vl-remove-if-not '(lambda (x)  (= (car x) 10)) (entget ent)))
	  j 0
	  dist_lst nil
	  )
       
    (repeat (length ptlist)
      (if (/= j (- (length ptlist) 1))
	(setq dist (distance (nth j ptlist) (nth (1+ j) ptlist))
	      dist_lst (cons dist dist_lst)
	      j (1+ j)
	      )
	(setq dist (distance (nth j ptlist) (nth 0 ptlist))
	      dist_lst (cons dist dist_lst)
	      )
	)
      )

    (setq dist_lst (vl-sort dist_lst '<)
;;;	  max_val1 (nth (- (length dist_lst) 1) dist_lst) ;; find the first largest number from dist_lst
	  max_val2 (nth (- (length dist_lst) 2) dist_lst) ;; find the second largest number from dist_lst
	  )

;;;    (setq min_pt (nth 0 (vl-sort ptlist (function (lambda (pt1 pt2) (< (cadr pt1) (cadr pt2))))))
;;;	  max_pt (nth (- (length ptlist) 1) (vl-sort ptlist (function (lambda (pt1 pt2) (< (cadr pt1) (cadr pt2))))))
;;;	  mid_pt (polar min_pt (angle min_pt max_pt) (/ (distance min_pt max_pt) 2))
;;;	  )
    
    ;find frontage
    ;;;	(setq DN (- (cadr Pt2) (cadr Pt1)))
    ;;;	(setq DE (- (car Pt2) (car Pt1)))
    ;;;	(setq Mfront (sqrt(+(* DE DE)(* DN DN))))
    ;;; (setq Mfront (distance min_pt max_pt))
    (setq Mfront (apply 'min dist_lst)) ;; from dist_lst I find here the min distance between two vertices
    
    ;find depth
;;;    (setq DN (-(cadr mid_pt) (cadr min_pt)))
;;;    (setq DE (-(car mid_pt) (car min_pt)))
    (setq Mdepth max_val2) ;; sum the max_val1 and max_val2 and divide by 2
    
    (setq col 1)
    
    (cond
      ;Terrace lots < 7.5m frontage - Change TE to TF for front loaded lots and TE to TR for rear loaded terraces.
      (( <= Mfront 7.49949)
       
       (cond
	 ;depth range
	 ((<= Mdepth 24.99949)	(setq col "198,110,78" lay "TE_(F)-7.5m_(D)-25m"))
	 ((<= Mdepth 27.99949) 	(setq col "192,76,54" lay "TE_(F)-7.5m_(D)25m"))
	 ((<= Mdepth 29.99949) 	(setq col "183,49,44" lay "TE_(F)-7.5m_(D)28m"))
	 ((<= Mdepth 31.99949) 	(setq col "171,35,40" lay "TE_(F)-7.5m_(D)30m"))
	 ((<= Mdepth 35.99949) 	(setq col "147,39,44" lay "TE_(F)-7.5m_(D)32m"))
	 (( > Mdepth 35.99949)	(setq col "138,42,43" lay "TE_(F)-7.5m_(D)36m"))
	 )
       )
      ;Terrace Lots 7.5m frontage - Change TE to TF for front loaded lots and TE to TR for rear loaded terraces.
      ((and(<= Mfront 7.50049 ))
       
       (cond
	 ;depth range
	 ((<= Mdepth 24.99949)   (setq col "104,101,159" lay "TE_(F)7.5m_(D)-25m"))
	 ((<= Mdepth 27.99949)   (setq col "97,94,155" lay "TE_(F)7.5m_(D)25m"))
	 ((<= Mdepth 29.99949)   (setq col "86,82,148" lay "TE_(F)7.5m_(D)28m"))
	 ((<= Mdepth 31.99949)   (setq col "81,70,137" lay "TE_(F)7.5m_(D)30m"))
	 ((<= Mdepth 35.99949)   (setq col "76,65,132" lay "TE_(F)7.5m_(D)32m"))
	 (( > Mdepth 35.99949)   (setq col "83,84,74" lay "TE_(F)7.5m_(D)36m"))
	 )
       )
      
      ;Terrace Lots between 7.5m and 10.5m frontage - Change TE to TF for front loaded lots and TE to TR for rear loaded terraces.
      ((<= Mfront 10.49949)
       
       (cond
	 ;depth range
	 ((<= Mdepth 24.99949)   (setq col "186,187,177" lay "TE_(F)7.5m+_(D)-25m"))
	 ((<= Mdepth 27.99949)   (setq col "168,169,158" lay "TE_(F)7.5m+_(D)25m"))
	 ((<= Mdepth 29.99949)   (setq col "145,147,136" lay "TE_(F)7.5m+_(D)28m"))
	 ((<= Mdepth 31.99949)   (setq col "126,127,116" lay "TE_(F)7.5m+_(D)30m"))
	 ((<= Mdepth 35.99949)   (setq col "101,102,92" lay "TE_(F)7.5m+_(D)32m"))
	 (( > Mdepth 35.99949)   (setq col "81,83,74" lay "TE_(F)7.5m+_(D)36m"))
	 )
       )
      
      ;Standard Lots between 10.5m and 12.5m frontage
      ((<= Mfront 12.49949)
       
       (cond
	 ;depth range
	 ((<= Mdepth 24.99949)   (setq col "169,133,132" lay "_V_(F)10.5m_(D)-25m"))
	 ((<= Mdepth 27.99949)   (setq col "129,107,183" lay "_V_(F)10.5m_(D)25m"))
	 ((<= Mdepth 29.99949)   (setq col "138,52,83" lay "_V_(F)10.5m_(D)28m"))
	 ((<= Mdepth 31.99949)   (setq col "245,101,83" lay "_V_(F)10.5m_(D)30m"))
	 ((<= Mdepth 35.99949)   (setq col "116,72,57" lay "_V_(F)10.5m_(D)32m"))
	 (( > Mdepth 35.99949)   (setq col "54,114,142" lay "_V_(F)10.5m_(D)36m"))
	 )
       )
      
      ;Standard Lots between 12.5m and 14.0m frontage
      ((<= Mfront 13.99949)
       
       (cond
	 ;depth range
	 ((<= Mdepth 24.99949)   (setq col "181,149,148" lay "PV_(F)12.5m_(D)-25m"))
	 ((<= Mdepth 27.99949)   (setq col "156,128,199" lay "PV_(F)12.5m_(D)25m"))
	 ((<= Mdepth 29.99949)   (setq col "174,72,103" lay "PV_(F)12.5m_(D)28m"))
	 ((<= Mdepth 31.99949)   (setq col "245,130,73" lay "PV_(F)12.5m_(D)30m"))
	 ((<= Mdepth 35.99949)   (setq col "114,89,71" lay "PV_(F)12.5m_(D)32m"))
	 (( > Mdepth 35.99949)   (setq col "73,142,164" lay "PV_(F)12.5m_(D)36m"))
	 )
       )
      
      ;Standard Lots between 14.0m and 16.0m frontage
      ((<= Mfront 15.99949)
       
       (cond
	 ;depth range
	 ((<= Mdepth 24.99949)   (setq col "195,162,168" lay "C_(F)14m_(D)-25m"))
	 ((<= Mdepth 27.99949)   (setq col "182,150,214" lay "C_(F)14m_(D)25m"))
	 ((<= Mdepth 29.99949)   (setq col "203,98,123" lay "C_(F)14m_(D)28m"))
	 ((<= Mdepth 31.99949)   (setq col "243,155,76" lay "C_(F)14m_(D)30m"))
	 ((<= Mdepth 35.99949)   (setq col "176,115,94" lay "C_(F)14m_(D)32m"))
	 (( > Mdepth 35.99949)   (setq col "103,169,182" lay "C_(F)14m_(D)36m"))
	 )
       )
      
      ;Standard Lots between 16.0m and 18.0m frontage
      ((<= Mfront 17.99949)
       
       (cond
	 ;depth range
	 ((<= Mdepth 24.99949)   (setq col "211,187,191" lay "PC_(F)16m_(D)-25m"))
	 ((<= Mdepth 27.99949)   (setq col "207,173,229" lay "PC_(F)16m_(D)25m"))
	 ((<= Mdepth 29.99949)   (setq col "221,132,146" lay "PC_(F)16m_(D)28m"))
	 ((<= Mdepth 31.99949)   (setq col "240,177,94" lay "PC_(F)16m_(D)30m"))
	 ((<= Mdepth 35.99949)   (setq col "196,151,135" lay "PC_(F)16m_(D)32m"))
	 (( > Mdepth 35.99949)   (setq col "136,195,200" lay "PC_(F)16m_(D)36m"))
	 )
       )
      
      ;Standard Lots between 18.0m and 20.0m frontage
      ((<= Mfront 19.99949)
       
       (cond
	 ;depth range
	 ((<= Mdepth 24.99949)   (setq col "225,209,212" lay "T_(F)18m_(D)-25m"))
	 ((<= Mdepth 27.99949)   (setq col "230,198,243" lay "T_(F)18m_(D)25m"))
	 ((<= Mdepth 29.99949)   (setq col "239,165,172" lay "T_(F)18m_(D)28m"))
	 ((<= Mdepth 31.99949)   (setq col "237,198,122" lay "T_(F)18m_(D)30m"))
	 ((<= Mdepth 35.99949)   (setq col "215,183,173" lay "T_(F)18m_(D)32m"))
	 (( > Mdepth 35.99949)   (setq col "170,219,218" lay "T_(F)18m_(D)36m"))
	 )
       )
      
      ;Standard Lots 20m frontage or greater
      (( > Mfront 19.99949)
       
       (cond
	 ;depth range
	 ((<= Mdepth 24.99949)   (setq col "241,221,226" lay "PT_(F)20m_(D)-25m"))
	 ((<= Mdepth 27.99949)   (setq col "231,211,248" lay "PT_(F)20m_(D)25m"))
	 ((<= Mdepth 29.99949)   (setq col "255,197,199" lay "PT_(F)20m_(D)28m"))
	 ((<= Mdepth 31.99949)   (setq col "236,217,153" lay "PT_(F)20m_(D)30m"))
	 ((<= Mdepth 35.99949)   (setq col "230,210,204" lay "PT_(F)20m_(D)32m"))
	 (( > Mdepth 35.99949)   (setq col "210,238,234" lay "PT_(F)20m_(D)36m"))
	 )
       )
      )
    
    (setq layx (vl-string-subst "" "," lay))
    (setq layx (vl-string-subst "" "," layx))
    
    (setq lay (strcat "SHG_Hatch_(FD)_" layx))
    (command "layer" "new" lay "")
    (command "layer" "color" "truecolor" col lay "")
    (command "LAYER" "SET" lay "")
    (command "color" "bylayer")
    (entmod (append (entget (tblobjname "layer" lay)) '((-3("AcCmTransparency" (1071 . 33554610))))))
    
    ;;;	(setq P1 (getpoint "\nSelect inside lot : "))
    (command "Bhatch" "s" ent "" "")
    (setq i (1+ i))
    )
    
  (print "Hatch completed")
  (terpri)  
  )

 

Best regards.

  • Like 1
Posted
14 minutes ago, Saxlle said:

@andyb57J

 

From picture 1 I get thoose layers for parcels. Also, according to your last request, the Mfront will always be the SHORTEST distance between two vertices. From your last request, the Mdepth will always be the SECOND largest number measuring distances between every vertices. Thoose values are stored in dist_lst variable.  Description is on the Picture 2.  The colors of the hatch is not as yours!

 

picture1.thumb.JPG.09ac92bca2a8b7541a1fee2dcf920e77.JPG

Picture 1.

 

picture2.thumb.JPG.36561e1bde09971a8823120960d2e884.JPG

Picture 2.

 

This is the last modification from me, for the rest, do it on your own:

;hatch lots based on both Frontage and Depth with RGB colours

(prompt "To run a LISP type: hl4")
(princ)

(defun c:hl4 (/ min_vertices ss len i ent ptlist j dist_lst max_val1 max_val2 min_pt max_pt mid_pt Mfront Mdepth P1 DN DE col lay pt1 pt2 pt3 Mdst colx layx)
  
  (setvar "cmdecho" 0)
  
  ;;;	(setq pt1 (getpoint "\nSelect first frontage point (Right click to exit) : "))
  ;;;	(if (/= nil pt1)(setq pt2 (getpoint pt1 "\nSelect second frontage point (Right click to exit) : ")))
  ;;;	(if (/= nil pt2)(setq pt3 (getpoint "\nSelect depth point (Right click to exit) : ")))
  (setq min_vertices 4)
  (setq min_vertices (getint (strcat "\nEnter the number of vertex to proccessed selection <" (itoa min_vertices) ">:")))
  (while (equal min_vertices nil)
    (prompt "\nThe input value can't be nil! Try again...")
    (setq min_vertices (getint (strcat "\nEnter the number of vertex to proccessed selection: ")))
    (princ)
    )
  
  (prompt "\Select entities for HATCH:")
  (setq ss (ssget (list (cons 0 "LWPOLYLINE") (cons 70 1) (cons -4 "<=") (cons 90 min_vertices))) ;; use that just to SEE if there are some LWPOLYLINES which are not CLOSED when trying to select entities for HATCHING
	len (sslength ss)
	i 0
	)
  
  (while ( < i len)
    
    (setq ent (ssname ss i)
	  ptlist (mapcar 'cdr (vl-remove-if-not '(lambda (x)  (= (car x) 10)) (entget ent)))
	  j 0
	  dist_lst nil
	  )
       
    (repeat (length ptlist)
      (if (/= j (- (length ptlist) 1))
	(setq dist (distance (nth j ptlist) (nth (1+ j) ptlist))
	      dist_lst (cons dist dist_lst)
	      j (1+ j)
	      )
	(setq dist (distance (nth j ptlist) (nth 0 ptlist))
	      dist_lst (cons dist dist_lst)
	      )
	)
      )

    (setq dist_lst (vl-sort dist_lst '<)
;;;	  max_val1 (nth (- (length dist_lst) 1) dist_lst) ;; find the first largest number from dist_lst
	  max_val2 (nth (- (length dist_lst) 2) dist_lst) ;; find the second largest number from dist_lst
	  )

;;;    (setq min_pt (nth 0 (vl-sort ptlist (function (lambda (pt1 pt2) (< (cadr pt1) (cadr pt2))))))
;;;	  max_pt (nth (- (length ptlist) 1) (vl-sort ptlist (function (lambda (pt1 pt2) (< (cadr pt1) (cadr pt2))))))
;;;	  mid_pt (polar min_pt (angle min_pt max_pt) (/ (distance min_pt max_pt) 2))
;;;	  )
    
    ;find frontage
    ;;;	(setq DN (- (cadr Pt2) (cadr Pt1)))
    ;;;	(setq DE (- (car Pt2) (car Pt1)))
    ;;;	(setq Mfront (sqrt(+(* DE DE)(* DN DN))))
    ;;; (setq Mfront (distance min_pt max_pt))
    (setq Mfront (apply 'min dist_lst)) ;; from dist_lst I find here the min distance between two vertices
    
    ;find depth
;;;    (setq DN (-(cadr mid_pt) (cadr min_pt)))
;;;    (setq DE (-(car mid_pt) (car min_pt)))
    (setq Mdepth max_val2) ;; sum the max_val1 and max_val2 and divide by 2
    
    (setq col 1)
    
    (cond
      ;Terrace lots < 7.5m frontage - Change TE to TF for front loaded lots and TE to TR for rear loaded terraces.
      (( <= Mfront 7.49949)
       
       (cond
	 ;depth range
	 ((<= Mdepth 24.99949)	(setq col "198,110,78" lay "TE_(F)-7.5m_(D)-25m"))
	 ((<= Mdepth 27.99949) 	(setq col "192,76,54" lay "TE_(F)-7.5m_(D)25m"))
	 ((<= Mdepth 29.99949) 	(setq col "183,49,44" lay "TE_(F)-7.5m_(D)28m"))
	 ((<= Mdepth 31.99949) 	(setq col "171,35,40" lay "TE_(F)-7.5m_(D)30m"))
	 ((<= Mdepth 35.99949) 	(setq col "147,39,44" lay "TE_(F)-7.5m_(D)32m"))
	 (( > Mdepth 35.99949)	(setq col "138,42,43" lay "TE_(F)-7.5m_(D)36m"))
	 )
       )
      ;Terrace Lots 7.5m frontage - Change TE to TF for front loaded lots and TE to TR for rear loaded terraces.
      ((and(<= Mfront 7.50049 ))
       
       (cond
	 ;depth range
	 ((<= Mdepth 24.99949)   (setq col "104,101,159" lay "TE_(F)7.5m_(D)-25m"))
	 ((<= Mdepth 27.99949)   (setq col "97,94,155" lay "TE_(F)7.5m_(D)25m"))
	 ((<= Mdepth 29.99949)   (setq col "86,82,148" lay "TE_(F)7.5m_(D)28m"))
	 ((<= Mdepth 31.99949)   (setq col "81,70,137" lay "TE_(F)7.5m_(D)30m"))
	 ((<= Mdepth 35.99949)   (setq col "76,65,132" lay "TE_(F)7.5m_(D)32m"))
	 (( > Mdepth 35.99949)   (setq col "83,84,74" lay "TE_(F)7.5m_(D)36m"))
	 )
       )
      
      ;Terrace Lots between 7.5m and 10.5m frontage - Change TE to TF for front loaded lots and TE to TR for rear loaded terraces.
      ((<= Mfront 10.49949)
       
       (cond
	 ;depth range
	 ((<= Mdepth 24.99949)   (setq col "186,187,177" lay "TE_(F)7.5m+_(D)-25m"))
	 ((<= Mdepth 27.99949)   (setq col "168,169,158" lay "TE_(F)7.5m+_(D)25m"))
	 ((<= Mdepth 29.99949)   (setq col "145,147,136" lay "TE_(F)7.5m+_(D)28m"))
	 ((<= Mdepth 31.99949)   (setq col "126,127,116" lay "TE_(F)7.5m+_(D)30m"))
	 ((<= Mdepth 35.99949)   (setq col "101,102,92" lay "TE_(F)7.5m+_(D)32m"))
	 (( > Mdepth 35.99949)   (setq col "81,83,74" lay "TE_(F)7.5m+_(D)36m"))
	 )
       )
      
      ;Standard Lots between 10.5m and 12.5m frontage
      ((<= Mfront 12.49949)
       
       (cond
	 ;depth range
	 ((<= Mdepth 24.99949)   (setq col "169,133,132" lay "_V_(F)10.5m_(D)-25m"))
	 ((<= Mdepth 27.99949)   (setq col "129,107,183" lay "_V_(F)10.5m_(D)25m"))
	 ((<= Mdepth 29.99949)   (setq col "138,52,83" lay "_V_(F)10.5m_(D)28m"))
	 ((<= Mdepth 31.99949)   (setq col "245,101,83" lay "_V_(F)10.5m_(D)30m"))
	 ((<= Mdepth 35.99949)   (setq col "116,72,57" lay "_V_(F)10.5m_(D)32m"))
	 (( > Mdepth 35.99949)   (setq col "54,114,142" lay "_V_(F)10.5m_(D)36m"))
	 )
       )
      
      ;Standard Lots between 12.5m and 14.0m frontage
      ((<= Mfront 13.99949)
       
       (cond
	 ;depth range
	 ((<= Mdepth 24.99949)   (setq col "181,149,148" lay "PV_(F)12.5m_(D)-25m"))
	 ((<= Mdepth 27.99949)   (setq col "156,128,199" lay "PV_(F)12.5m_(D)25m"))
	 ((<= Mdepth 29.99949)   (setq col "174,72,103" lay "PV_(F)12.5m_(D)28m"))
	 ((<= Mdepth 31.99949)   (setq col "245,130,73" lay "PV_(F)12.5m_(D)30m"))
	 ((<= Mdepth 35.99949)   (setq col "114,89,71" lay "PV_(F)12.5m_(D)32m"))
	 (( > Mdepth 35.99949)   (setq col "73,142,164" lay "PV_(F)12.5m_(D)36m"))
	 )
       )
      
      ;Standard Lots between 14.0m and 16.0m frontage
      ((<= Mfront 15.99949)
       
       (cond
	 ;depth range
	 ((<= Mdepth 24.99949)   (setq col "195,162,168" lay "C_(F)14m_(D)-25m"))
	 ((<= Mdepth 27.99949)   (setq col "182,150,214" lay "C_(F)14m_(D)25m"))
	 ((<= Mdepth 29.99949)   (setq col "203,98,123" lay "C_(F)14m_(D)28m"))
	 ((<= Mdepth 31.99949)   (setq col "243,155,76" lay "C_(F)14m_(D)30m"))
	 ((<= Mdepth 35.99949)   (setq col "176,115,94" lay "C_(F)14m_(D)32m"))
	 (( > Mdepth 35.99949)   (setq col "103,169,182" lay "C_(F)14m_(D)36m"))
	 )
       )
      
      ;Standard Lots between 16.0m and 18.0m frontage
      ((<= Mfront 17.99949)
       
       (cond
	 ;depth range
	 ((<= Mdepth 24.99949)   (setq col "211,187,191" lay "PC_(F)16m_(D)-25m"))
	 ((<= Mdepth 27.99949)   (setq col "207,173,229" lay "PC_(F)16m_(D)25m"))
	 ((<= Mdepth 29.99949)   (setq col "221,132,146" lay "PC_(F)16m_(D)28m"))
	 ((<= Mdepth 31.99949)   (setq col "240,177,94" lay "PC_(F)16m_(D)30m"))
	 ((<= Mdepth 35.99949)   (setq col "196,151,135" lay "PC_(F)16m_(D)32m"))
	 (( > Mdepth 35.99949)   (setq col "136,195,200" lay "PC_(F)16m_(D)36m"))
	 )
       )
      
      ;Standard Lots between 18.0m and 20.0m frontage
      ((<= Mfront 19.99949)
       
       (cond
	 ;depth range
	 ((<= Mdepth 24.99949)   (setq col "225,209,212" lay "T_(F)18m_(D)-25m"))
	 ((<= Mdepth 27.99949)   (setq col "230,198,243" lay "T_(F)18m_(D)25m"))
	 ((<= Mdepth 29.99949)   (setq col "239,165,172" lay "T_(F)18m_(D)28m"))
	 ((<= Mdepth 31.99949)   (setq col "237,198,122" lay "T_(F)18m_(D)30m"))
	 ((<= Mdepth 35.99949)   (setq col "215,183,173" lay "T_(F)18m_(D)32m"))
	 (( > Mdepth 35.99949)   (setq col "170,219,218" lay "T_(F)18m_(D)36m"))
	 )
       )
      
      ;Standard Lots 20m frontage or greater
      (( > Mfront 19.99949)
       
       (cond
	 ;depth range
	 ((<= Mdepth 24.99949)   (setq col "241,221,226" lay "PT_(F)20m_(D)-25m"))
	 ((<= Mdepth 27.99949)   (setq col "231,211,248" lay "PT_(F)20m_(D)25m"))
	 ((<= Mdepth 29.99949)   (setq col "255,197,199" lay "PT_(F)20m_(D)28m"))
	 ((<= Mdepth 31.99949)   (setq col "236,217,153" lay "PT_(F)20m_(D)30m"))
	 ((<= Mdepth 35.99949)   (setq col "230,210,204" lay "PT_(F)20m_(D)32m"))
	 (( > Mdepth 35.99949)   (setq col "210,238,234" lay "PT_(F)20m_(D)36m"))
	 )
       )
      )
    
    (setq layx (vl-string-subst "" "," lay))
    (setq layx (vl-string-subst "" "," layx))
    
    (setq lay (strcat "SHG_Hatch_(FD)_" layx))
    (command "layer" "new" lay "")
    (command "layer" "color" "truecolor" col lay "")
    (command "LAYER" "SET" lay "")
    (command "color" "bylayer")
    (entmod (append (entget (tblobjname "layer" lay)) '((-3("AcCmTransparency" (1071 . 33554610))))))
    
    ;;;	(setq P1 (getpoint "\nSelect inside lot : "))
    (command "Bhatch" "s" ent "" "")
    (setq i (1+ i))
    )
    
  (print "Hatch completed")
  (terpri)  
  )

 

Best regards.

Thankyou.  This is perfect now.  Really appreciate your effort

Posted

You're welcome, glad it works now. Like, share and subscribe 😎

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...