Jump to content

Recommended Posts

Posted

Hi!

 

I'm working on a big project. I have about 5600 units whit unique numbering/labels.

merkeeksempel.jpg

 

Examples of labels:

SQ.2.20.32

RB.2.20.04

 

When a add a new unit, I have to manually increase the numbering of following units by +1.

 

Is there possible for me to make a button with a function that does this automaticly?

 

Example:

I press a label that say "SQ.2.20.32" and it changes to "SQ.2.20.33"

I press a label that say "RB.2.20.04" and it changes to "RB.2.20.05"

 

This would save me hours of boring work so I would really appreciate it if anyone could help me:)

Posted

I use a diesel macro that works from 0, but I think you would need lisp to manage such a complex numbering system.

 
*^C^Ctext;_m;\;;$M=$(getvar,USERI1);setvar;USERI1;$(+,1,$(getvar,USERI1))

  • 2 weeks later...
Posted

If always 2 decs easy a start

 

; from help
;Substr string start length
(setq ans (getstring "\type in code part num above"))
(setq number ( - (strlen ans) 2))
(princ (substr ans number 2))
; you need to do some convert to real add 1 then RTOS & strcat etc 

Posted

Thank you for helping me:)

 

(setq ans (getstring *^C^Ctext;_m;\;;$M=$(getvar,USERI1);setvar;USERI1;$(+,1,$(getvar,USERI1))))
(setq number ( - (strlen ans) 2))
(princ (substr ans number 2))

 

I've added this code to a button, but all that happens is that when I press a label a new label that say "0" is created.

 

; you need to do some convert to real add 1 then RTOS & strcat etc

 

I'm not familiar with autolisp so I guess that I need to learn much more before I get it to work:)

Posted


(setq ans (getstring *^C^Ctext;_m;\;;$M=$(getvar,USERI1);setvar;USERI1;$(+,1,$(getvar,USERI1))))
(princ ans)

 

Shouldn't this code prit the same as the label I click? All that happens is that when I press a label a new label that say "0" is created.

Posted

I would not mix diesel inside a lisp rather do everything as a lisp proceedure, using ENTSEL you can pick an object and check if its text so then do next step.

 

(setq en1 (car (entsel "\nSelect first text number:" )))
(setq el1 (entget en1))
(if (= (cdr (assoc 0 el1)) "TEXT")
 (progn
 (setq ans (cdr (assoc 1 el1))) 
 (setq number ( - (strlen ans) 1))
 (princ (substr ans number 2))
 )
)

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