command button insert block with attributes

I want to create a command button in the menu that will place a block. This block contains an attribute with a number that increases by 1 each time it is placed. There is also an attribute that takes over the value of a variable. I am unable to make both work. This works separately.

This is working for the attribute with incremental number:
*^C^C^P(command "-layer" "m" (strcat "00-punt" typesymbool1) "c" (strcat laagkleur1) "" "");setvar;attmode;1;setvar;attdia;0;setvar;attreq;1;(command "-insert" (findfile "controle1.dwg"));s;1;\0;$m=$(getvar,useri1);;;;setvar;useri1;$m=$(+,$(getvar,useri1),1)

This is working for the attribute containing the variable:
(command "-insert" (findfile "controle1.dwg") "s" "1" pause "" (getvar "useri1") "" (strcat controle))

Conbining is not working:
^C^C^P(command "-layer" "m" (strcat "00-punt" typesymbool1) "c" (strcat laagkleur1) "" "");setvar;attmode;1;setvar;attdia;0;setvar;attreq;1;(command "-insert" (findfile "controle1.dwg"));s;1;\0;$m=$(getvar,useri1);(strcad controle)*;;;setvar;useri1;$m=$(+,$(getvar,useri1),1)

I also tried this, but it is not working to:
*^C^C^P(command "-layer" "m" (strcat "00-punt" typesymbool1) "c" (strcat laagkleur1) "" "");setvar;attmode;1;setvar;attdia;0;setvar;attreq;1;(command "-insert" (findfile "controle1.dwg"));s;1;\0;$m=$(getvar,useri1);;;;setvar;useri1;$m=$(+,$(getvar,useri1),1);(command "_attedit" "" "" "CHECK" "" "last" "T" "R" (strcat controle) "")

How can i solve this?


  • 1st step take it all out of the menu and put it into a lisp much easier to manage just need 1 line then ^c^c(load "block-number")

    Much simpler to debug.

  • You're right. I am not very familiar with Lisp but with the help of Google I have come a long way. The problem with the code below is that if I cancel placing the blocks and then continue, a number is stored. Any idea how I can fix this?

    (defun c:controleblok ()

    (while T
    (command "-layer" "m" (strcat "00-CTR" typesymbool1) "c" (strcat laagkleur1) "" "")
    (command "_.insert"
    (findfile "controle1.dwg")
    pause ; for insertion point
    "" "" "" ; default scales/rotation
    (if attnum
    (itoa (setq attnum (1+ attnum)))
    (itoa (setq attnum (getint "startnummer: ")))
    (strcat controle)


  • Not sure about this (strcat laagkleur1) or (strcat controle)

    Findfile if you set your support path to where you have say all your blocks then "controle1.dwg" is fine

    Use _.-insert

  • Hans Hermans
    edited May 2021

    I meant, a number is skipped instead of stored.
    Findfile, (strcat laagkleur1) or (strcat controle) are working. these are set with other command buttons (see gif file in previous post)
    controle takes care of the tekst in one of the attributes, laagkleur1 of the color.

  • As the first step in the function, get the value of the incrementing variable and store it in a special variable for that purpose. Then write an *error* function that restores that value to the incrementing variable. That error-handling function will be executed on any abnormal termination.

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!