SIMPLYCRAZY Posted June 21, 2021 Posted June 21, 2021 looking for some help... my program asks you for a part number. If its not created its fine but if the name already exists it basically will crash out. So what im looking to do is Get the part number? the part number usually starts with a letter then a number ex. P100 do a tablesearch for the block names if the part number names exists - then sequentially go up finding the next number that does not exist and update the PRTN if the part number name does not exist <continune on> (setq PRTN (getstring t "\nENTER NEW PANEL NUMBER: ") Quote
SIMPLYCRAZY Posted June 23, 2021 Author Posted June 23, 2021 Ok Scratch that weak attempt. Iv'e got this kinda working. 2 Questions 1.) Is there a wildcard * I can put in front of the 1000 so it will use the number and not the prefix. I always want the number to jump no matter the prefix. or do I have to study the substr. 2.) in the Setq Pl line how do keep the last prefix number selected to use the next time I invoke the command. right now its defaulting to "P". Iv'e used getstring and that works but I would like it to follow the format I have going. Any help would be greatly appreciated. (setq i 1000) (while (tblsearch "BLOCK" (setq BLKN (itoa (setq i (1+ i)))))) (initget "P A B C D E F G H J K L M N P Q R S T U V W X Y Z") (setq PL (cond ((getkword "\nChoose PREFIX LETTER [A/B/C/D/E/F/G/H/J/K/L/M/N/P/Q/R/S/T/U/V/W/X/Y/Z] <P>: ")) ("P"))) (setq PRTN (strcat PL BLKN)) Quote
BIGAL Posted June 24, 2021 Posted June 24, 2021 For 1 (vlax-for block (vla-get-blocks (vla-get-activedocument (vlax-get-acad-object))) maybe do wcmatch i ie blk1002 ie found a block with 1002 in name ) for 2 I had a go using Multi radio buttons there is a option for A-Z its in the code examples at start of code, uses a defun to make the A-Z list its pushing the limits, use "H" horizontal option, when ran a variable BUT is set this is last item picked so default button will change to match last picked. (if (not AH:Butts)(load "Multi Radio buttons.lsp")) (if (not but)(setq but 16)) (setq ans2 (ah:butts but "h" (make_letters "Please choose" 65 26))) Multi radio buttons.lsp 1 1 Quote
SIMPLYCRAZY Posted June 24, 2021 Author Posted June 24, 2021 2 hours ago, BIGAL said: For 1 (vlax-for block (vla-get-blocks (vla-get-activedocument (vlax-get-acad-object))) maybe do wcmatch i ie blk1002 ie found a block with 1002 in name ) for 2 I had a go using Multi radio buttons there is a option for A-Z its in the code examples at start of code, uses a defun to make the A-Z list its pushing the limits, use "H" horizontal option, when ran a variable BUT is set this is last item picked so default button will change to match last picked. (if (not AH:Butts)(load "Multi Radio buttons.lsp")) (if (not but)(setq but 16)) (setq ans2 (ah:butts but "h" (make_letters "Please choose" 65 26))) Multi radio buttons.lsp 3.38 kB · 1 download Thats super cool... Quote
SIMPLYCRAZY Posted July 18, 2021 Author Posted July 18, 2021 Starting over......Kinda -hope someone will restart this quest from here. Well thought I could figure this one out and its just not clicking for me. I have looked and looked for an example to try to understand the wcmatch (wchmatch "*1???) but im just not sure how to use in the routine. When I invoke it stats off with the default P1001, and next time P1002. but if i want to change the prefix in the next round say H1003 it will start over at H1001. !i equals 1002 before invoke for third time so im not sure how its resetting. (setq PRE (getstring (strcat "\nEnter One Prefix Letter <" (cond (PL) ("P")) ">: ")) PL (cond ((/= PRE "") (strcase PRE)) (PL) ("P"))) (setq i 1000) (while (tblsearch "BLOCK" (setq PRTN (strcat PL (itoa (setq i (1+ i))))))) Quote
BIGAL Posted July 18, 2021 Posted July 18, 2021 It maybe easier to make a list of all block names, WCMATCH can use "P*" and make a new list of the Pxxxx blocks, then sort and look at the highest one, I also use Lee-mac parse number to get the number. Quote
Recommended Posts
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.