Author Topic: programatically edit text in a list and display on screen  (Read 1620 times)

0 Members and 1 Guest are viewing this topic.

andrew_nao

  • Guest
programatically edit text in a list and display on screen
« on: July 28, 2014, 09:52:43 AM »
hello all.
i want to say sorry in advanced for the title, it might be a little misleading as i didnt know how to properly word what i need help with.

let me explain my dilema.
i have a lisp file that scans my bill of material and turns it into a text file to be processed by another software program.
im looking to make a program that, when certain lines contain certain criteria it changes other lines.
(see picture for further explaination)

ok so in the picture, lets say that when i run my lisp and the code finds that the "section" with "ft" or "inches" has something there
i want it to take those numbers, add them together and replace the dash under "test3" with that number and then put dashes in the "ft" and "inches" section.

now, i have the code to compare sections and see that the ft and inches has something there, and i have code to add them and do almost everything else im looking to do, however what im difficult is to replace the dash under "test3" with it.
i know how to swap it out using entmod and selection sets but when the items are in lists,... yea im having trouble with it.
i just cant figure out how to get a list item as an selection set with out it asking me to select it. thats what im trying to avoid.

i hope i explained my issue and someone can point me in the right direction

edit: this is the code i was trying to use to swap it but like i said im trying to avoid the ssget
if there is a better way i would appreciate some guidance

thanks

Code: [Select]
(setq ss (ssget))
(setq vlaObj (vlax-ename->vla-object (ssname ss 0)))
(vla-put-textstring vlaObj (vl-string-subst "hello" (vla-get-textstring vlaObj) (vla-get-textstring vlaObj)))

« Last Edit: July 28, 2014, 09:56:33 AM by andrew_nao »

irneb

  • Water Moccasin
  • Posts: 1794
  • ACad R9-2016, Revit Arch 6-2016
Re: programatically edit text in a list and display on screen
« Reply #1 on: July 28, 2014, 11:08:42 AM »
Do you want to update the actual BOM on the drawing? If so, is each item in your BOM a block with attributes or simply lines & text?

It might help if you could post a sample DWG before & after applying your requirements.
Common sense - the curse in disguise. Because if you have it, you have to live with those that don't.

andrew_nao

  • Guest
Re: programatically edit text in a list and display on screen
« Reply #2 on: July 28, 2014, 11:40:49 AM »
thanks for the reply.

yes im looking to update the actual text on the bom.
its plain text

ive attached a sample dwg

cmwade77

  • Swamp Rat
  • Posts: 1443
Re: programatically edit text in a list and display on screen
« Reply #3 on: July 28, 2014, 02:37:17 PM »
Here's an alternative option:
Could you make the BOM an AutoCAD table and link it to an Excel file?

Then whenever you update it in AutoCAD or in Excel, it would automatically update the other.

I know it might not work for existing drawings, but might be helpful going forward. Just a thought.

andrew_nao

  • Guest
Re: programatically edit text in a list and display on screen
« Reply #4 on: July 28, 2014, 03:39:58 PM »
got what i was after.
needed to take a step back and refocus

Code: [Select]
(setq ss (ssget "X" (list (cons 1 (NTH 60 MAINLST)))))

(setq var (vlax-ename->vla-object (ssname ss 0)))
(vla-put-textstring var (vl-string-subst "HELLO" (vla-get-textstring var) (vla-get-textstring var)))

this does excatly what i want

now i got to get it to work with my program and in a loop with some if statements
im sure questions will follow soon

thanks :)

ronjonp

  • Needs a day job
  • Posts: 7529
Re: programatically edit text in a list and display on screen
« Reply #5 on: July 29, 2014, 12:11:24 PM »
got what i was after.
needed to take a step back and refocus

Code: [Select]
(setq ss (ssget "X" (list (cons 1 (NTH 60 MAINLST)))))

(setq var (vlax-ename->vla-object (ssname ss 0)))
(vla-put-textstring var (vl-string-subst "HELLO" (vla-get-textstring var) (vla-get-textstring var)))

this does excatly what i want

now i got to get it to work with my program and in a loop with some if statements
im sure questions will follow soon

thanks :)


Not quite sure what you are doing but this:
Code: [Select]
(vla-put-textstring var (vl-string-subst "HELLO" (vla-get-textstring var) (vla-get-textstring var)))is the same as this
Code: [Select]
(vla-put-textstring var "HELLO")??

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC