Increment Attributes inserting block again

Increment Attributes inserting block again

C.Utzinger
Collaborator Collaborator
4,240 Views
63 Replies
Message 1 of 64

Increment Attributes inserting block again

C.Utzinger
Collaborator
Collaborator

HI

 

First of all: Happy New Year!!!

 

OK! I wrote this little Code, but i want to use Chars with numbers. For example EG001... EG002... EG003

 

How can i do that...????

 

 

(defun C:<Test5 ( / Pnummer)
	(princ "\nEinfügepunkt angeben: ")
	(command "_-insert" "SPI-Datenextraktionspunkt-CM" pause "1" "1" "" (setq Pnummer (getint "\nPunktnummer angeben (01): ")) "")
	(repeat 1000
	(setq Pnummer (+ Pnummer 1))
	(command "_-insert" "SPI-Datenextraktionspunkt-CM" pause "1" "1" "" Pnummer ""))	
	(prin1)
) ; end of defun
0 Likes
4,241 Views
63 Replies
Replies (63)
Message 21 of 64

ВeekeeCZ
Consultant
Consultant

Sure. It's the regular UNDO function, one step of it, so including zooms and pans.

 

 

(vl-load-com)

(defun c:<Test5 ( / *error* lay cmd :MaxAttValue :AddLeadingZeros txt enl)
  
  (defun *error* (errmsg)
    (if (not (wcmatch errmsg "Function cancelled,quit / exit abort,console break"))
      (princ (strcat "\nError: " errmsg)))
    (setvar 'CLAYER lay)
    (setvar 'CMDECHO cmd)
    (princ "\nLetzte Punktnummer gespeichert!")
    (terpri)
    (princ))
  
  (defun :MaxAttValue (pre / mxm i en em val att)
    (setq mxm 0)
    (if (= pre "") (setq pre ";"))
    (if (setq ss (ssget "_X" (list '(0 . "INSERT") '(2 . "SPI-Datenextraktionspunkt-CM") (cons 410 (getvar 'CTAB)))))
      (repeat (setq i (sslength ss))
        (setq en (ssname ss (setq i (1- i))))
        (while (/= (cdr (assoc 0 (setq em (entget (setq en (entnext en)))))) "SEQEND")
          (and (eq (cdr (assoc 0 em)) "ATTRIB")
               (setq att (cdr (assoc 1 (reverse em))))
               (vl-string-search pre att)
               (setq val (substr att (+ 1 (vl-string-search pre att) (strlen pre))))
               (setq mxm (max mxm (atoi val)))
               ))))
    mxm)
  
  (defun :AddLeadingZeros (a d / b) ;add zeros to 'd' many digits  ;a string
    (strcat (substr "000000000" 1 (if (>= d (setq b (strlen (itoa (fix (atof a)))))) (- d b) 0)) a))
  
  
  ; ------------------------------------------------------------------------------------------------------
  
  (setq lay (getvar 'CLAYER)
        cmd (getvar 'CMDECHO))
  (setvar 'CMDECHO 0)
  (command "_.-LAYER" "_m" "-I-Koordinatenpunkte" "_co" "3" "-I-Koordinatenpunkte" "")
  
  (or *<test5-g*
      (setq *<test5-g* "None"))
  (initget 128 "U1 EG O1 None")
  (setq *<test5-g* (cond ((getkword (strcat "\nGeschoss angeben [U1/EG/O1/None] <" *<test5-g* ">: ")))
                         (*<test5-g*))
        *<test5-g* (if (= *<test5-g* "None")
                     ""
                     *<test5-g*))
  
  (setq *<test5-i* (1+ (:MaxAttValue *<test5-g*))
        *<test5-i* (cond ((getint (strcat "\nPunktnummer angeben <" (itoa *<test5-i*) ">: ")))
                         (*<test5-i*)))

  (while (progn (initget "Undo") (setq pnt (getpoint (strcat "\nEinfügepunkt angeben für '" (setq txt (strcat *<test5-g* (:AddLeadingZeros (itoa *<test5-i*) 3))) "' [Undo] <exit>: "))))
    (if (= pnt "Undo")
      (progn
        (setq enl (entlast))
        (command "_.UNDO" 1)
        (if (not (equal enl (entlast)))
          (setq *<test5-i* (1- *<test5-i*))))        
      (progn
        (command "_.-INSERT" "SPI-Datenextraktionspunkt-CM" "_none" pnt "1" "1" "" txt "")
        (setq *<test5-i* (1+ *<test5-i*)))))
)
0 Likes
Message 22 of 64

john.uhden
Mentor
Mentor
Yes you do. You are just being polite. I have found that most apiculturists
are that way.

When I said dictionary, I really meant an Xrecord saved in the drawing to
be used as the default for future runs for that drawing only, even in a
later session.

When I said registry, I meant (setenv "Variable_ID" "Value") which can be
recalled by any subsequently opened drawing via (getenv "Variable_ID") and
replaced with the latest value . Both the Variable_ID and its Value must
be strings. Be careful not to change the value of an ID that already exists
for some other reason (like basic AutoCAD or any vertical or other add-on).

A third way would be to use (vl-bb-set 'ID Value) and (vl-bb-ref 'ID) which
will save the ID and Value to the AutoCAD bulletin board for the current
AutoCAD session for any open or opened drawings in that session. Multiple
sessions of AutoCAD do not share the same bulletin board.

John F. Uhden

Message 23 of 64

john.uhden
Mentor
Mentor
Yes you do. You are just being polite. I have found that most apiculturists
are that way.

When I said dictionary, I really meant an Xrecord saved in the drawing to
be used as the default for future runs for that drawing only, even in a
later session.

When I said registry, I meant (setenv "Variable_ID" "Value") which can be
recalled by any subsequently opened drawing via (getenv "Variable_ID") and
replaced with the latest value . Both the Variable_ID and its Value must
be strings. Be careful not to change the value of an ID that already exists
for some other reason (like basic AutoCAD or any vertical or other add-on).

A third way would be to use (vl-bb-set 'ID Value) and (vl-bb-ref 'ID) which
will save the ID and Value to the AutoCAD bulletin board for the current
AutoCAD session for any open or opened drawings in that session. Multiple
sessions of AutoCAD do not share the same bulletin board.

John F. Uhden

Message 24 of 64

ВeekeeCZ
Consultant
Consultant

Thanks John for clarification your ideas. Kind of heard of that, saw that... but never used that. Actually..., probably I have one routine where I used the *bb* functions... to  make a stuff available for more drawings... 

 

Anyway, I think my last suggestion covers the OP's idea quite well and I would go for it. It looks like the missing dynamic preview is no such a big deal.

0 Likes
Message 25 of 64

C.Utzinger
Collaborator
Collaborator

Hi

 

Thank you for the code. I'm just testing it and i have noticed some Problems.

 

If you just use it correctly it works perfect. But if you for example insert a few Points, then draw some lines, continue inserting Points and then undo a lot, then it will undo the lines and that makes a mess witch the Pointnumbers.

 

I'm trying to fix this, but only mess comes out Smiley LOL...

 

Kind regards

 

 

0 Likes
Message 26 of 64

C.Utzinger
Collaborator
Collaborator

I am very interested in this solution (setenv "Variable_ID" "Value") for another problem i have.

 

I have a Dialog Box (dcl) and it would be nice if I can check an Option and save it for other sessions.

 

How can i do this?

0 Likes
Message 27 of 64

ВeekeeCZ
Consultant
Consultant

@c.utzinger wrote:

... 

Thank you for the code. I'm just testing it and i have noticed some Problems.

 

If you just use it correctly it works perfect. But if you for example insert a few Points, then draw some lines, continue inserting Points and then undo a lot, then it will undo the lines and that makes a mess witch the Pointnumbers.

... 



Well, I see two possible ways to go

 

- a similar solution as it is - just a quick undo within the current run of the routine. So if you add some "lines" in between, the undo stops there. I though this could be enough.

- the second is different, we can make our own undo function to select and erase the point with the previous number (and the same prefix). But we should add a ZOOM function as well, because the user could get lost easily.

0 Likes
Message 28 of 64

C.Utzinger
Collaborator
Collaborator

I think the first Option would be enough...

0 Likes
Message 29 of 64

ВeekeeCZ
Consultant
Consultant
Accepted solution

@c.utzinger wrote:

I think the first Option would be enough...


(vl-load-com)

(defun c:<Test5 ( / *error* lay cmd :MaxAttValue :AddLeadingZeros txt enl enlast)
  
  (defun *error* (errmsg)
    (if (not (wcmatch errmsg "Function cancelled,quit / exit abort,console break"))
      (princ (strcat "\nError: " errmsg)))
    (setvar 'CLAYER lay)
    (setvar 'CMDECHO cmd)
    (princ "\nLetzte Punktnummer gespeichert!")
    (terpri)
    (princ))
  
  (defun :MaxAttValue (pre / mxm i en em val att)
    (setq mxm 0)
    (if (= pre "") (setq pre ";"))
    (if (setq ss (ssget "_X" (list '(0 . "INSERT") '(2 . "SPI-Datenextraktionspunkt-CM") (cons 410 (getvar 'CTAB)))))
      (repeat (setq i (sslength ss))
        (setq en (ssname ss (setq i (1- i))))
        (while (/= (cdr (assoc 0 (setq em (entget (setq en (entnext en)))))) "SEQEND")
          (and (eq (cdr (assoc 0 em)) "ATTRIB")
               (setq att (cdr (assoc 1 (reverse em))))
               (vl-string-search pre att)
               (setq val (substr att (+ 1 (vl-string-search pre att) (strlen pre))))
               (setq mxm (max mxm (atoi val)))
               ))))
    mxm)
  
  (defun :AddLeadingZeros (a d / b) ;add zeros to 'd' many digits  ;a string
    (strcat (substr "000000000" 1 (if (>= d (setq b (strlen (itoa (fix (atof a)))))) (- d b) 0)) a))
  
  
  ; ------------------------------------------------------------------------------------------------------
  
  (setq lay (getvar 'CLAYER)
        cmd (getvar 'CMDECHO))
  
  (setvar 'CMDECHO 0)
  (command "_.-LAYER" "_m" "-I-Koordinatenpunkte" "_co" "3" "-I-Koordinatenpunkte" "")
  
  (or *<test5-g*
      (setq *<test5-g* "None"))
  (initget 128 "U1 EG O1 None")
  (setq *<test5-g* (cond ((getkword (strcat "\nGeschoss angeben [U1/EG/O1/None] <" *<test5-g* ">: ")))
                         (*<test5-g*))
        *<test5-g* (if (= *<test5-g* "None")
                     ""
                     *<test5-g*))
  
  (setq *<test5-i* (1+ (:MaxAttValue *<test5-g*))
        *<test5-i* (cond ((getint (strcat "\nPunktnummer angeben <" (itoa *<test5-i*) ">: ")))
                         (*<test5-i*)))
  
  (setq enlast (entlast))
  
  (while (progn
           (initget "Undo")
           (setq pnt (getpoint (strcat "\nEinfügepunkt angeben für '" (setq txt (strcat *<test5-g* (:AddLeadingZeros (itoa *<test5-i*) 3))) "' [Undo] <exit>: "))))
    (if (= pnt "Undo")
      (if (equal enlast (entlast))
        (princ "\nCan't go any further.")
        (progn
          (setq enl (entlast))
          (command "_.UNDO" 1)
          (if (not (equal enl (entlast)))
            (setq *<test5-i* (1- *<test5-i*)))))
      (progn
        (command "_.-INSERT" "SPI-Datenextraktionspunkt-CM" "_none" pnt "1" "1" "" txt "")
        (setq *<test5-i* (1+ *<test5-i*)))))
  )
Message 30 of 64

john.uhden
Mentor
Mentor

Shooting from the hip...

 

(defun c:UTZtest ( /  *error* #Default # etc)
  (defun *error* (err) blah blah)
  ;; let's say you want to use a default value, but if there is none, then 100
  (if (not (setq #Default (getenv "UTZ:#Default")))
    (setq #Default "100")
  )
  (initget 6) ;; no zeros or negatives (just maybe)
  (setq # (getint (strcat "\nFirst # to use <" #Default ">: ")))
  ;; returns an 'INT or nil
  (if #
    (setenv "UTZ:#Default" (setq #Default (itoa #)))  ;; must be strings
  )
  (setq # (atoi #Default)) ;; so the rest of your code can use just # as an 'INT
  ;; because maybe you want to increment it or something
  ;; rest of code follows
)

John F. Uhden

Message 31 of 64

C.Utzinger
Collaborator
Collaborator

Just one Thing more.

 

I was trying to get only upper chars with strcase, but i don´t know where exactly to put it.

 

Can you help me with this???

 

 

Thank you...

 

 

0 Likes
Message 32 of 64

C.Utzinger
Collaborator
Collaborator

I have it....

(vl-load-com)

(defun c:<Test1 ( / *error* lay cmd :MaxAttValue :AddLeadingZeros txt enl enlast)
  
  (defun *error* (errmsg)
    (if (not (wcmatch errmsg "Function cancelled,quit / exit abort,console break"))
      (princ (strcat "\nError: " errmsg)))
    (setvar 'CLAYER lay)
    (princ "\nLetzte Punktnummer gespeichert!")
    (terpri)
    (princ))
  
  (defun :MaxAttValue (pre / mxm i en em val att)
    (setq mxm 0)
    (if (= pre "") (setq pre ";"))
    (if (setq ss (ssget "_X" (list '(0 . "INSERT") '(2 . "SPI-Datenextraktionspunkt-CM") (cons 410 (getvar 'CTAB)))))
      (repeat (setq i (sslength ss))
        (setq en (ssname ss (setq i (1- i))))
        (while (/= (cdr (assoc 0 (setq em (entget (setq en (entnext en)))))) "SEQEND")
          (and (eq (cdr (assoc 0 em)) "ATTRIB")
               (setq att (cdr (assoc 1 (reverse em))))
               (vl-string-search pre att)
               (setq val (substr att (+ 1 (vl-string-search pre att) (strlen pre))))
               (setq mxm (max mxm (atoi val)))
               ))))
    mxm)
  
  (defun :AddLeadingZeros (a d / b) ;add zeros to 'd' many digits  ;a string
    (strcat (substr "000000000" 1 (if (>= d (setq b (strlen (itoa (fix (atof a)))))) (- d b) 0)) a))
  
  
  ; ------------------------------------------------------------------------------------------------------
  
  (setq lay (getvar 'CLAYER))
  
  (command "_.-LAYER" "_m" "-I-Koordinatenpunkte" "_co" "3" "-I-Koordinatenpunkte" "")
  
  (setq oATTREQ (getvar 'ATTREQ)
        oATTDIA (getvar 'ATTDIA))
  (setvar 'ATTREQ 1)
  (setvar 'ATTDIA 0)

  (or *<test5-g*
      (setq *<test5-g* "Ohne"))
  (initget 128 "1U- EG- 1O- Ohne")
  (setq *<test5-g* (strcase (cond ((getkword (strcat "\nGeschoss angeben (1U-/EG-/1O-/Ohne) <" *<test5-g* ">: ")))
                         (*<test5-g*)))
        *<test5-g* (if (= *<test5-g* "Ohne")
                     ""
                     *<test5-g*))
  
  (setq *<test5-i* (1+ (:MaxAttValue *<test5-g*))
        *<test5-i* (cond ((getint (strcat "\nPunktnummer angeben <" (itoa *<test5-i*) ">: ")))
                         (*<test5-i*)))

  (setq enlast (entlast))

  (while (progn
           (initget "Undo")
           (setq pnt (getpoint (strcat "\nEinfügepunkt angeben für '" (setq txt (strcat *<test5-g* (:AddLeadingZeros (itoa *<test5-i*) 1))) "' [Undo] <exit>: "))))
    (if (= pnt "Undo")
      (progn
        (if (equal enlast (entlast))
          (alert "Alle eingefügten Punkte gelöscht!")
          (progn
            (setq enl (entlast))
            (command "_.UNDO" 1)
            (if (not (equal enl (entlast)))
              (setq *<test5-i* (1- *<test5-i*))))))
      (progn
        (command "_.-INSERT" "SPI-Datenextraktionspunkt-CM" "_none" pnt "1" "1" "" txt "")
        (setq *<test5-i* (1+ *<test5-i*)))))
) ; end of defun
0 Likes
Message 33 of 64

ВeekeeCZ
Consultant
Consultant

@c.utzinger wrote:

I have it....


... wrong, unfortunately. You're not able to select "Ohne" anymore. I can see 3 possible places...

 

;; 1/

(setq *<test5-g* (cond ((getkword (strcat "\nGeschoss angeben (1U-/EG-/1O-/Ohne) <" *<test5-g* ">: ")))
                       (*<test5-g*))
      *<test5-g* (strcase (if (= *<test5-g* "Ohne")
                            ""
                            *<test5-g*)))

;; 2/

(setq *<test5-g* (cond ((getkword (strcat "\nGeschoss angeben (1U-/EG-/1O-/Ohne) <" *<test5-g* ">: ")))
                       (*<test5-g*))
      *<test5-g* (if (= *<test5-g* "Ohne")
                   ""
                   (strcase *<test5-g*)))

;; 3/

(setq *<test5-g* (strcase (cond ((getkword (strcat "\nGeschoss angeben (1U-/EG-/1O-/Ohne) <" *<test5-g* ">: ")))
                                (*<test5-g*)))
      *<test5-g* (if (= *<test5-g* "OHNE")
                   ""
                   *<test5-g*))

BTW. replacing my square brackets with yours rounded parentheses you're not only break the common syntax but also lose the possibility of making the choices by mouse click (since version acad 2013)

 

Kword square brackets.png

 

 

0 Likes
Message 34 of 64

C.Utzinger
Collaborator
Collaborator

Hi

 

Yes I saw it yesterday and changed it to your third option.

 

I have it with rounded parentheses, because when your working with the "dinamic mouse Option" (Dynamische Eingabe), then appears a Dropdown menue and i don't like it very much, beause it's static.

 

The 1U- EG- 1O- are just examples, they don´t have to be an direct Option to choose.

 

 

Thank you very much

0 Likes
Message 35 of 64

C.Utzinger
Collaborator
Collaborator
Accepted solution

 

So this one is it!!!

 

(vl-load-com)

(defun c:<Koordpunkt ( / *error* lay cmd :MaxAttValue :AddLeadingZeros txt enl enlast)
  
  (defun *error* (errmsg)
    (if (not (wcmatch errmsg "Function cancelled,quit / exit abort,console break"))
      (princ (strcat "\nError: " errmsg)))
    (setvar 'CLAYER lay)
    (princ "\nLetzte Punktnummer gespeichert!")
    (terpri)
    (princ))
  
  (defun :MaxAttValue (pre / mxm i en em val att)
    (setq mxm 0)
    (if (= pre "") (setq pre ";"))
    (if (setq ss (ssget "_X" (list '(0 . "INSERT") '(2 . "SPI-Datenextraktionspunkt-CM") (cons 410 (getvar 'CTAB)))))
      (repeat (setq i (sslength ss))
        (setq en (ssname ss (setq i (1- i))))
        (while (/= (cdr (assoc 0 (setq em (entget (setq en (entnext en)))))) "SEQEND")
          (and (eq (cdr (assoc 0 em)) "ATTRIB")
               (setq att (cdr (assoc 1 (reverse em))))
               (vl-string-search pre att)
               (setq val (substr att (+ 1 (vl-string-search pre att) (strlen pre))))
               (setq mxm (max mxm (atoi val)))
               ))))
    mxm)
  
  (defun :AddLeadingZeros (a d / b) ;add zeros to 'd' many digits  ;a string
    (strcat (substr "000000000" 1 (if (>= d (setq b (strlen (itoa (fix (atof a)))))) (- d b) 0)) a))
  
  
  ; ------------------------------------------------------------------------------------------------------
  
  (setq lay (getvar 'CLAYER))
  
  (command "_.-LAYER" "_m" "-I-Koordinatenpunkte" "_co" "3" "-I-Koordinatenpunkte" "")
  
  (setq oATTREQ (getvar 'ATTREQ)
        oATTDIA (getvar 'ATTDIA))
  (setvar 'ATTREQ 1)
  (setvar 'ATTDIA 0)

  (or *<test5-g*
      (setq *<test5-g* "Ohne"))
  (initget 128 "1U- EG- 1O- Ohne")
  (setq *<test5-g* (strcase (cond ((getkword (strcat "\nGeschoss angeben (1U-/EG-/1O-/Ohne) <" *<test5-g* ">: ")))
                         (*<test5-g*)))
        *<test5-g* (if (= *<test5-g* "OHNE")
                     ""
                     *<test5-g*))
  
  (setq *<test5-i* (1+ (:MaxAttValue *<test5-g*))
        *<test5-i* (cond ((getint (strcat "\nPunktnummer angeben <" (itoa *<test5-i*) ">: ")))
                         (*<test5-i*)))

  (setq enlast (entlast))

  (while (progn
           (initget "Undo")
           (setq pnt (getpoint (strcat "\nEinfügepunkt angeben für '" (setq txt (strcat *<test5-g* (:AddLeadingZeros (itoa *<test5-i*) 1))) "' [Undo] <exit>: "))))
    (if (= pnt "Undo")
      (progn
        (if (equal enlast (entlast))
          (alert "Alle eingefügten Punkte gelöscht!")
          (progn
            (setq enl (entlast))
            (command "_.UNDO" 1)
            (if (not (equal enl (entlast)))
              (setq *<test5-i* (1- *<test5-i*))))))
      (progn
        (command "_.-INSERT" "SPI-Datenextraktionspunkt-CM" "_none" pnt "1" "1" "" txt "")
        (setq *<test5-i* (1+ *<test5-i*)))))
) ; end of defun
0 Likes
Message 36 of 64

ВeekeeCZ
Consultant
Consultant

@c.utzinger wrote:

 

Yes I saw it yesterday and changed it to your third option.


Good that you've found the solution - I hoped you will.

 

 


@c.utzinger wrote:

 

... I have it with rounded parentheses, because when your working with the "dinamic mouse Option" (Dynamische Eingabe), then appears a Dropdown menue and i don't like it very much, beause it's static.

 

The 1U- EG- 1O- are just examples, they don´t have to be an direct Option to choose.


I see your point... but in this case you should remove that from the (initget 128 "1U- EG- 1O- Ohne")  list. It may be confusing because these still are kwords with its key letters. The only real kword left is the "Ohne" option. So if I would be a perfectionist... the prompt should look like 

 

Geschoss angeben (eg. 1U-/EG-) [Ohne] <" *<test5-g* ">: 

 

... if this is not in conflict with your "don't like a dynamic input" (me too). I'd remove the "1O" sample - it's not good as a sample anyway... is it 10 or 1O?? 

 

No other comments, I promise.

Message 37 of 64

C.Utzinger
Collaborator
Collaborator

Hihihihi

 

Thank for your comments... I'm happy for your help...

 

 

Kind regards

 

Christian

0 Likes
Message 38 of 64

C.Utzinger
Collaborator
Collaborator

Just another question about this...

 

When I use "getstring", then would be perfect, because there is no static Dropdown menue. 

 

But with getstring you cannot hit enter for the last option (the last Option shows up), it takes "ohne" as default. Why??? 

 

 

0 Likes
Message 39 of 64

ВeekeeCZ
Consultant
Consultant

The selection part of the program as I wrote is based on the fact that (getkword) returns nil if you hit enter. But the (getstring) returns the empty character "" which is not nil but True. I could rewrite it, but the issue I'm facing is that I'm unable to see the difference whether the user hit Enter or typed "" as the empty char.

 

So I would go for something like this:

 

(vl-load-com)

(defun c:<Koordpunkt ( / *error* lay cmd :MaxAttValue :AddLeadingZeros txt enl enlast)
  
  (defun *error* (errmsg)
    (if (not (wcmatch errmsg "Function cancelled,quit / exit abort,console break"))
      (princ (strcat "\nError: " errmsg)))
    (setvar 'CLAYER lay)
    (princ "\nLetzte Punktnummer gespeichert!")
    (terpri)
    (princ))
  
  (defun :MaxAttValue (pre / mxm i en em val att)
    (setq mxm 0)
    (if (= pre "") (setq pre ";"))
    (if (setq ss (ssget "_X" (list '(0 . "INSERT") '(2 . "SPI-Datenextraktionspunkt-CM") (cons 410 (getvar 'CTAB)))))
      (repeat (setq i (sslength ss))
        (setq en (ssname ss (setq i (1- i))))
        (while (/= (cdr (assoc 0 (setq em (entget (setq en (entnext en)))))) "SEQEND")
          (and (eq (cdr (assoc 0 em)) "ATTRIB")
               (setq att (cdr (assoc 1 (reverse em))))
               (vl-string-search pre att)
               (setq val (substr att (+ 1 (vl-string-search pre att) (strlen pre))))
               (setq mxm (max mxm (atoi val)))
               ))))
    mxm)
  
  (defun :AddLeadingZeros (a d / b) ;add zeros to 'd' many digits  ;a string
    (strcat (substr "000000000" 1 (if (>= d (setq b (strlen (itoa (fix (atof a)))))) (- d b) 0)) a))
  
  
  ; ------------------------------------------------------------------------------------------------------
  
  (setq lay (getvar 'CLAYER))
  
  (command "_.-LAYER" "_m" "-I-Koordinatenpunkte" "_co" "3" "-I-Koordinatenpunkte" "")
  
  (setq oATTREQ (getvar 'ATTREQ)
        oATTDIA (getvar 'ATTDIA))
  (setvar 'ATTREQ 1)
  (setvar 'ATTDIA 0)
  
  (or *<Koordpunkt-g*
      (setq *<Koordpunkt-g* ""))
  (initget 128)
  (setq *<Koordpunkt-g* (strcase (cond ((getkword (strcat "\nGeschoss angeben (zB. \"1U-\", \"EG-\" oder \"\" für Ohne) <" (if (= "" *<Koordpunkt-g*) "Ohne") ">: ")))
                                       (*<Koordpunkt-g*))))
  
  (setq *<Koordpunkt-i* (1+ (:MaxAttValue *<Koordpunkt-g*))
        *<Koordpunkt-i* (cond ((getint (strcat "\nPunktnummer angeben <" (itoa *<Koordpunkt-i*) ">: ")))
                              (*<Koordpunkt-i*)))
  
  (setq enlast (entlast))
  
  (while (progn
           (initget "Undo")
           (setq pnt (getpoint (strcat "\nEinfügepunkt angeben für '" (setq txt (strcat *<Koordpunkt-g* (:AddLeadingZeros (itoa *<Koordpunkt-i*) 1))) "' [Undo] <exit>: "))))
    (if (= pnt "Undo")
      (progn
        (if (equal enlast (entlast))
          (alert "Alle eingefügten Punkte gelöscht!")
          (progn
            (setq enl (entlast))
            (command "_.UNDO" 1)
            (if (not (equal enl (entlast)))
              (setq *<Koordpunkt-i* (1- *<Koordpunkt-i*))))))
      (progn
        (command "_.-INSERT" "SPI-Datenextraktionspunkt-CM" "_none" pnt "1" "1" "" txt "")
        (setq *<Koordpunkt-i* (1+ *<Koordpunkt-i*)))))
  ) ; end of defun

BTW I would suggest to get the CMDECHO OFF back. There are some build-in echos prompted by the INSERT command... not nice a confusing to me. 

 

0 Likes
Message 40 of 64

C.Utzinger
Collaborator
Collaborator

I have not forgotten that...

 

I'm just really busy Smiley Sad

0 Likes