WIRENUMBER lisp routine

WIRENUMBER lisp routine

rfigueroa24PK4
Contributor Contributor
720 Views
11 Replies
Message 1 of 12

WIRENUMBER lisp routine

rfigueroa24PK4
Contributor
Contributor

Hello

 

A couple months ago I got help from someone creating a lisp routine for my wire labels. Since then I have simplfied the dynamic block and it requires the lisp routine to be changed. I gave it a shot by using chatgpt and every routine it gives me, when I load it, it gives me an error message "error: manlformed list on input". Not sure what this really means but Im reaching out for some help. 

 

Here are the basics of what I was looking for and will attach the dynamic block for reference.

 

  • Dynamic block has a WIRE attribute, I need the value changed when I click it a label numering sequence.
  • I have 10 different label types: A, U, RF, S, P, N, NA, NV, V, C
  • The goal is to type "WIRENUMBERS" for the lisp routine, it asks me what cable label I want, I choose a for example "A", then it asks me what number to start with, I type "001". Then I will pick 2 WIRE blocks and it labels them automatically to "A001" then I pick the next to blocks and it labels them "A002" and continues in increments of 1. 

 

If im not explaining something correctly or need more clarification please let me know. And thankyou for any and all help!

 

0 Likes
Accepted solutions (1)
721 Views
11 Replies
Replies (11)
Message 2 of 12

paullimapa
Mentor
Mentor

Perhaps you can also share the previous lisp routine that worked for you before?


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
0 Likes
Message 3 of 12

rfigueroa24PK4
Contributor
Contributor

I have attached the previous lisp routine. Keep in mind, this was a different setup as it included 2 different blocks for input and output. With the new blockit doesnt require input and output as the single block can do both. Thank you for reaching out!

0 Likes
Message 4 of 12

Moshe-A
Mentor
Mentor

@rfigueroa24PK4 ,

 

welcome back 😀

 

does that look familiar?

 

enjoy

Moshe

 

 

 

(defun c:wirenumber (/ _initget_options _prompt_options _format askKword ; local functions
		       cable idx ss ename)
  
 ; anonymous functions
 (setq _initget_options (lambda (l) (substr (apply 'strcat (mapcar (function (lambda (k) (strcat " " k " " (strcase k)))) l)) 2)))
 (setq _prompt_options  (lambda (l) (substr (apply 'strcat (mapcar (function (lambda (k) (strcat "/" (strcase k)))) l)) 2)))


 (defun _format (s l)
  (while (< (strlen s) l)
   (setq s (strcat "0" s))
  )
  s
 ); _format
  
 (defun askKword (lst / ask)
  (initget (_initget_options lst))
   
  (if (setq ask (getkword (strcat "\nChoose cable [" (_prompt_options lst) "]: ")))
   (strcase ask)
  )
 ); askKword
  
 (if (and
       (setq cable (askKword '("a" "u" "rf" "s" "p" "n" "na" "nv" "v" "c")))
       (setq idx (getint "\nStarting number: "))
     )
  (while (setq ss (ssget ":s:e+." '((0 . "insert") (2 . "wire,`*U*") (66 . 1))))
   (setq ename (ssname ss 0))
   (setpropertyvalue ename "wire" (strcat cable (_format (itoa idx) 3)))  
   (setq idx (1+ idx))
  ); while
 ); if

 (princ)
); c:wirenumber

 

0 Likes
Message 5 of 12

rfigueroa24PK4
Contributor
Contributor

Its you 😁😁😁

 

so I just tried that one and although it technically works, it only allows a single block click and it labels it. Like I click one block and it labels it A001 but then the second block gets labeled A002. It should be I select 2 blocks for A001 and then the next 2 blocks for A002 etc etc.

0 Likes
Message 6 of 12

pendean
Community Legend
Community Legend
0 Likes
Message 7 of 12

Moshe-A
Mentor
Mentor
Accepted solution

@rfigueroa24PK4  hi,

 

ok, now it changed to full select objects, make sure to select 2 tags each step (or you'll end up with all selected gets the same number 🤣)

 

Moshe

 

 

 

(defun c:wirenumber (/ _initget_options _prompt_options _format askKword ; local functions
		       cable idx ss ename)
  
 ; anonymous functions
 (setq _initget_options (lambda (l) (substr (apply 'strcat (mapcar (function (lambda (k) (strcat " " k " " (strcase k)))) l)) 2)))
 (setq _prompt_options  (lambda (l) (substr (apply 'strcat (mapcar (function (lambda (k) (strcat "/" (strcase k)))) l)) 2)))


 (defun _format (s l)
  (while (< (strlen s) l)
   (setq s (strcat "0" s))
  )
  s
 ); _format
  
 (defun askKword (lst / ask)
  (initget (_initget_options lst))
   
  (if (setq ask (getkword (strcat "\nChoose cable [" (_prompt_options lst) "]: ")))
   (strcase ask)
  )
 ); askKword
  
 (if (and
       (setq cable (askKword '("a" "u" "rf" "s" "p" "n" "na" "nv" "v" "c")))
       (setq idx (getint "\nStarting number: "))
     )
  (while (setq ss (ssget '((0 . "insert") (2 . "wire,`*U*") (66 . 1))))
   (foreach ename (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss)))
    (setpropertyvalue ename "wire" (strcat cable (_format (itoa idx) 3)))
   )
   (setq idx (1+ idx))
  ); while
 ); if

 (princ)
); c:wirenumber

 

 

 

 

0 Likes
Message 8 of 12

rfigueroa24PK4
Contributor
Contributor

No, this does not work form what Im seeing. This brings in a block which does not help, because al my blocks are already laid out. I would have to delete all the existing blocks to be replaced by the ones this brings in. Also from what Im seeing it increments by 1 but for every single block, it doesnt doo 1-1 then 2-2 it does 1, then 2, then 3. if im explaining that correctly😂

0 Likes
Message 9 of 12

rfigueroa24PK4
Contributor
Contributor

Moshe-A, you are freaking amazing. Thank you so much for your help again and getting this to work. I tried going the chatGPT route like everyone kept telling me but that was difficult as well when it starts giving you errors and it doesnt know how to fix it 😂

 

@rfigueroa24PK4 - this post has been edited due to Community Rules & Etiquette violation

0 Likes
Message 10 of 12

Moshe-A
Mentor
Mentor

wow this was fast...glade i could help here.

 

thank you 💪

0 Likes
Message 11 of 12

pendean
Community Legend
Community Legend

@rfigueroa24PK4 wrote:

...because al my blocks are already laid out....


Not at all, this tool relies on your BLOCKs being present, it is not a block-insert routine. Reading the page for the free LISP routine, it's not written cryptically.

0 Likes
Message 12 of 12

rfigueroa24PK4
Contributor
Contributor

Ok thats weird then, because I just tried using it, and it is bringing in the blocks as new blocks with the labeling. Ill keep trying it out, but the lisp Moshe-A provided works exactly 100% how I need it to work so thats great either way. Thanks for the help as well!!

0 Likes