Jump to content

Recommended Posts

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

 

11111.dwg

Edited by thecocuk07
  • 2 weeks later...
Posted (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 by thecocuk07
Posted

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.

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

image.thumb.png.8460f1c0e78f6c903462ca124293ccd9.png

image.thumb.png.0b6781ad9f43dd60ac447521eada64b6.png

 

 

 

 

 

2----------------------------------------------------

image.thumb.png.05da66520518ab71b1188bd1b21ade79.png

image.thumb.png.242c2eac083bb7e3e04e0063a29ddfeb.png

 

-----------------------------------

 

 

(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)
  )

 

Posted
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 

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