TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: BHenry85 on August 09, 2022, 01:56:48 PM

Title: Switch Block Attribute Value According to List
Post by: BHenry85 on August 09, 2022, 01:56:48 PM
Hello All,

I have a detail bubble block that is used for over 1000+ details. We use the external hyperlink, not the one within the block, property to link to a published detail in BIM 360 for each detail. The block name is "DetailBubble" and it has two attributes that we use called "SHEET_NUMBER" and "DETAIL_NUMBER". I have lisp that reads through all of the insertions of this block and will list these attributes combined together (EX: Detail Number (1) + Sheet Number (D1) = 1-D1) and the hyperlink within a CSV file. There are times when the hyperlink will be incorrect or changes and we have to update these links in any drawing that references that detail. This can be a vary tedious process on our users manually and I am looking for a way that I can automate this process. I would need something that first can take detail information in column a (1-D1) and separate those, run a search through all "DetailBubble" block insertions and find any that might match those values (DETAIL_NUMBER = 1, SHEET_NUMBER = D1), and then when it finds a match, replace the hyperlink with what is listed in column B in the CSV file. Before any one states, yes I have searched far and wide for something that might fit the bill, but I have only found something that would replace the hyperlink across ALL block insertions that have that name or others suggesting to do a find and replace which will not work in this scenario because broken links will have the same starting path as working hyperlinks. I have included some reference files that someone can test with and I appreciate anyone that can help on this in advance.
Title: Re: Switch Block Attribute Value According to List
Post by: BIGAL on August 09, 2022, 08:08:59 PM
As your excel file is unique to a dwg have you looked at adding the "Handle" to your xl this way a row of values is directly connected to a block so you can get that 1 block instantly. The only thing is does object exist check.

Google "handle autocad"  "Handent Autocad"
Title: Re: Switch Block Attribute Value According to List
Post by: mhupp on August 09, 2022, 09:09:11 PM
Was just going to say that BIGAL.

You could just skip outputting to the spread sheet entirely and modify the original lisp to first if the link is valid.

Code - Auto/Visual Lisp: [Select]
  1. (if (< (strlen hyprlnk) 208)

if its not search the other spread sheet that has valid links for the "SHEET_NUMBER" - "DETAIL_NUMBER" with a read loop to find the row number then use that to pull the valid link.
might be a little slow to process all the blocks but would be faster then making a second spread sheet using vlookup to get right links. then using another lisp to input those values back into the drawing.

Title: Re: Switch Block Attribute Value According to List
Post by: mhupp on August 10, 2022, 03:07:42 PM
Looks like RLX has something kinda like that but searches for x y z coords.

https://www.cadtutor.net/forum/topic/67036-lines-to-search-in-excel/?do=findComment&comment=548552
Title: Re: Switch Block Attribute Value According to List
Post by: BHenry85 on August 15, 2022, 10:33:39 AM
Apparently my last comment only took the quote and not anything else around it. I was wondering why I wasn't getting any responses and assumed I annoyed you both.

Hey @mhupp! Nice to see you again and thank you for your previous help on the first phase of this project located here:

https://www.cadtutor.net/forum/topic/75699-remove-duplicates-in-list/

I don't think that modifying the original script would help because I need something that first identified if there is an issue and then now another that would resolve it. I reviewed the lisp linked above and it looks like it would need a massive overhaul that is all way above me in order for it to fit my use case. We could change the initial script to leave the "SHEET_NUMBER" and "DETAIL_NUMBER" attributes in separate columns if that would aid the process of identifying the detail callouts that have incorrect hyperlinks and need to be corrected. Again, and as always, I greatly appreciate any and all help on the matter.