Incsuff without losing text prefix

Incsuff without losing text prefix

clement.rochier
Community Visitor Community Visitor
359 Views
2 Replies
Message 1 of 3

Incsuff without losing text prefix

clement.rochier
Community Visitor
Community Visitor

Hello ! 

 

I have to increment blocks with attribute that have the shape you can see on my example dwg.

 

I use the  famous Giles' lisp called  "INCTXT"  and especially the incsuff function however I run into a problem

 

In an attribute named for example AB/01/001 followed by another named CD/01/001 I want to increment on CD only the final value "001", but incsuff will copy all the previous text and transform "CD" into "AB".

 

The only function that exists to do this is called incsel but it should be like this: AB/01/ and CD/01/  and it add the numbers at the end but it only works at creation, if I have to go back to the numbering I have to delete everything again and put the AB and CD etc in the places where they were

 

So I want to know if it is possible to increment a value from the Xth character of an attribute, for example here delete everything from the 7th character and replace by an incremented value a bit like incsel

 

Thanking you in advance ! 

 

A link for the giles lisp :  

 

https://gilecad.azurewebsites.net/Lisp.aspx

 

Its the one called "Increment"

 

0 Likes
360 Views
2 Replies
Replies (2)
Message 2 of 3

ВeekeeCZ
Consultant
Consultant

I would recommend creating a stand-alone routine that will remove certain chars first, then you can use gile's routine to add increments.

Or use something like THIS 

 

Here's a routine that will remove ending numbers up to the non-number character.

In your case it's XX-101/01/01 ->> XX-101-01/

 

(vl-load-com)

(defun c:RemoveEndingNumbers ( / s i e v)

  (if (setq s (ssget '((0 . "INSERT") (66 . 1))))
    (repeat (setq i (sslength s))
      (setq e (ssname s (setq i (1- i))))
      (if (not (vl-catch-all-error-p (setq v (vl-catch-all-apply 'getpropertyvalue (list e "REPERE")))))
	(setpropertyvalue e "REPERE" (vl-string-right-trim "0123456789" v)))))
  (princ)
  )

 

Only for blocks with "REPERE" att.

0 Likes
Message 3 of 3

3wood
Advisor
Advisor

You can try ALTEXT.

It can find the number from either left or right side of the text string.

altext16.gif

0 Likes