leonucadomi Posted December 13, 2022 Posted December 13, 2022 hello all: can someone help me to do the following? purpose: adjust the line scale of the same type of lines or polylines 1.- select a line and get its scale. (entsel) 2.-make a filtered selection set where only lines and polylines of the same line type are selected (ssget) 3.- copy the scale line of the first element (step 1) to selection set (step 2). I have a very good routine here, maybe you can help me modify it (defun C:test ( / s1 obj lst flst s2) (if (or (if (setq s1 (cadr (ssgetfirst))) (setq s1 (if (= 1 (sslength s1)) (ssname s1 0) (car (sssetfirst nil nil)) ) ) ) (setq s1 (car (entsel "\nSelect source object:"))) ) (progn (princ "\nSelect the other objects...") (setq obj (entget s1) lst '(0 8 6 62)) (sssetfirst nil nil) (setq flst (vl-remove-if-not (function (lambda (x) (member (car x) lst))) obj)) (if (setq s2 (ssget flst)) (princ (strcat (itoa (sslength s2)) " objects"))) (sssetfirst nil s2) ) ) (princ) ) example.dwg Quote
Steven P Posted December 13, 2022 Posted December 13, 2022 Maybe use a selection set filter to select lines to change:: (ssget "_X" '((0 . "*LINE")(8 . "-LAYER-")(6 . "--LINETYPE-")(62 . "-COLOUR-"))) 1 Quote
leonucadomi Posted December 13, 2022 Author Posted December 13, 2022 thanks .. but the problem is not making a selection filter else assign the selected property to a selection set what i need is like use command "SELECTSIMILARMODE" "4" "_.selectsimilar" The problem is that this function does it for all the elements of the drawing and I only need a certain area Quote
leonucadomi Posted December 13, 2022 Author Posted December 13, 2022 I tried to do this and it doesn't work for me (defun c:test (/) (setq e (car (entsel "\nSelecciona la linea: "))) (setq tipol (cdr (assoc 6 (entget e )))) (ssget '((0 . "*LINE") (6 . "(cdr (assoc 6 (entget e )"))) (princ tipol) (princ) ) Quote
mhupp Posted December 13, 2022 Posted December 13, 2022 (edited) if you select a line that is set to ByLayer you need to pull the line type from the layer. or you will update all lines and polylines in the drawing that are bylayer. You need a list of layers that have the same linetype to make a 2nd selection of all lines and polylines on those layers that are set to bylayer. Doesn't have error checking so if you select text or something that doesn't have linetype or linetypescale it will error ;;----------------------------------------------------------------------;; ;; Update linetype scale (defun C:match-linetype (/ SS ent lay typ scl laylst) (setq i 0) (if (setq SS (ssget "_+.:E:S")) (progn (setq ent (vlax-ename->vla-object (ssname SS 0))) (setq lay (vla-get-layer ent)) (if (eq (setq typ (vla-get-linetype ent)) "ByLayer") (setq typ (vla-get-linetype (vlax-ename->vla-object (tblobjname "layer" lay)))) ) (setq scl (vla-get-linetypescale ent)) (setq SS (ssget (list '(0 . "LINE,*polyline") (cons 6 typ)))) (foreach ent (vl-remove-if 'listp (mapcar 'cadr (ssnamex SS))) (vla-put-linetypescale (vlax-ename->vla-object ent) scl) (setq i (1+ i)) ) (vlax-for layer (vla-get-layers (vla-get-ActiveDocument (vlax-get-acad-object))) (if (eq (vla-get-linetype layer) typ) (setq laylst (cons (vla-get-name layer) laylst)) ) ) (setq laylst (l2s "," laylst)) (if (setq SS (ssget "_CP" (mapcar 'cadr (cdr (assoc -1 (ssnamex SS)))) (list '(0 . "LINE,*polyline") '(6 . "ByLayer") (cons 8 laylst)))) (foreach ent (vl-remove-if 'listp (mapcar 'cadr (ssnamex SS))) (vla-put-linetypescale (vlax-ename->vla-object ent) scl) (setq i (1+ i)) ) ) ) ) (prompt (strcat "\n" (rtos i 2 0) " Entities updated")) (princ) ) ;https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/list-to-string/m-p/830688/highlight/true#M56346 (defun l2s (delim lst / out) (setq out (car lst) lst (cdr lst)) (repeat (length lst) (setq out (strcat out delim (car lst)) lst (cdr lst)) ) out ) Edited December 13, 2022 by mhupp Code Updated 1 1 Quote
leonucadomi Posted December 13, 2022 Author Posted December 13, 2022 it is excellent but... It can be adjusted so that it filters in a certain area and not in the entire drawing? Quote
mhupp Posted December 13, 2022 Posted December 13, 2022 Remove the "_X" from the ssget's (setq SS (ssget (list '(0 . "*LINE") (cons 6 typ)))) (setq SS (ssget (list '(0 . "*LINE") '(6 . "ByLayer") (cons 8 laylst)))) Quote
leonucadomi Posted December 13, 2022 Author Posted December 13, 2022 IT'S EXCELLENT only that I select the source entity , then the set of lines to filter I finish the selection and it executes it well but again it asks me for a selection and should just exit after finishing work Quote
mhupp Posted December 13, 2022 Posted December 13, 2022 (edited) The 2nd selection is for lines and polys that are bylayer for linetype. Updated the code so you only have to make one selection. Edited December 13, 2022 by mhupp Quote
leonucadomi Posted December 13, 2022 Author Posted December 13, 2022 it was corrected very good... Even though I don't know why it shows this Quote
mhupp Posted December 13, 2022 Posted December 13, 2022 (edited) AutoCAD is trying to process a nil selection set. it doesn't error in BricsCAD Added a if statement to the 2nd ssget so it shouldn't run that code if nothing is selected. Edited December 13, 2022 by mhupp 1 Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.