Jump to content

Recommended Posts

Posted

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: ")

 

Posted

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))

 

Posted

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)))

 

 

image.thumb.png.fd410049135041b8234d74588c91e220.pngMulti radio buttons.lsp

  • Like 1
  • Thanks 1
Posted
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)))

 

 

image.thumb.png.fd410049135041b8234d74588c91e220.png Multi radio buttons.lsp 3.38 kB · 1 download

Thats super cool... image.thumb.png.4d35b9b00e5dd41b580be12e22dd0969.png

  • 4 weeks later...
Posted

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)))))))

 

 

 

 

Posted

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.

 

 

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...