thecocuk07 Posted February 15, 2023 Posted February 15, 2023 (edited) hi - In these pick selections, it gives numbers by following the selection order. no problem with that - in select window selections starting the numbering operation from the last entity selected ( in select window selections first selected entity > how to make first number ?) (defun C:FMA (/ def1 def2 def3 n1 ss1) (setq FMA_PATTERN (getstring (strcat "\nEnter tag pattern <" (setq def1 (if (not FMA_PATTERN) "*" FMA_PATTERN)) ">: "))) ;Attribute search pattern, using wildcard (if (equal FMA_PATTERN "") (setq FMA_PATTERN def1)) (setq FMA_PREFIX (getstring T (strcat "\nEnter prefix <" (setq def2 (if (not FMA_PREFIX) "" FMA_PREFIX)) ">: "))) ;Prefix in attribute value (cond ((equal FMA_PREFIX "") (setq FMA_PREFIX def2)) ((equal FMA_PREFIX " ") (setq FMA_PREFIX "")) ;Enter a space to remove prefix ) (setq FMA_START (getint (strcat "\nEnter start number <" (setq def3 (if (not FMA_START) "1" (itoa FMA_START))) ">: "))) ;Number sequence start number (if (not FMA_START) (setq FMA_START (atoi def3))) (setq n1 0) (if (and (setq ss1 (ssget '((-4 . "<AND")(0 . "INSERT")(66 . 1)(-4 . "AND>")))) ) (repeat (sslength ss1) (foreach r1 (vlax-safearray->list (vlax-variant-value (vla-getattributes (vlax-ename->vla-object (ssname ss1 n1))))) (if (wcmatch (vla-Get-Tagstring r1) FMA_PATTERN) (progn (vla-Put-Textstring r1 (strcat FMA_PREFIX (itoa FMA_START))) (setq FMA_START (1+ FMA_START)) ) ) ) (setq n1 (1+ n1)) ) ) (princ) ) select window.mp4 11111.dwg Edited February 15, 2023 by thecocuk07 Quote
thecocuk07 Posted February 25, 2023 Author Posted February 25, 2023 (edited) hi fix selection window order ,, reversed in pick selections .. i.e. reversed the entire selection order ((( (defun C:FMA2 (/ def1 def2 def3 n1 ss1) (setq FMA_PATTERN (getstring (strcat "\nEnter tag pattern <" (setq def1 (if (not FMA_PATTERN) "*" FMA_PATTERN)) ">: "))) ;Attribute search pattern, using wildcard (if (equal FMA_PATTERN "") (setq FMA_PATTERN def1)) (setq FMA_PREFIX (getstring T (strcat "\nEnter prefix <" (setq def2 (if (not FMA_PREFIX) "" FMA_PREFIX)) ">: "))) ;Prefix in attribute value (cond ((equal FMA_PREFIX "") (setq FMA_PREFIX def2)) ((equal FMA_PREFIX " ") (setq FMA_PREFIX "")) ;Enter a space to remove prefix ) (setq FMA_START (getint (strcat "\nEnter start number <" (setq def3 (if (not FMA_START) "1" (itoa FMA_START))) ">: "))) ;Number sequence start number (if (not FMA_START) (setq FMA_START (atoi def3))) (setq n1 0) (if (and (setq ss1 (ssget '((-4 . "<AND")(0 . "INSERT")(66 . 1)(-4 . "AND>")))) ) (repeat (setq cnt (sslength ss1)) (foreach r1 (vlax-safearray->list (vlax-variant-value (vla-getattributes (vlax-ename->vla-object (ssname ss1 (setq cnt (1- cnt))))))) (if (wcmatch (vla-Get-Tagstring r1) FMA_PATTERN) (progn (vla-Put-Textstring r1 (strcat FMA_PREFIX (itoa FMA_START))) (setq FMA_START (1+ FMA_START)) ) ) ) (setq n1 (1+ n1)) ) ) (princ) ) (PRINC " ") Edited February 27, 2023 by thecocuk07 Quote
BIGAL Posted February 26, 2023 Posted February 26, 2023 Ok select all then do a double sort on X&Y, you will say need to make a list ((x1 y1 entname)(x2 y2 entname2) ....... then sort it and then replace the attribute form a starting number. Ps there is a subtle error in what I just posted will let you work it out. Quote
thecocuk07 Posted February 27, 2023 Author Posted February 27, 2023 On 2/25/2023 at 6:13 PM, devitg said: Please clear what do you want to do. i want , 1-When I select one by one, it gives numbers according to the order of selection. and 2-When I select with the selection window; starting to give from right to left and choosing the bottom row when the line ends the code below; doing the first item. but it starts the second item in reverse (Starting from the lower right corner, it continues from right to left and up when the line ends.) 1------------------------------------ 2---------------------------------------------------- ----------------------------------- (defun C:FMA (/ def1 def2 def3 n1 ss1) (setq FMA_PATTERN (getstring (strcat "\nEnter tag pattern <" (setq def1 (if (not FMA_PATTERN) "*" FMA_PATTERN)) ">: "))) ;Attribute search pattern, using wildcard (if (equal FMA_PATTERN "") (setq FMA_PATTERN def1)) (setq FMA_PREFIX (getstring T (strcat "\nEnter prefix <" (setq def2 (if (not FMA_PREFIX) "" FMA_PREFIX)) ">: "))) ;Prefix in attribute value (cond ((equal FMA_PREFIX "") (setq FMA_PREFIX def2)) ((equal FMA_PREFIX " ") (setq FMA_PREFIX "")) ;Enter a space to remove prefix ) (setq FMA_START (getint (strcat "\nEnter start number <" (setq def3 (if (not FMA_START) "1" (itoa FMA_START))) ">: "))) ;Number sequence start number (if (not FMA_START) (setq FMA_START (atoi def3))) (setq n1 0) (if (and (setq ss1 (ssget '((-4 . "<AND")(0 . "INSERT")(66 . 1)(-4 . "AND>")))) ) (repeat (sslength ss1) (foreach r1 (vlax-safearray->list (vlax-variant-value (vla-getattributes (vlax-ename->vla-object (ssname ss1 n1))))) (if (wcmatch (vla-Get-Tagstring r1) FMA_PATTERN) (progn (vla-Put-Textstring r1 (strcat FMA_PREFIX (itoa FMA_START))) (setq FMA_START (1+ FMA_START)) ) ) ) (setq n1 (1+ n1)) ) ) (princ) ) Quote
thecocuk07 Posted February 27, 2023 Author Posted February 27, 2023 On 2/26/2023 at 7:14 AM, BIGAL said: Ok select all then do a double sort on X&Y, you will say need to make a list ((x1 y1 entname)(x2 y2 entname2) ....... then sort it and then replace the attribute form a starting number. Ps there is a subtle error in what I just posted will let you work it out. I will try , thanks Quote
BIGAL Posted February 27, 2023 Posted February 27, 2023 (edited) Look at this https://www.cadtutor.net/forum/topic/71201-function-to-sort-a-list-of-points-first-x-then-y/ Edited February 27, 2023 by BIGAL 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.