A variable named $folblock ,bug my code

A variable named $folblock ,bug my code

Anonymous
Not applicable
905 Views
4 Replies
Message 1 of 5

A variable named $folblock ,bug my code

Anonymous
Not applicable

Hello,

I am learning slowly at the same time, but I have a problem when I come up with a variable named "$ folblock" (an old command according to my research).
How to avoid the error please?

 

If i delete--->   " (cons '2 $FOLBLOCK) " the code will works ,but I'm not sure, because I don't understand the usefulness of (cons '2 $FOLBLOCK)

(defun NUMFOL (/ FS LF FT FM E E1 NF)
  (check_init)
  (LIDERFOL 0)
  (if (/= LF 0)
    (progn
      (princ "\nMise à jour de la numérotation des folios  ... patientez\n")
      (setq FS (1+ (atoi (cdr (assoc 2 (tblnext "LAYER" T))))))
      (while (and (<= FS LF)(tblnext "LAYER"))
	(while (and (<= FS LF)(= (tblsearch "LAYER" (itoa FS)) nil))
	  (setq FS (1+ FS))
	)
	(setq FT (itoa FS))
	(if (= (strlen FT) 1)(setq FM (strcat "0" FT))(setq FM FT))
	(princ (strcat "\rTraitement du folio " FM "/" (itoa LF)))
	(setq E (ssget "X" (list (cons '8 FT) (cons '2 $FOLBLOCK))))
	(if E
	  (progn
	    (setq E (cdr (assoc -1 (entget (ssname E 0))))
		  E1 (entnext E)
	    )
	    (while (= "ATTRIB" (cdr (assoc 0 (entget E1))))
	      (setq E1 (entget E1))
	      (cond ((= (cdr (assoc 2 E1)) "NF")
		     (setq NF (cdr (assoc 1 E1)))
		     (setq E1 (subst (cons 1 FM) (assoc 1 E1) E1))
		     (entmod E1)
		     (entupd (cdr (assoc -1 E1)))
		    );end ATT=NF
	      );end cond
	      (setq E1 (entnext (cdr (assoc -1 E1))))
	    );end while
	  );end progn
	  (princ (strcat "\nFolio " FM " sans bloc "$FOLBLOCK", ignoré...\n"))
	);end if E
	(setq FS (1+ FS))
      );end while
      (princ "\nTerminé")
    );end progn
    (princ "\nAucun folio n'a été créé ! Utilisez NOUVFOL")
  );end if
(princ)
);end defun

 

Thans a lot !! 🙂

0 Likes
Accepted solutions (1)
906 Views
4 Replies
Replies (4)
Message 2 of 5

cadffm
Consultant
Consultant
Accepted solution

Your code doesn't set a variable $folblock,

so it looks like you copied just a part of the code.

 

 

For testing:

If you have a Block "BLOCK123", try this to see how it works:

Type in Acad:

(setq $folblock "BLOCK123")

Then run the code again.

 

 

Sebastian

0 Likes
Message 3 of 5

Sea-Haven
Mentor
Mentor

Just me I avoid using * # $ etc in variable names prevent any funny character errors if you want personal code do something like dev:var1 etc just write code then use replace to add the dev:

0 Likes
Message 4 of 5

lena.talkhina
Alumni
Alumni

Welcome to Autodesk Community @Anonymous !

 

It's been a while since we heard from you. Did you find a solution?

Don't hesitate to accept solution here in this thread if any of post was helpful.

 

Or, we are waiting for updated information to help you.

Находите сообщения полезными? Поставьте "НРАВИТСЯ" этим сообщениям! | Do you find the posts helpful? "LIKE" these posts!
На ваш вопрос успешно ответили? Нажмите кнопку "УТВЕРДИТЬ РЕШЕНИЕ" | Have your question been answered successfully? Click "ACCEPT SOLUTION" button.



Лена Талхина/Lena Talkhina
Менеджер Сообщества - Русский/Community Manager - Russian

0 Likes
Message 5 of 5

Anonymous
Not applicable

thank you so much ! with your help i found a block on my layer and was able to assign it to $ folblock. Thanks for your help 😁

0 Likes