Leaderboard
Popular Content
Showing content with the highest reputation on 05/13/2025 in all areas
-
2 points
-
Whoops, that's me not reading your question properly! (though of course, you can use entmake method to copy a layout it is a bit of a pain to do - assuming you also want anything on that layout also copied)1 point
-
1 point
-
Great, thanks. Also, the entmod is one of the function which is too fast for changing the definition data of the entity. Whenever, entmake is great solution for making an entity. The while loop is fast for iterating trough the selection set or similiar situtation.1 point
-
I've been looking for information about this in the past, and from what I understand, it can be said very generally that: 1. ENTMAKE is the fastest. 2. VLA is slightly behind and almost without difference (if any). 3. COMMAND is the slowest and in my experience it is indeed noticeable,so I try to avoid it as much as possible. aridzv1 point
-
@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! Picture 1. 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.1 point
-
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) )1 point
-
1 point
-
Unless you can work at micro second level then you will probably not see any difference between Command, Entmod & VL for this task.. But if you were changing 1000 layouts then one method may be faster than another. Command is the slowest method.1 point
-
(defun c:Test (/ i s c e y l b k) ;; Tharwat - Date: 24.Mar.2021 ;; ;; Freeze layers of selected objects ;; ;; NOTE: excludes if any of the layers is current. ;; (and (princ "\nSelect objects to Freeze their layers : ") (setq c (getvar 'CLAYER) i -1 s (ssget '((0 . "~VIEWPORT"))) ) (while (setq i (1+ i) e (ssname s i) ) (or (member (setq y (cdr (assoc 8 (entget e)))) l) (= c y) (and (setq l (cons y l) b (entget (tblobjname "LAYER" y)) k (assoc 70 b) ) (entmod (subst (cons 70 (1+ (cdr k))) k b)) ) ) ) ) (princ) )1 point