Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Block Attribute Reset LISP

9 REPLIES 9
SOLVED
Reply
Message 1 of 10
jr_olmos23
364 Views, 9 Replies

Block Attribute Reset LISP

I have no idea how to write LISPs, so I ended up using ChatGPT to write one for me. I want the lisp to change the selected attributes from ONLY THE SELECTED blocks. However, the lisp applies the command to subsequent block iterations in the order they were created. I've tried explaining to GPT but either I can't explain myself in writing, or GPT doesn't know what it's doing I've attached LISP and test file. Thanks!

Labels (4)
9 REPLIES 9
Message 2 of 10
pendean
in reply to: jr_olmos23

So you only want a LISP that will change a "number" to the letter X in your custom block, nothing more.

And this is based on a manual selection by you of 'certain' blocks only? Or is there some other anticipated selection method?

pendean_0-1723662790148.png

 

Message 3 of 10
jr_olmos23
in reply to: pendean

Yes, that's exactly right. I don't know what you mean by an anticipated selection method; if the LISP prompts me to select the blocks, or whether I select the blocks first and then run the LISP... it does the iteration regardless. Don't know if that matters.

Message 4 of 10
paullimapa
in reply to: jr_olmos23

Attached is revised AttX.lsp

This will only  allow you to select block name: Bubble and change Tag name: NO.

If you want a different block name or tag name change that at the beginning of the code here:

  ;; Prompt user to select blocks
  (setq blknam "Bubble" ; block name
        tagnam "NO."    ; tag name

Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
Message 5 of 10
jr_olmos23
in reply to: paullimapa

So this one you provided is block specific and doesn't work on other blocks. I provided the bubbles as an example. I want to be able to select which tags to reset the values. I want the lisp to be able to work on any other block with other tags as well. The one I provided does what I want, except that it resets subsequent iterations; that is what I was looking to see if anybody could figure out.
Message 6 of 10
Kent1Cooper
in reply to: jr_olmos23

If it's the same Attribute and you want it changed to the same value in selected Blocks, and you need to select the Blocks anyway, no routine is necessary.  Just select the Blocks and you can change them all collectively in the Properties palette.

Kent1Cooper_0-1723667398334.png

Just pick in where it says *VARIES* and type in your X, and they'll all change [and only the selected ones].

Kent Cooper, AIA
Message 7 of 10
jr_olmos23
in reply to: Kent1Cooper

Well... now I feel like a fool lol. I should've thought of that before. Thanks for the hand slap.
Message 8 of 10
paullimapa
in reply to: jr_olmos23

I see what you're getting at. I made the adjustments with the attached AttX.lsp.

I incorporated your GetTags function with a minor modification and then created my own PickTag function which is similar to your SelectTag function except it'll now let you pick the Attribute Tag name from a cursor menu or at the command line instead of having to type the corresponding number.

paullimapa_1-1723673526258.png

 

What @Kent1Cooper pointed out is absolutely correct assuming you only select all matching Block names like with the Select Similar option or the Blocks all have matching Attribute Tag names. But if you would like to have the flexibility of selecting a mix of Blocks with different Attribute Tags on the screen then a lisp function would be required. 

Note your lisp code acquires the Attribute Tag names from the first Block selected. To select another Tag name selection from a different Block make that selection first and then enter Previous to perform the same operations on the same selection set.


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
Message 9 of 10
jr_olmos23
in reply to: paullimapa

Thanks, man. Yeah that's pretty much what I was angling for. We have blocks with different visibilities and tags that are related.
Message 10 of 10
paullimapa
in reply to: jr_olmos23

Glad to have helped. Actually this is the first time I’ve seen code generated from ChatGPT that had some pretty legit code…cheers!!!


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Forma Design Contest


AutoCAD Beta